@theokit/agents 0.47.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/{bridge-entry-BQ6UUSLZ.d.ts → bridge-entry-F9kHGaIn.d.ts} +378 -106
- package/dist/bridge.d.ts +1 -2
- package/dist/bridge.js +3 -12
- package/dist/{chunk-FEH7JFH7.js → chunk-7KRJJX7W.js} +139 -358
- package/dist/chunk-7KRJJX7W.js.map +1 -0
- package/dist/index.d.ts +173 -15
- package/dist/index.js +225 -15
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
- package/dist/chunk-FEH7JFH7.js.map +0 -1
- package/dist/chunk-NERDIS45.js +0 -329
- package/dist/chunk-NERDIS45.js.map +0 -1
- package/dist/decorators.d.ts +0 -176
- package/dist/decorators.js +0 -308
- package/dist/decorators.js.map +0 -1
- package/dist/types-DVA4LQsA.d.ts +0 -313
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { G as Guardrail, R as ReasoningEffort } from './
|
|
2
|
-
export {
|
|
3
|
-
import
|
|
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';
|
|
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';
|
|
5
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';
|
|
@@ -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.
|
|
174
|
-
*
|
|
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
|
|
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.
|
|
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
|
|
329
|
-
static
|
|
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
|
|
363
|
+
private readonly spec;
|
|
346
364
|
private reflectionOverride?;
|
|
347
365
|
private streamEnabled;
|
|
348
366
|
private compactionOverride?;
|
|
349
|
-
constructor(
|
|
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,7 +377,7 @@ declare class AgentRunnerBuilder {
|
|
|
359
377
|
compaction(name: string, options?: {
|
|
360
378
|
keepTokens?: number;
|
|
361
379
|
}): this;
|
|
362
|
-
/**
|
|
380
|
+
/** Resolve strategies from the spec — the compile→execute boundary (no I/O). */
|
|
363
381
|
build(): AgentRunner;
|
|
364
382
|
}
|
|
365
383
|
|
|
@@ -467,6 +485,146 @@ declare class CapabilityPreset implements Capability {
|
|
|
467
485
|
apply(draft: CompiledAgentOptionsDraft): void;
|
|
468
486
|
}
|
|
469
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
|
+
|
|
470
628
|
/**
|
|
471
629
|
* M15 (theokit-ai-first) — A2A agent card generation (ADR-0040 § D2, home/discovery concern).
|
|
472
630
|
*
|
|
@@ -658,4 +816,4 @@ declare class AcpClient {
|
|
|
658
816
|
private handleServerRequest;
|
|
659
817
|
}
|
|
660
818
|
|
|
661
|
-
export { type A2AAuth, type A2ACapabilities, type A2ASkill, type A2AToolConfig, AcpClient, AcpMessageDecoder, type AcpTransport, type AgentCard, AgentManifestEntry, AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, 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, LoopStrategy, MCP_PROTOCOL_VERSION, type McpJsonSchema, type McpServerInfo, type McpToolDescriptor, ModelCapability, type OutputModerationOptions, type PiiOptions, type PromptInjectionOptions, type ProvenanceEntry, ReasoningEffort, ReflectionStrategy, RoundStreamFactory, StreamEvent, type Summarize, ToolsCapability, type TranscriptCompactionStrategy, UnknownCapabilityError, applyCapabilities, buildAgentCard, buildMcpToolDescriptors, compactionStrategyConfigSchema, costGuard, createA2ATool, createDraft, deriveConversationId, encodeAcpMessage, estimateTokens, mcpServerInfo, moderateOutputStream, outputModeration, parseConversationId, piiDetector, promptInjectionDetector, resolveCompactionStrategy, runInputGuards, runOutputGuards, setOnce, skills, 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 };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
AgentDefinitionError,
|
|
4
4
|
AgentRunner,
|
|
5
5
|
AgentRunnerBuilder,
|
|
6
|
-
AgentWarningCode,
|
|
7
6
|
BudgetExceededError,
|
|
8
7
|
CostBudgetExceededError,
|
|
9
8
|
DEFAULT_KEEP_TOKENS,
|
|
@@ -14,7 +13,6 @@ import {
|
|
|
14
13
|
agentsPlugin,
|
|
15
14
|
buildModelSelection,
|
|
16
15
|
compactionStrategyConfigSchema,
|
|
17
|
-
compileAgent,
|
|
18
16
|
compileAgentDefinition,
|
|
19
17
|
compileAgentModule,
|
|
20
18
|
compileContextWindow,
|
|
@@ -68,11 +66,8 @@ import {
|
|
|
68
66
|
toAgentFactory,
|
|
69
67
|
tokenBudgetCompactionStrategy,
|
|
70
68
|
translateSdkEvent,
|
|
71
|
-
unicodeNormalizer
|
|
72
|
-
|
|
73
|
-
walkAgentMetadata
|
|
74
|
-
} from "./chunk-FEH7JFH7.js";
|
|
75
|
-
import "./chunk-NERDIS45.js";
|
|
69
|
+
unicodeNormalizer
|
|
70
|
+
} from "./chunk-7KRJJX7W.js";
|
|
76
71
|
import {
|
|
77
72
|
__name
|
|
78
73
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -213,9 +208,7 @@ var skills = /* @__PURE__ */ __name((entries) => {
|
|
|
213
208
|
return {
|
|
214
209
|
name: "skills",
|
|
215
210
|
apply: /* @__PURE__ */ __name((draft) => {
|
|
216
|
-
const compiled = compileSkillsSelection(
|
|
217
|
-
...entries
|
|
218
|
-
]);
|
|
211
|
+
const compiled = compileSkillsSelection(entries.slice());
|
|
219
212
|
if (compiled.skills === void 0) return;
|
|
220
213
|
const previous = draft.skills;
|
|
221
214
|
draft.skills = previous === void 0 ? compiled.skills : {
|
|
@@ -296,6 +289,207 @@ var CapabilityPreset = class {
|
|
|
296
289
|
}
|
|
297
290
|
};
|
|
298
291
|
|
|
292
|
+
// src/capability/agent-capabilities.ts
|
|
293
|
+
function fieldCapability(name, field) {
|
|
294
|
+
return (value) => ({
|
|
295
|
+
name,
|
|
296
|
+
apply: /* @__PURE__ */ __name((draft) => {
|
|
297
|
+
setOnce(draft, field, value, name);
|
|
298
|
+
}, "apply")
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
__name(fieldCapability, "fieldCapability");
|
|
302
|
+
var memory = fieldCapability("memory", "memory");
|
|
303
|
+
var contextWindow = /* @__PURE__ */ __name((options) => ({
|
|
304
|
+
name: "context-window",
|
|
305
|
+
apply: /* @__PURE__ */ __name((draft) => {
|
|
306
|
+
setOnce(draft, "context", compileContextWindow(options).context, "context-window");
|
|
307
|
+
}, "apply")
|
|
308
|
+
}), "contextWindow");
|
|
309
|
+
var projectContext = fieldCapability("project-context", "projectContext");
|
|
310
|
+
var mcpServers = fieldCapability("mcp", "mcpServers");
|
|
311
|
+
var guardrails = fieldCapability("guardrails", "guardrails");
|
|
312
|
+
var checkpoint = /* @__PURE__ */ __name((options) => ({
|
|
313
|
+
name: "checkpoint",
|
|
314
|
+
apply: /* @__PURE__ */ __name((draft) => {
|
|
315
|
+
if (options !== void 0 && options.storage !== "filesystem") {
|
|
316
|
+
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.`);
|
|
317
|
+
}
|
|
318
|
+
setOnce(draft, "checkpoint", options, "checkpoint");
|
|
319
|
+
}, "apply")
|
|
320
|
+
}), "checkpoint");
|
|
321
|
+
var humanInTheLoop = fieldCapability("human-in-the-loop", "hitl");
|
|
322
|
+
var subAgents = /* @__PURE__ */ __name((children) => ({
|
|
323
|
+
name: "sub-agents",
|
|
324
|
+
apply: /* @__PURE__ */ __name((draft) => {
|
|
325
|
+
for (const [name, child] of Object.entries(children)) {
|
|
326
|
+
if (name in draft.agents && draft.agents[name] !== child) {
|
|
327
|
+
throw new ConfigurationError(`sub-agents: filho "${name}" declarado duas vezes com defini\xE7\xF5es diferentes`);
|
|
328
|
+
}
|
|
329
|
+
draft.agents[name] = child;
|
|
330
|
+
}
|
|
331
|
+
draft.provenance.push({
|
|
332
|
+
capability: "sub-agents",
|
|
333
|
+
contributed: [
|
|
334
|
+
"agents"
|
|
335
|
+
]
|
|
336
|
+
});
|
|
337
|
+
}, "apply")
|
|
338
|
+
}), "subAgents");
|
|
339
|
+
var skillsOptions = /* @__PURE__ */ __name((options) => ({
|
|
340
|
+
name: "skills",
|
|
341
|
+
apply: /* @__PURE__ */ __name((draft) => {
|
|
342
|
+
setOnce(draft, "skills", compileSkills(options), "skills");
|
|
343
|
+
}, "apply")
|
|
344
|
+
}), "skillsOptions");
|
|
345
|
+
var settingSources = fieldCapability("setting-sources", "settingSources");
|
|
346
|
+
var plugins = fieldCapability("plugins", "plugins");
|
|
347
|
+
var runContext = fieldCapability("run-context", "runContext");
|
|
348
|
+
var skillsResolver = fieldCapability("skills-resolver", "skillsResolver");
|
|
349
|
+
var AgentConfigCapability = class {
|
|
350
|
+
static {
|
|
351
|
+
__name(this, "AgentConfigCapability");
|
|
352
|
+
}
|
|
353
|
+
config;
|
|
354
|
+
name = "agent-config";
|
|
355
|
+
constructor(config) {
|
|
356
|
+
this.config = config;
|
|
357
|
+
if (typeof config !== "object" || config === null) {
|
|
358
|
+
throw new ConfigurationError("agent-config: esperava um objeto de configura\xE7\xE3o");
|
|
359
|
+
}
|
|
360
|
+
for (const field of [
|
|
361
|
+
"maxIterations",
|
|
362
|
+
"timeoutMs"
|
|
363
|
+
]) {
|
|
364
|
+
const value = config[field];
|
|
365
|
+
if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) {
|
|
366
|
+
throw new ConfigurationError(`agent-config: \`${field}\` deve ser um n\xFAmero positivo`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
apply(draft) {
|
|
371
|
+
const claimedByMainLoop = /* @__PURE__ */ __name((field) => draft.provenance.some((p) => p.capability === "main-loop" && p.contributed.includes(field)), "claimedByMainLoop");
|
|
372
|
+
if (!claimedByMainLoop("maxIterations")) {
|
|
373
|
+
setOnce(draft, "maxIterations", this.config.maxIterations, this.name);
|
|
374
|
+
}
|
|
375
|
+
if (!claimedByMainLoop("timeoutMs")) {
|
|
376
|
+
setOnce(draft, "timeoutMs", this.config.timeoutMs, this.name);
|
|
377
|
+
}
|
|
378
|
+
setOnce(draft, "systemPrompt", this.config.systemPrompt, this.name);
|
|
379
|
+
setOnce(draft, "parseThinkTags", this.config.parseThinkTags, this.name);
|
|
380
|
+
setOnce(draft, "stripToolDialect", this.config.stripToolDialect, this.name);
|
|
381
|
+
setOnce(draft, "recoverLeakedToolCalls", this.config.recoverLeakedToolCalls, this.name);
|
|
382
|
+
setOnce(draft, "stream", this.config.stream, this.name);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var MainLoopCapability = class {
|
|
386
|
+
static {
|
|
387
|
+
__name(this, "MainLoopCapability");
|
|
388
|
+
}
|
|
389
|
+
config;
|
|
390
|
+
name = "main-loop";
|
|
391
|
+
constructor(config) {
|
|
392
|
+
this.config = config;
|
|
393
|
+
}
|
|
394
|
+
apply(draft) {
|
|
395
|
+
const contributed = [];
|
|
396
|
+
if (this.config.maxIterations !== void 0) {
|
|
397
|
+
draft.maxIterations = this.config.maxIterations;
|
|
398
|
+
contributed.push("maxIterations");
|
|
399
|
+
}
|
|
400
|
+
if (this.config.timeoutMs !== void 0) {
|
|
401
|
+
draft.timeoutMs = this.config.timeoutMs;
|
|
402
|
+
contributed.push("timeoutMs");
|
|
403
|
+
}
|
|
404
|
+
if (contributed.length > 0) draft.provenance.push({
|
|
405
|
+
capability: this.name,
|
|
406
|
+
contributed
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// src/capability/toolbox.ts
|
|
412
|
+
var ToolboxCapability = class {
|
|
413
|
+
static {
|
|
414
|
+
__name(this, "ToolboxCapability");
|
|
415
|
+
}
|
|
416
|
+
name = "toolbox";
|
|
417
|
+
#instance;
|
|
418
|
+
#declarations;
|
|
419
|
+
#namespace;
|
|
420
|
+
constructor(instance, options = {}) {
|
|
421
|
+
if (typeof instance !== "object" || instance === null) {
|
|
422
|
+
throw new ConfigurationError("toolbox: esperava uma inst\xE2ncia de toolbox");
|
|
423
|
+
}
|
|
424
|
+
const declared = options.tools ?? instance.constructor.tools;
|
|
425
|
+
if (declared === void 0 || declared.length === 0) {
|
|
426
|
+
throw new ConfigurationError(`toolbox: ${instance.constructor.name} n\xE3o declara tools \u2014 use \`static tools = [...]\` ou a op\xE7\xE3o \`tools\``);
|
|
427
|
+
}
|
|
428
|
+
for (const tool of declared) {
|
|
429
|
+
if (typeof instance[tool.method] !== "function") {
|
|
430
|
+
throw new ConfigurationError(`toolbox: ${instance.constructor.name}.${tool.method} n\xE3o \xE9 um m\xE9todo (tool "${tool.name}")`);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
this.#instance = instance;
|
|
434
|
+
this.#declarations = declared;
|
|
435
|
+
this.#namespace = options.namespace ?? "";
|
|
436
|
+
}
|
|
437
|
+
/** The compiled tools this toolbox contributes — the same shape the decorator path produces. */
|
|
438
|
+
compile() {
|
|
439
|
+
const token = this.#instance.constructor;
|
|
440
|
+
const walk = {
|
|
441
|
+
class: token,
|
|
442
|
+
namespace: this.#namespace,
|
|
443
|
+
guards: [],
|
|
444
|
+
tools: this.#declarations.map((tool) => ({
|
|
445
|
+
propertyKey: tool.method,
|
|
446
|
+
config: tool,
|
|
447
|
+
guards: [],
|
|
448
|
+
approval: tool.approval,
|
|
449
|
+
trace: tool.trace ?? false,
|
|
450
|
+
audit: tool.audit ?? false,
|
|
451
|
+
...tool.hitl !== void 0 ? {
|
|
452
|
+
hitl: tool.hitl
|
|
453
|
+
} : {}
|
|
454
|
+
}))
|
|
455
|
+
};
|
|
456
|
+
return compileTools([
|
|
457
|
+
walk
|
|
458
|
+
], /* @__PURE__ */ new Map([
|
|
459
|
+
[
|
|
460
|
+
token,
|
|
461
|
+
this.#instance
|
|
462
|
+
]
|
|
463
|
+
]));
|
|
464
|
+
}
|
|
465
|
+
apply(draft) {
|
|
466
|
+
draft.tools.push(...this.compile());
|
|
467
|
+
draft.provenance.push({
|
|
468
|
+
capability: this.name,
|
|
469
|
+
contributed: [
|
|
470
|
+
"tools"
|
|
471
|
+
]
|
|
472
|
+
});
|
|
473
|
+
const gates = [];
|
|
474
|
+
for (const tool of this.#declarations) {
|
|
475
|
+
if (tool.hitl === void 0) continue;
|
|
476
|
+
gates.push([
|
|
477
|
+
this.#namespace === "" ? tool.name : `${this.#namespace}.${tool.name}`,
|
|
478
|
+
tool.hitl
|
|
479
|
+
]);
|
|
480
|
+
}
|
|
481
|
+
if (gates.length === 0) return;
|
|
482
|
+
draft.hitl ??= /* @__PURE__ */ new Map();
|
|
483
|
+
for (const [key, options] of gates) draft.hitl.set(key, options);
|
|
484
|
+
draft.provenance.push({
|
|
485
|
+
capability: this.name,
|
|
486
|
+
contributed: [
|
|
487
|
+
"hitl"
|
|
488
|
+
]
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
299
493
|
// src/a2a/agent-card.ts
|
|
300
494
|
function trimTrailingSlash(url) {
|
|
301
495
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
@@ -432,8 +626,12 @@ async function resolveEnabledSkills(selection, ctx) {
|
|
|
432
626
|
if (!Array.isArray(resolved)) {
|
|
433
627
|
throw new Error("[@theokit/agents] skills resolver must return an array of skill names");
|
|
434
628
|
}
|
|
629
|
+
const names = resolved;
|
|
630
|
+
if (!names.every((n) => typeof n === "string" && n.trim().length > 0)) {
|
|
631
|
+
throw new Error("[@theokit/agents] skills resolver must return non-empty skill NAME strings");
|
|
632
|
+
}
|
|
435
633
|
return [
|
|
436
|
-
...
|
|
634
|
+
...names
|
|
437
635
|
];
|
|
438
636
|
}
|
|
439
637
|
__name(resolveEnabledSkills, "resolveEnabledSkills");
|
|
@@ -567,10 +765,10 @@ export {
|
|
|
567
765
|
AGENT_BRAND,
|
|
568
766
|
AcpClient,
|
|
569
767
|
AcpMessageDecoder,
|
|
768
|
+
AgentConfigCapability,
|
|
570
769
|
AgentDefinitionError,
|
|
571
770
|
AgentRunner,
|
|
572
771
|
AgentRunnerBuilder,
|
|
573
|
-
AgentWarningCode,
|
|
574
772
|
BudgetExceededError,
|
|
575
773
|
CapabilityConflictError,
|
|
576
774
|
CapabilityPreset,
|
|
@@ -582,7 +780,9 @@ export {
|
|
|
582
780
|
DelegationError,
|
|
583
781
|
GuardrailViolationError,
|
|
584
782
|
MCP_PROTOCOL_VERSION,
|
|
783
|
+
MainLoopCapability,
|
|
585
784
|
ModelCapability,
|
|
785
|
+
ToolboxCapability,
|
|
586
786
|
ToolsCapability,
|
|
587
787
|
UnknownCapabilityError,
|
|
588
788
|
agent,
|
|
@@ -591,14 +791,15 @@ export {
|
|
|
591
791
|
buildAgentCard,
|
|
592
792
|
buildMcpToolDescriptors,
|
|
593
793
|
buildModelSelection,
|
|
794
|
+
checkpoint,
|
|
594
795
|
compactionStrategyConfigSchema,
|
|
595
|
-
compileAgent,
|
|
596
796
|
compileAgentDefinition,
|
|
597
797
|
compileAgentModule,
|
|
598
798
|
compileContextWindow,
|
|
599
799
|
compileProjectContext,
|
|
600
800
|
compileSkills,
|
|
601
801
|
compileTools,
|
|
802
|
+
contextWindow,
|
|
602
803
|
contextualTool,
|
|
603
804
|
costGuard,
|
|
604
805
|
createA2ATool,
|
|
@@ -617,6 +818,8 @@ export {
|
|
|
617
818
|
extractThinkTagStream,
|
|
618
819
|
generateAgentManifest,
|
|
619
820
|
generateAgentRoutes,
|
|
821
|
+
guardrails,
|
|
822
|
+
humanInTheLoop,
|
|
620
823
|
isAgentContext,
|
|
621
824
|
isAgentDefinition,
|
|
622
825
|
isApprovalRequired,
|
|
@@ -630,13 +833,17 @@ export {
|
|
|
630
833
|
loopStrategyConfigSchema,
|
|
631
834
|
mcpRegistry,
|
|
632
835
|
mcpServerInfo,
|
|
836
|
+
mcpServers,
|
|
633
837
|
mcpToolApprovals,
|
|
838
|
+
memory,
|
|
634
839
|
moderateOutputStream,
|
|
635
840
|
noopReflectionStrategy,
|
|
636
841
|
outputModeration,
|
|
637
842
|
parseConversationId,
|
|
638
843
|
piiDetector,
|
|
844
|
+
plugins,
|
|
639
845
|
presentUIMessageStream,
|
|
846
|
+
projectContext,
|
|
640
847
|
projectContextMetadataOnlyKnobs,
|
|
641
848
|
promptInjectionDetector,
|
|
642
849
|
reflectionStrategyConfigSchema,
|
|
@@ -644,19 +851,22 @@ export {
|
|
|
644
851
|
resolveEnabledSkills,
|
|
645
852
|
resolveLoopStrategy,
|
|
646
853
|
resolveMcpServers,
|
|
854
|
+
runContext,
|
|
647
855
|
runInputGuards,
|
|
648
856
|
runOutputGuards,
|
|
649
857
|
runWithApiErrorHandling,
|
|
650
858
|
setOnce,
|
|
859
|
+
settingSources,
|
|
651
860
|
skills,
|
|
861
|
+
skillsOptions,
|
|
862
|
+
skillsResolver,
|
|
652
863
|
streamAgentResponse,
|
|
653
864
|
streamAgentUIMessages,
|
|
865
|
+
subAgents,
|
|
654
866
|
toAgentFactory,
|
|
655
867
|
tokenBudgetCompactionStrategy,
|
|
656
868
|
translateSdkEvent,
|
|
657
869
|
unicodeNormalizer,
|
|
658
|
-
validateUniqueRoutes,
|
|
659
|
-
walkAgentMetadata,
|
|
660
870
|
wellKnownCardPath
|
|
661
871
|
};
|
|
662
872
|
//# sourceMappingURL=index.js.map
|