@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.
package/dist/index.d.ts CHANGED
@@ -1,6 +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-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
- import * as _theokit_sdk 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, e as SkillsOptions, T as ToolOptions, A as ApprovalOptions, H as HumanInTheLoopOptions, f as AgentManifestEntry } from './bridge-entry-Ddu3Ug_3.js';
2
+ export { g as AGENT_BRAND, h as AfterToolCallContext, i as AgentBuilder, j as AgentDefinition, k as AgentDefinitionError, l as AgentExecutionContext, m as AgentManifest, n as AgentManifestSource, o as AgentManifestTool, p as AgentOptions, 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, K as BudgetOptions, N as CheckpointSavedEvent, O as CompiledContextWindow, P as ContextualTool, Q as CostBudgetExceededError, U as DEFAULT_MAX_ITERATIONS, V as DefineAgentConfig, W as DelegateFn, X as DelegateOptions, Y as DelegationError, Z as DoneEvent, _ as ErrorEvent, $ as FileEditEvent, a0 as GuardrailAction, a1 as GuardrailPhase, a2 as GuardrailResult, a3 as GuardrailViolationError, a4 as HitlDecision, a5 as InferAgentInput, a6 as InferAgentToolNames, a7 as IterationEvent, a8 as LLMCallContext, a9 as LoopFinishReason, aa as LoopOutcome, ab as LoopStrategyConfig, ac as MainLoopOptions, ad as McpApprovalSpec, ae as McpRegistryConfig, af as McpRequestContext, ag as McpSelection, ah as PartialToolCallEvent, ai as PolicyHandler, aj as ProcessInputContext, ak as ReflectionContext, al as ReflectionResult, am as ReflectionStrategyConfig, an as RunStartedEvent, ao as ScoreVerdict, ap as ScoredDelegation, aq as Scorer, ar as SdkAgentHandle, as as SdkMessage, at as Segment, au as SkillsRequestContext, av as SkillsSelection, aw as StateUpdateEvent, ax as TextDeltaEvent, ay as ThinkingEvent, az as TimeoutAction, aA as ToolCallEvent, aB as ToolCallVeto, aC as ToolHooks, aD as ToolHooksPlugin, aE as ToolResultEvent, aF as ToolWalkResult, aG as ToolboxOptions, 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, b8 as ladderReflectionStrategy, b9 as loopStrategyConfigSchema, ba as mcpRegistry, bb as mcpToolApprovals, bc as noopReflectionStrategy, bd as presentUIMessageStream, be as projectContextMetadataOnlyKnobs, bf as reflectionStrategyConfigSchema, bg as resolveEnabledSkills, bh as resolveLoopStrategy, bi as resolveMcpServers, bj as runWithApiErrorHandling, bk as streamAgentResponse, bl as streamAgentUIMessages, bm as toAgentFactory, bn as translateSdkEvent } from './bridge-entry-Ddu3Ug_3.js';
4
3
  import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool, InlineSkill } from '@theokit/sdk';
5
4
  import { RetryOptions } from '@theokit/sdk/retry';
6
5
  import { CompressibleMessage } from '@theokit/sdk/compaction';
@@ -498,10 +497,16 @@ declare class ToolsCapability implements Capability {
498
497
  apply(draft: CompiledAgentOptionsDraft): void;
499
498
  }
500
499
  /**
501
- * Enables skills by name. FUNCTION, not class: it carries no behavior beyond assignment a class here
502
- * would be ceremony (the honest counter-example to "everything must be a class").
500
+ * Enables skills by name (or inline). M57: a CLASS now (was a factory function). Validation moves to
501
+ * the constructor fail-fast at authoring, the same place `ModelCapability`/`AgentConfigCapability`
502
+ * validate. The `apply` body (delegate + merge) is unchanged, so the compiled output is identical.
503
503
  */
504
- declare const skills: (entries: readonly (string | InlineSkill)[]) => Capability;
504
+ declare class SkillsCapability implements Capability {
505
+ #private;
506
+ readonly name = "skills";
507
+ constructor(entries: readonly (string | InlineSkill)[]);
508
+ apply(draft: CompiledAgentOptionsDraft): void;
509
+ }
505
510
 
506
511
  /**
507
512
  * M52 — resolution + composition. The registry is what unlocks FILE-BASED authoring (a config lists
@@ -531,51 +536,122 @@ declare class CapabilityPreset implements Capability {
531
536
  apply(draft: CompiledAgentOptionsDraft): void;
532
537
  }
533
538
 
539
+ /**
540
+ * M53 — the capabilities that replace the waist-bound agent decorators, one per field the decorator
541
+ * pipeline produces today (`docs/agents/decorator-to-capability.md` § A).
542
+ *
543
+ * M57 reverses ADR 0001 § 4 (which kept the pure-assignment ones as a factory function to avoid
544
+ * "13 near-identical classes"): the authoring surface is now 100% classes, aligned with the SDK's
545
+ * `X.create()`/class shape. The `FieldCapability` base keeps the assignment ones DRY (one line each);
546
+ * the behaviour-carrying ones are written out. Rationale in ADR 0005.
547
+ */
548
+ /**
549
+ * Base for a capability whose only job is to assign one waist field — no validation, no merge, no
550
+ * precedence. M57: this replaces the `fieldCapability(name, field)` factory function with a class, so
551
+ * the authoring surface is 100% classes (aligned with the SDK's `X.create()` and the existing
552
+ * `ModelCapability`). The subclasses below are one line each; the shared `apply` lives here (DRY).
553
+ * NOT the Template-Method the ADR-0001 refused — that was inheritance of variable *behaviour*
554
+ * (`shouldContinue`); here the base carries *data* (name/field) and `apply` is identical for all.
555
+ */
556
+ declare abstract class FieldCapability<K extends keyof CompiledAgentOptionsDraft> implements Capability {
557
+ private readonly value;
558
+ abstract readonly name: string;
559
+ protected abstract readonly field: K;
560
+ constructor(value: NonNullable<CompiledAgentOptionsDraft[K]>);
561
+ apply(draft: CompiledAgentOptionsDraft): void;
562
+ }
534
563
  /** `@Memory` → `memory`. */
535
- declare const memory: (value: NonNullable<MemoryOptions | _theokit_sdk.MemorySettings | undefined>) => Capability;
564
+ declare class MemoryCapability extends FieldCapability<'memory'> {
565
+ readonly name = "memory";
566
+ protected readonly field: "memory";
567
+ }
536
568
  /**
537
569
  * `@ContextWindow` → `context`. DELEGATES to `compileContextWindow`, which is the canonical
538
570
  * `ContextWindowOptions → ContextSettings` conversion (it also reports the metadata-only knobs).
539
571
  * Taking a pre-converted value here would duplicate that knowledge — the exact divergence the M52
540
572
  * zero-behavior proof caught in `skills`.
541
573
  */
542
- declare const contextWindow: (options: ContextWindowOptions) => Capability;
574
+ declare class ContextWindowCapability implements Capability {
575
+ private readonly options;
576
+ readonly name = "context-window";
577
+ constructor(options: ContextWindowOptions);
578
+ apply(draft: CompiledAgentOptionsDraft): void;
579
+ }
543
580
  /** `@ProjectContext` → `projectContext`. */
544
- declare const projectContext: (value: ProjectContextOptions) => Capability;
581
+ declare class ProjectContextCapability extends FieldCapability<'projectContext'> {
582
+ readonly name = "project-context";
583
+ protected readonly field: "projectContext";
584
+ }
545
585
  /** `@MCP` → `mcpServers`. */
546
- declare const mcpServers: (value: McpServersMap) => Capability;
586
+ declare class McpServersCapability extends FieldCapability<'mcpServers'> {
587
+ readonly name = "mcp";
588
+ protected readonly field: "mcpServers";
589
+ }
547
590
  /** `@Guardrails` → `guardrails`. */
548
- declare const guardrails: (value: readonly Guardrail[]) => Capability;
591
+ declare class GuardrailsCapability extends FieldCapability<'guardrails'> {
592
+ readonly name = "guardrails";
593
+ protected readonly field: "guardrails";
594
+ }
549
595
  /**
550
596
  * `@Checkpoint` → `checkpoint`. Carries the non-durable WARNING the metadata walk used to emit: only
551
597
  * `'filesystem'` selects the SDK's durable store, so any other storage cannot resume across
552
598
  * requests. The warning moves WITH the feature — a declared checkpoint that silently cannot resume
553
599
  * is exactly the kind of no-op this project refuses to ship.
554
600
  */
555
- declare const checkpoint: (options: CompiledAgentOptions["checkpoint"]) => Capability;
601
+ declare class CheckpointCapability implements Capability {
602
+ private readonly options;
603
+ readonly name = "checkpoint";
604
+ constructor(options: CompiledAgentOptions['checkpoint']);
605
+ apply(draft: CompiledAgentOptionsDraft): void;
606
+ }
556
607
  /**
557
608
  * `@HumanInTheLoop` → `hitl`, keyed `"<namespace>_<tool>"` — the same key `compileHitlGates` mints
558
609
  * via `toolRuntimeName`. The separator is `_`, not `.`: the dot is outside the charset the SDK
559
610
  * accepts, and a gate keyed with a dot silently failed to match its tool (theokit#145).
560
611
  */
561
- declare const humanInTheLoop: (value: Map<string, HumanInTheLoopOptions>) => Capability;
612
+ declare class HumanInTheLoopCapability extends FieldCapability<'hitl'> {
613
+ readonly name = "human-in-the-loop";
614
+ protected readonly field: "hitl";
615
+ }
562
616
  /**
563
617
  * `@SubAgents` → `agents`. MERGES instead of `setOnce`: `agents` is a pre-seeded collection on the
564
618
  * draft (`createDraft` gives it `{}`), so a `setOnce` would conflict against the seed itself — the
565
619
  * same trap the pre-seeded `stream` sprang in M52. Merging also lets a preset declare a baseline
566
620
  * child set that a call site extends.
567
621
  */
568
- declare const subAgents: (children: CompiledAgentOptions["agents"]) => Capability;
622
+ declare class SubAgentsCapability implements Capability {
623
+ private readonly children;
624
+ readonly name = "sub-agents";
625
+ constructor(children: CompiledAgentOptions['agents']);
626
+ apply(draft: CompiledAgentOptionsDraft): void;
627
+ }
569
628
  /**
570
629
  * `@Skills({ include, autoDiscover })` → `skills`. Delegates to `compileSkills` (same reason as
571
630
  * `contextWindow`). Distinct from the M52 `skills([...])`, which takes the plain name/inline list.
572
631
  */
573
- declare const skillsOptions: (options: SkillsOptions) => Capability;
632
+ declare class SkillsOptionsCapability implements Capability {
633
+ private readonly options;
634
+ readonly name = "skills";
635
+ constructor(options: SkillsOptions);
636
+ apply(draft: CompiledAgentOptionsDraft): void;
637
+ }
574
638
  /** Functional-path fields that had no decorator source — closing the gap list, not adding surface. */
575
- declare const settingSources: (value: readonly _theokit_sdk.SettingSource[]) => Capability;
576
- declare const plugins: (value: readonly unknown[]) => Capability;
577
- declare const runContext: (value: Record<string, unknown>) => Capability;
578
- declare const skillsResolver: (value: NonNullable<SkillsSelection | undefined>) => Capability;
639
+ declare class SettingSourcesCapability extends FieldCapability<'settingSources'> {
640
+ readonly name = "setting-sources";
641
+ protected readonly field: "settingSources";
642
+ }
643
+ declare class PluginsCapability extends FieldCapability<'plugins'> {
644
+ readonly name = "plugins";
645
+ protected readonly field: "plugins";
646
+ }
647
+ declare class RunContextCapability extends FieldCapability<'runContext'> {
648
+ readonly name = "run-context";
649
+ protected readonly field: "runContext";
650
+ }
651
+ declare class SkillsResolverCapability extends FieldCapability<'skillsResolver'> {
652
+ readonly name = "skills-resolver";
653
+ protected readonly field: "skillsResolver";
654
+ }
579
655
  /** The scalar agent config (name/route are HTTP concerns, never agent config). */
580
656
  interface AgentConfig {
581
657
  readonly systemPrompt?: CompiledAgentOptions['systemPrompt'];
@@ -872,4 +948,4 @@ declare class AcpClient {
872
948
  private handleServerRequest;
873
949
  }
874
950
 
875
- 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 };
951
+ 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, CheckpointCapability, type CompactionCallOptions, type CompactionStrategyConfig, CompiledAgentOptions, type CompiledAgentOptionsDraft, CompiledTool, ConfigurationError, ContextWindowCapability, type CostGuardOptions, DEFAULT_KEEP_TOKENS, DelegationResult, FieldCapability, type FinalizedDraft, Guardrail, GuardrailsCapability, HumanInTheLoopCapability, HumanInTheLoopOptions, LoopStrategy, MCP_PROTOCOL_VERSION, MainLoopCapability, MainLoopMeta, type McpJsonSchema, type McpServerInfo, McpServersCapability, type McpToolDescriptor, MemoryCapability, ModelCapability, type OutputModerationOptions, type PiiOptions, PluginsCapability, ProjectContextCapability, type PromptInjectionOptions, type ProvenanceEntry, ReasoningEffort, ReflectionStrategy, RoundStreamFactory, RunContextCapability, SettingSourcesCapability, SkillsCapability, SkillsOptionsCapability, SkillsResolverCapability, StreamEvent, SubAgentsCapability, type Summarize, type ToolDeclaration, ToolOptions, ToolboxCapability, type ToolboxSource, ToolsCapability, type TranscriptCompactionStrategy, UnknownCapabilityError, applyCapabilities, buildAgentCard, buildMcpToolDescriptors, compactionStrategyConfigSchema, costGuard, createA2ATool, createDraft, deriveConversationId, encodeAcpMessage, estimateTokens, mcpServerInfo, moderateOutputStream, outputModeration, parseConversationId, piiDetector, promptInjectionDetector, resolveCompactionStrategy, runInputGuards, runOutputGuards, setOnce, tokenBudgetCompactionStrategy, unicodeNormalizer, wellKnownCardPath };
package/dist/index.js CHANGED
@@ -1,16 +1,17 @@
1
1
  import {
2
2
  AGENT_BRAND,
3
+ AgentBuilder,
3
4
  AgentDefinitionError,
4
5
  AgentRunner,
5
6
  AgentRunnerBuilder,
6
7
  BudgetExceededError,
7
8
  ConfigurationError,
9
+ ContextualTool,
8
10
  CostBudgetExceededError,
9
11
  DEFAULT_KEEP_TOKENS,
10
12
  DEFAULT_MAX_ITERATIONS,
11
13
  DelegationError,
12
14
  GuardrailViolationError,
13
- agent,
14
15
  agentsPlugin,
15
16
  buildModelSelection,
16
17
  compactionStrategyConfigSchema,
@@ -22,7 +23,6 @@ import {
22
23
  compileSkills,
23
24
  compileSkillsSelection,
24
25
  compileTools,
25
- contextualTool,
26
26
  costGuard,
27
27
  createAgentExecutionContext,
28
28
  createApiErrorHandler,
@@ -70,7 +70,7 @@ import {
70
70
  toolRuntimeName,
71
71
  translateSdkEvent,
72
72
  unicodeNormalizer
73
- } from "./chunk-C2DALG62.js";
73
+ } from "./chunk-OKG5LRGV.js";
74
74
  import {
75
75
  __name
76
76
  } from "./chunk-7QVYU63E.js";
@@ -177,66 +177,71 @@ var ToolsCapability = class {
177
177
  });
178
178
  }
179
179
  };
180
- var skills = /* @__PURE__ */ __name((entries) => {
181
- if (!Array.isArray(entries)) {
182
- throw new ConfigurationError(`skills: esperava array de nomes, recebi ${describe(entries)}`);
183
- }
184
- for (const e of entries) {
185
- if (typeof e === "string") {
186
- if (e.trim().length === 0) {
187
- throw new ConfigurationError("skills: nome vazio \u2014 use um nome de skill n\xE3o vazio");
188
- }
189
- continue;
190
- }
191
- if (typeof e !== "object" || e === null || Array.isArray(e)) {
192
- throw new ConfigurationError(`skills: entrada inv\xE1lida (${describe(e)}) \u2014 use um nome ou um skill inline`);
180
+ var SkillsCapability = class {
181
+ static {
182
+ __name(this, "SkillsCapability");
183
+ }
184
+ name = "skills";
185
+ #entries;
186
+ constructor(entries) {
187
+ if (!Array.isArray(entries)) {
188
+ throw new ConfigurationError(`skills: esperava array de nomes, recebi ${describe(entries)}`);
193
189
  }
194
- for (const field of [
195
- "name",
196
- "description",
197
- "instructions"
198
- ]) {
199
- const value = e[field];
200
- if (typeof value !== "string" || value.trim().length === 0) {
201
- throw new ConfigurationError(`skills: skill inline sem \`${field}\` v\xE1lido (${describe(value)}) \u2014 name, description e instructions s\xE3o obrigat\xF3rios`);
190
+ for (const e of entries) {
191
+ if (typeof e === "string") {
192
+ if (e.trim().length === 0) {
193
+ throw new ConfigurationError("skills: nome vazio \u2014 use um nome de skill n\xE3o vazio");
194
+ }
195
+ continue;
196
+ }
197
+ if (typeof e !== "object" || e === null || Array.isArray(e)) {
198
+ throw new ConfigurationError(`skills: entrada inv\xE1lida (${describe(e)}) \u2014 use um nome ou um skill inline`);
199
+ }
200
+ for (const field of [
201
+ "name",
202
+ "description",
203
+ "instructions"
204
+ ]) {
205
+ const value = e[field];
206
+ if (typeof value !== "string" || value.trim().length === 0) {
207
+ throw new ConfigurationError(`skills: skill inline sem \`${field}\` v\xE1lido (${describe(value)}) \u2014 name, description e instructions s\xE3o obrigat\xF3rios`);
208
+ }
202
209
  }
203
210
  }
211
+ this.#entries = entries;
204
212
  }
205
- return {
206
- name: "skills",
207
- apply: /* @__PURE__ */ __name((draft) => {
208
- const compiled = compileSkillsSelection(entries.slice());
209
- if (compiled.skills === void 0) return;
210
- const previous = draft.skills;
211
- draft.skills = previous === void 0 ? compiled.skills : {
212
- // The spread is exhaustive only because `compileSkillsSelection` emits a FIXED 3-key
213
- // shape (`enabled`, `autoInject: true`, and `inline` iff non-empty) `enabled` and
214
- // `inline` are both re-derived below, and `autoInject` is the same literal on both
215
- // sides. TRAP for the future: if a capability ever authors `autoInject: false`, this
216
- // spread would silently normalize it back to `true`. Unreachable today (no capability
217
- // and no reference array form can express it) — revisit when one can.
218
- ...previous,
219
- ...compiled.skills,
220
- enabled: [
221
- ...previous.enabled ?? [],
222
- ...compiled.skills.enabled ?? []
223
- ],
224
- ...previous.inline !== void 0 || compiled.skills.inline !== void 0 ? {
225
- inline: [
226
- ...previous.inline ?? [],
227
- ...compiled.skills.inline ?? []
228
- ]
229
- } : {}
230
- };
231
- draft.provenance.push({
232
- capability: "skills",
233
- contributed: [
234
- "skills"
213
+ apply(draft) {
214
+ const compiled = compileSkillsSelection(this.#entries.slice());
215
+ if (compiled.skills === void 0) return;
216
+ const previous = draft.skills;
217
+ draft.skills = previous === void 0 ? compiled.skills : {
218
+ // The spread is exhaustive only because `compileSkillsSelection` emits a FIXED 3-key
219
+ // shape (`enabled`, `autoInject: true`, and `inline` iff non-empty) — `enabled` and
220
+ // `inline` are both re-derived below, and `autoInject` is the same literal on both
221
+ // sides. TRAP for the future: if a capability ever authors `autoInject: false`, this
222
+ // spread would silently normalize it back to `true`. Unreachable today (no capability
223
+ // and no reference array form can express it) revisit when one can.
224
+ ...previous,
225
+ ...compiled.skills,
226
+ enabled: [
227
+ ...previous.enabled ?? [],
228
+ ...compiled.skills.enabled ?? []
229
+ ],
230
+ ...previous.inline !== void 0 || compiled.skills.inline !== void 0 ? {
231
+ inline: [
232
+ ...previous.inline ?? [],
233
+ ...compiled.skills.inline ?? []
235
234
  ]
236
- });
237
- }, "apply")
238
- };
239
- }, "skills");
235
+ } : {}
236
+ };
237
+ draft.provenance.push({
238
+ capability: this.name,
239
+ contributed: [
240
+ "skills"
241
+ ]
242
+ });
243
+ }
244
+ };
240
245
 
241
246
  // src/capability/registry.ts
242
247
  var UnknownCapabilityError = class extends Error {
@@ -287,62 +292,147 @@ var CapabilityPreset = class {
287
292
  };
288
293
 
289
294
  // src/capability/agent-capabilities.ts
290
- function fieldCapability(name, field) {
291
- return (value) => ({
292
- name,
293
- apply: /* @__PURE__ */ __name((draft) => {
294
- setOnce(draft, field, value, name);
295
- }, "apply")
296
- });
297
- }
298
- __name(fieldCapability, "fieldCapability");
299
- var memory = fieldCapability("memory", "memory");
300
- var contextWindow = /* @__PURE__ */ __name((options) => ({
301
- name: "context-window",
302
- apply: /* @__PURE__ */ __name((draft) => {
303
- setOnce(draft, "context", compileContextWindow(options).context, "context-window");
304
- }, "apply")
305
- }), "contextWindow");
306
- var projectContext = fieldCapability("project-context", "projectContext");
307
- var mcpServers = fieldCapability("mcp", "mcpServers");
308
- var guardrails = fieldCapability("guardrails", "guardrails");
309
- var checkpoint = /* @__PURE__ */ __name((options) => ({
310
- name: "checkpoint",
311
- apply: /* @__PURE__ */ __name((draft) => {
312
- if (options !== void 0 && options.storage !== "filesystem") {
313
- console.warn(`[THEO_AGENT_CHECKPOINT_STORAGE_METADATA_ONLY] checkpoint({ storage: '${options.storage ?? "memory"}' }) does NOT resume across requests \u2014 only 'filesystem' selects the SDK's durable conversation store. Use checkpoint({ storage: 'filesystem' }) for cross-request resume.`);
295
+ var FieldCapability = class {
296
+ static {
297
+ __name(this, "FieldCapability");
298
+ }
299
+ value;
300
+ constructor(value) {
301
+ this.value = value;
302
+ }
303
+ apply(draft) {
304
+ setOnce(draft, this.field, this.value, this.name);
305
+ }
306
+ };
307
+ var MemoryCapability = class extends FieldCapability {
308
+ static {
309
+ __name(this, "MemoryCapability");
310
+ }
311
+ name = "memory";
312
+ field = "memory";
313
+ };
314
+ var ContextWindowCapability = class {
315
+ static {
316
+ __name(this, "ContextWindowCapability");
317
+ }
318
+ options;
319
+ name = "context-window";
320
+ constructor(options) {
321
+ this.options = options;
322
+ }
323
+ apply(draft) {
324
+ setOnce(draft, "context", compileContextWindow(this.options).context, this.name);
325
+ }
326
+ };
327
+ var ProjectContextCapability = class extends FieldCapability {
328
+ static {
329
+ __name(this, "ProjectContextCapability");
330
+ }
331
+ name = "project-context";
332
+ field = "projectContext";
333
+ };
334
+ var McpServersCapability = class extends FieldCapability {
335
+ static {
336
+ __name(this, "McpServersCapability");
337
+ }
338
+ name = "mcp";
339
+ field = "mcpServers";
340
+ };
341
+ var GuardrailsCapability = class extends FieldCapability {
342
+ static {
343
+ __name(this, "GuardrailsCapability");
344
+ }
345
+ name = "guardrails";
346
+ field = "guardrails";
347
+ };
348
+ var CheckpointCapability = class {
349
+ static {
350
+ __name(this, "CheckpointCapability");
351
+ }
352
+ options;
353
+ name = "checkpoint";
354
+ constructor(options) {
355
+ this.options = options;
356
+ }
357
+ apply(draft) {
358
+ if (this.options !== void 0 && this.options.storage !== "filesystem") {
359
+ console.warn(`[THEO_AGENT_CHECKPOINT_STORAGE_METADATA_ONLY] checkpoint({ storage: '${this.options.storage ?? "memory"}' }) does NOT resume across requests \u2014 only 'filesystem' selects the SDK's durable conversation store. Use checkpoint({ storage: 'filesystem' }) for cross-request resume.`);
314
360
  }
315
- setOnce(draft, "checkpoint", options, "checkpoint");
316
- }, "apply")
317
- }), "checkpoint");
318
- var humanInTheLoop = fieldCapability("human-in-the-loop", "hitl");
319
- var subAgents = /* @__PURE__ */ __name((children) => ({
320
- name: "sub-agents",
321
- apply: /* @__PURE__ */ __name((draft) => {
322
- for (const [name, child] of Object.entries(children)) {
361
+ setOnce(draft, "checkpoint", this.options, this.name);
362
+ }
363
+ };
364
+ var HumanInTheLoopCapability = class extends FieldCapability {
365
+ static {
366
+ __name(this, "HumanInTheLoopCapability");
367
+ }
368
+ name = "human-in-the-loop";
369
+ field = "hitl";
370
+ };
371
+ var SubAgentsCapability = class {
372
+ static {
373
+ __name(this, "SubAgentsCapability");
374
+ }
375
+ children;
376
+ name = "sub-agents";
377
+ constructor(children) {
378
+ this.children = children;
379
+ }
380
+ apply(draft) {
381
+ for (const [name, child] of Object.entries(this.children)) {
323
382
  if (name in draft.agents && draft.agents[name] !== child) {
324
383
  throw new ConfigurationError(`sub-agents: filho "${name}" declarado duas vezes com defini\xE7\xF5es diferentes`);
325
384
  }
326
385
  draft.agents[name] = child;
327
386
  }
328
387
  draft.provenance.push({
329
- capability: "sub-agents",
388
+ capability: this.name,
330
389
  contributed: [
331
390
  "agents"
332
391
  ]
333
392
  });
334
- }, "apply")
335
- }), "subAgents");
336
- var skillsOptions = /* @__PURE__ */ __name((options) => ({
337
- name: "skills",
338
- apply: /* @__PURE__ */ __name((draft) => {
339
- setOnce(draft, "skills", compileSkills(options), "skills");
340
- }, "apply")
341
- }), "skillsOptions");
342
- var settingSources = fieldCapability("setting-sources", "settingSources");
343
- var plugins = fieldCapability("plugins", "plugins");
344
- var runContext = fieldCapability("run-context", "runContext");
345
- var skillsResolver = fieldCapability("skills-resolver", "skillsResolver");
393
+ }
394
+ };
395
+ var SkillsOptionsCapability = class {
396
+ static {
397
+ __name(this, "SkillsOptionsCapability");
398
+ }
399
+ options;
400
+ name = "skills";
401
+ constructor(options) {
402
+ this.options = options;
403
+ }
404
+ apply(draft) {
405
+ setOnce(draft, "skills", compileSkills(this.options), this.name);
406
+ }
407
+ };
408
+ var SettingSourcesCapability = class extends FieldCapability {
409
+ static {
410
+ __name(this, "SettingSourcesCapability");
411
+ }
412
+ name = "setting-sources";
413
+ field = "settingSources";
414
+ };
415
+ var PluginsCapability = class extends FieldCapability {
416
+ static {
417
+ __name(this, "PluginsCapability");
418
+ }
419
+ name = "plugins";
420
+ field = "plugins";
421
+ };
422
+ var RunContextCapability = class extends FieldCapability {
423
+ static {
424
+ __name(this, "RunContextCapability");
425
+ }
426
+ name = "run-context";
427
+ field = "runContext";
428
+ };
429
+ var SkillsResolverCapability = class extends FieldCapability {
430
+ static {
431
+ __name(this, "SkillsResolverCapability");
432
+ }
433
+ name = "skills-resolver";
434
+ field = "skillsResolver";
435
+ };
346
436
  var AgentConfigCapability = class {
347
437
  static {
348
438
  __name(this, "AgentConfigCapability");
@@ -773,6 +863,7 @@ export {
773
863
  AGENT_BRAND,
774
864
  AcpClient,
775
865
  AcpMessageDecoder,
866
+ AgentBuilder,
776
867
  AgentConfigCapability,
777
868
  AgentDefinitionError,
778
869
  AgentRunner,
@@ -781,25 +872,39 @@ export {
781
872
  CapabilityConflictError,
782
873
  CapabilityPreset,
783
874
  CapabilityRegistry,
875
+ CheckpointCapability,
784
876
  ConfigurationError,
877
+ ContextWindowCapability,
878
+ ContextualTool,
785
879
  CostBudgetExceededError,
786
880
  DEFAULT_KEEP_TOKENS,
787
881
  DEFAULT_MAX_ITERATIONS,
788
882
  DelegationError,
883
+ FieldCapability,
789
884
  GuardrailViolationError,
885
+ GuardrailsCapability,
886
+ HumanInTheLoopCapability,
790
887
  MCP_PROTOCOL_VERSION,
791
888
  MainLoopCapability,
889
+ McpServersCapability,
890
+ MemoryCapability,
792
891
  ModelCapability,
892
+ PluginsCapability,
893
+ ProjectContextCapability,
894
+ RunContextCapability,
895
+ SettingSourcesCapability,
896
+ SkillsCapability,
897
+ SkillsOptionsCapability,
898
+ SkillsResolverCapability,
899
+ SubAgentsCapability,
793
900
  ToolboxCapability,
794
901
  ToolsCapability,
795
902
  UnknownCapabilityError,
796
- agent,
797
903
  agentsPlugin,
798
904
  applyCapabilities,
799
905
  buildAgentCard,
800
906
  buildMcpToolDescriptors,
801
907
  buildModelSelection,
802
- checkpoint,
803
908
  compactionStrategyConfigSchema,
804
909
  compileAgentDefinition,
805
910
  compileAgentModule,
@@ -807,8 +912,6 @@ export {
807
912
  compileProjectContext,
808
913
  compileSkills,
809
914
  compileTools,
810
- contextWindow,
811
- contextualTool,
812
915
  costGuard,
813
916
  createA2ATool,
814
917
  createAgentExecutionContext,
@@ -826,8 +929,6 @@ export {
826
929
  extractThinkTagStream,
827
930
  generateAgentManifest,
828
931
  generateAgentRoutes,
829
- guardrails,
830
- humanInTheLoop,
831
932
  isAgentContext,
832
933
  isAgentDefinition,
833
934
  isApprovalRequired,
@@ -841,17 +942,13 @@ export {
841
942
  loopStrategyConfigSchema,
842
943
  mcpRegistry,
843
944
  mcpServerInfo,
844
- mcpServers,
845
945
  mcpToolApprovals,
846
- memory,
847
946
  moderateOutputStream,
848
947
  noopReflectionStrategy,
849
948
  outputModeration,
850
949
  parseConversationId,
851
950
  piiDetector,
852
- plugins,
853
951
  presentUIMessageStream,
854
- projectContext,
855
952
  projectContextMetadataOnlyKnobs,
856
953
  promptInjectionDetector,
857
954
  reflectionStrategyConfigSchema,
@@ -859,18 +956,12 @@ export {
859
956
  resolveEnabledSkills,
860
957
  resolveLoopStrategy,
861
958
  resolveMcpServers,
862
- runContext,
863
959
  runInputGuards,
864
960
  runOutputGuards,
865
961
  runWithApiErrorHandling,
866
962
  setOnce,
867
- settingSources,
868
- skills,
869
- skillsOptions,
870
- skillsResolver,
871
963
  streamAgentResponse,
872
964
  streamAgentUIMessages,
873
- subAgents,
874
965
  toAgentFactory,
875
966
  tokenBudgetCompactionStrategy,
876
967
  translateSdkEvent,