@theokit/agents 2.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/{bridge-entry-F9kHGaIn.d.ts → bridge-entry-Ddu3Ug_3.d.ts} +44 -22
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +5 -5
- package/dist/{chunk-K3VX4S65.js → chunk-OKG5LRGV.js} +87 -22
- package/dist/chunk-OKG5LRGV.js.map +1 -0
- package/dist/index.d.ts +133 -20
- package/dist/index.js +210 -119
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-K3VX4S65.js.map +0 -1
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,
|
|
2
|
-
export {
|
|
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';
|
|
@@ -294,6 +293,13 @@ interface AgentRunnerState {
|
|
|
294
293
|
readonly agentName: string;
|
|
295
294
|
/** The resolved terminal-decision strategy (parity with `delegate()`). */
|
|
296
295
|
readonly loopStrategy: LoopStrategy;
|
|
296
|
+
/**
|
|
297
|
+
* M54 — true when `loopStrategy` came from `.loopStrategy(custom)` rather than a built-in name.
|
|
298
|
+
* A custom must NOT be re-resolved by name (its name is outside the `z.enum`); a per-run
|
|
299
|
+
* `maxIterations` override applies to it as a runner ceiling instead (see `stream`). Optional and
|
|
300
|
+
* defaults to `false`: a state built directly (tests, `delegate()`) is a by-name built-in.
|
|
301
|
+
*/
|
|
302
|
+
readonly loopStrategyIsCustom?: boolean;
|
|
297
303
|
/** The resolved between-round reflection (default or `.reflection(custom)` override). */
|
|
298
304
|
readonly reflectionStrategy: ReflectionStrategy;
|
|
299
305
|
/** Recorded streaming preference (see {@link AgentRunner.streamEnabled}). */
|
|
@@ -306,6 +312,8 @@ declare class AgentRunner {
|
|
|
306
312
|
private readonly agentName;
|
|
307
313
|
/** The resolved terminal-decision strategy (parity with `delegate()`). */
|
|
308
314
|
readonly loopStrategy: LoopStrategy;
|
|
315
|
+
/** M54 — whether {@link loopStrategy} is a caller-injected custom (see {@link AgentRunnerState}). */
|
|
316
|
+
private readonly loopStrategyIsCustom;
|
|
309
317
|
/** The resolved between-round reflection (default or `.reflection(custom)` override). */
|
|
310
318
|
readonly reflectionStrategy: ReflectionStrategy;
|
|
311
319
|
/**
|
|
@@ -336,6 +344,14 @@ declare class AgentRunner {
|
|
|
336
344
|
/** The core stream path, after input guardrails have run (M9). */
|
|
337
345
|
private streamUnguarded;
|
|
338
346
|
/** Run the agent to a terminal result via the shared reflective loop (collect mode). */
|
|
347
|
+
/**
|
|
348
|
+
* Apply a per-call `maxIterations` override (M54 D4). A custom strategy must NOT be re-resolved by
|
|
349
|
+
* name — its name is outside the `z.enum`, which would throw — and its `shouldContinue` closure
|
|
350
|
+
* must survive; since the runner enforces the ceiling via `round < loop.maxIterations` (T1.1),
|
|
351
|
+
* overriding just that field bounds a custom without touching its logic. A built-in keeps the
|
|
352
|
+
* by-name re-resolution (zod fail-loud on `< 1`) — unchanged, zero-behavior.
|
|
353
|
+
*/
|
|
354
|
+
private resolvePerRunLoop;
|
|
339
355
|
run(message: string, opts: AgentRunnerRunOptions): Promise<DelegationResult>;
|
|
340
356
|
}
|
|
341
357
|
/**
|
|
@@ -364,9 +380,29 @@ declare class AgentRunnerBuilder {
|
|
|
364
380
|
private reflectionOverride?;
|
|
365
381
|
private streamEnabled;
|
|
366
382
|
private compactionOverride?;
|
|
383
|
+
private loopStrategyOverride?;
|
|
367
384
|
constructor(spec: AgentRunnerSpec);
|
|
368
385
|
/** Override the default reflection strategy (OCP — plan Drawback #2). No arg ⇒ keep default. */
|
|
369
386
|
reflection(strategy?: ReflectionStrategy): this;
|
|
387
|
+
/**
|
|
388
|
+
* M54 — inject a custom terminal-decision strategy (the fourth OCP axis, alongside
|
|
389
|
+
* `.reflection()`/`.compaction()`/`streamFactory`). WINS over the strategy the spec's name would
|
|
390
|
+
* resolve to, exactly as `.compaction()` outranks the spec. The runner caps ANY strategy at
|
|
391
|
+
* `custom.maxIterations` (T1.1), so a `shouldContinue: () => true` still terminates — never an
|
|
392
|
+
* infinite loop.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```ts
|
|
396
|
+
* // Stop as soon as the confidence in the last round crosses 0.9, else run to the ceiling.
|
|
397
|
+
* const stopWhenConfident: LoopStrategy = {
|
|
398
|
+
* name: 'confident',
|
|
399
|
+
* maxIterations: 8,
|
|
400
|
+
* shouldContinue: (o) => !o.responseText.includes('confidence: high'),
|
|
401
|
+
* }
|
|
402
|
+
* AgentRunner.fromSpec(spec).loopStrategy(stopWhenConfident).build()
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
loopStrategy(custom: LoopStrategy): this;
|
|
370
406
|
/** Record the streaming preference (see {@link AgentRunner.streamEnabled}). */
|
|
371
407
|
stream(enabled?: boolean): this;
|
|
372
408
|
/**
|
|
@@ -461,10 +497,16 @@ declare class ToolsCapability implements Capability {
|
|
|
461
497
|
apply(draft: CompiledAgentOptionsDraft): void;
|
|
462
498
|
}
|
|
463
499
|
/**
|
|
464
|
-
* Enables skills by name
|
|
465
|
-
*
|
|
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.
|
|
466
503
|
*/
|
|
467
|
-
declare
|
|
504
|
+
declare class SkillsCapability implements Capability {
|
|
505
|
+
#private;
|
|
506
|
+
readonly name = "skills";
|
|
507
|
+
constructor(entries: readonly (string | InlineSkill)[]);
|
|
508
|
+
apply(draft: CompiledAgentOptionsDraft): void;
|
|
509
|
+
}
|
|
468
510
|
|
|
469
511
|
/**
|
|
470
512
|
* M52 — resolution + composition. The registry is what unlocks FILE-BASED authoring (a config lists
|
|
@@ -494,51 +536,122 @@ declare class CapabilityPreset implements Capability {
|
|
|
494
536
|
apply(draft: CompiledAgentOptionsDraft): void;
|
|
495
537
|
}
|
|
496
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
|
+
}
|
|
497
563
|
/** `@Memory` → `memory`. */
|
|
498
|
-
declare
|
|
564
|
+
declare class MemoryCapability extends FieldCapability<'memory'> {
|
|
565
|
+
readonly name = "memory";
|
|
566
|
+
protected readonly field: "memory";
|
|
567
|
+
}
|
|
499
568
|
/**
|
|
500
569
|
* `@ContextWindow` → `context`. DELEGATES to `compileContextWindow`, which is the canonical
|
|
501
570
|
* `ContextWindowOptions → ContextSettings` conversion (it also reports the metadata-only knobs).
|
|
502
571
|
* Taking a pre-converted value here would duplicate that knowledge — the exact divergence the M52
|
|
503
572
|
* zero-behavior proof caught in `skills`.
|
|
504
573
|
*/
|
|
505
|
-
declare
|
|
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
|
+
}
|
|
506
580
|
/** `@ProjectContext` → `projectContext`. */
|
|
507
|
-
declare
|
|
581
|
+
declare class ProjectContextCapability extends FieldCapability<'projectContext'> {
|
|
582
|
+
readonly name = "project-context";
|
|
583
|
+
protected readonly field: "projectContext";
|
|
584
|
+
}
|
|
508
585
|
/** `@MCP` → `mcpServers`. */
|
|
509
|
-
declare
|
|
586
|
+
declare class McpServersCapability extends FieldCapability<'mcpServers'> {
|
|
587
|
+
readonly name = "mcp";
|
|
588
|
+
protected readonly field: "mcpServers";
|
|
589
|
+
}
|
|
510
590
|
/** `@Guardrails` → `guardrails`. */
|
|
511
|
-
declare
|
|
591
|
+
declare class GuardrailsCapability extends FieldCapability<'guardrails'> {
|
|
592
|
+
readonly name = "guardrails";
|
|
593
|
+
protected readonly field: "guardrails";
|
|
594
|
+
}
|
|
512
595
|
/**
|
|
513
596
|
* `@Checkpoint` → `checkpoint`. Carries the non-durable WARNING the metadata walk used to emit: only
|
|
514
597
|
* `'filesystem'` selects the SDK's durable store, so any other storage cannot resume across
|
|
515
598
|
* requests. The warning moves WITH the feature — a declared checkpoint that silently cannot resume
|
|
516
599
|
* is exactly the kind of no-op this project refuses to ship.
|
|
517
600
|
*/
|
|
518
|
-
declare
|
|
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
|
+
}
|
|
519
607
|
/**
|
|
520
608
|
* `@HumanInTheLoop` → `hitl`, keyed `"<namespace>_<tool>"` — the same key `compileHitlGates` mints
|
|
521
609
|
* via `toolRuntimeName`. The separator is `_`, not `.`: the dot is outside the charset the SDK
|
|
522
610
|
* accepts, and a gate keyed with a dot silently failed to match its tool (theokit#145).
|
|
523
611
|
*/
|
|
524
|
-
declare
|
|
612
|
+
declare class HumanInTheLoopCapability extends FieldCapability<'hitl'> {
|
|
613
|
+
readonly name = "human-in-the-loop";
|
|
614
|
+
protected readonly field: "hitl";
|
|
615
|
+
}
|
|
525
616
|
/**
|
|
526
617
|
* `@SubAgents` → `agents`. MERGES instead of `setOnce`: `agents` is a pre-seeded collection on the
|
|
527
618
|
* draft (`createDraft` gives it `{}`), so a `setOnce` would conflict against the seed itself — the
|
|
528
619
|
* same trap the pre-seeded `stream` sprang in M52. Merging also lets a preset declare a baseline
|
|
529
620
|
* child set that a call site extends.
|
|
530
621
|
*/
|
|
531
|
-
declare
|
|
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
|
+
}
|
|
532
628
|
/**
|
|
533
629
|
* `@Skills({ include, autoDiscover })` → `skills`. Delegates to `compileSkills` (same reason as
|
|
534
630
|
* `contextWindow`). Distinct from the M52 `skills([...])`, which takes the plain name/inline list.
|
|
535
631
|
*/
|
|
536
|
-
declare
|
|
632
|
+
declare class SkillsOptionsCapability implements Capability {
|
|
633
|
+
private readonly options;
|
|
634
|
+
readonly name = "skills";
|
|
635
|
+
constructor(options: SkillsOptions);
|
|
636
|
+
apply(draft: CompiledAgentOptionsDraft): void;
|
|
637
|
+
}
|
|
537
638
|
/** Functional-path fields that had no decorator source — closing the gap list, not adding surface. */
|
|
538
|
-
declare
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
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
|
+
}
|
|
542
655
|
/** The scalar agent config (name/route are HTTP concerns, never agent config). */
|
|
543
656
|
interface AgentConfig {
|
|
544
657
|
readonly systemPrompt?: CompiledAgentOptions['systemPrompt'];
|
|
@@ -835,4 +948,4 @@ declare class AcpClient {
|
|
|
835
948
|
private handleServerRequest;
|
|
836
949
|
}
|
|
837
950
|
|
|
838
|
-
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,
|
|
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 };
|