@theokit/agents 0.31.0 → 0.33.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.
@@ -1,5 +1,5 @@
1
1
  import { ExecutionContext } from '@theokit/http';
2
- import { A as AgentOptions, D as ToolOptions, m as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, l as HumanInTheLoopOptions, k as GatewayOptions, r as MemoryOptions, z as SkillsOptions, j as ContextWindowOptions, w as ProjectContextOptions, p as McpServersMap, g as CompactionDecoratorConfig, b as CheckpointOptions, R as ReasoningEffort } from './skills-Dx_KJ6Eg.js';
2
+ import { A as AgentOptions, N as ToolOptions, s as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, r as HumanInTheLoopOptions, m as GatewayOptions, x as MemoryOptions, L as SkillsOptions, j as ContextWindowOptions, F as ProjectContextOptions, v as McpServersMap, G as Guardrail, g as CompactionDecoratorConfig, b as CheckpointOptions, R as ReasoningEffort } from './types-S7k_lt1_.js';
3
3
  import { SystemPromptResolver, SkillsSettings, ContextSettings, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, ConversationStorageAdapter, CustomTool, ModelSelection } from '@theokit/sdk';
4
4
  import { UIMessageChunk } from 'ai';
5
5
  import { z } from 'zod';
@@ -66,6 +66,8 @@ interface AgentWalkResult {
66
66
  contextWindow?: ContextWindowOptions;
67
67
  projectContext?: ProjectContextOptions;
68
68
  mcpServers?: McpServersMap;
69
+ /** M9 — `@Guardrails([...])` input/output guards when the class declares them; absent ⇒ none. */
70
+ guardrails?: readonly Guardrail[];
69
71
  compaction?: CompactionDecoratorConfig;
70
72
  /** `@Checkpoint` config (M4) when the agent declares resumable execution; absent ⇒ no checkpoint. */
71
73
  checkpoint?: CheckpointOptions;
@@ -102,53 +104,6 @@ declare function walkAgentMetadata(AgentClass: Function, toolboxClasses?: Functi
102
104
  */
103
105
  declare function validateUniqueRoutes(results: AgentWalkResult[]): void;
104
106
 
105
- /**
106
- * M9 (theokit-ai-first) — guardrail contract + typed errors.
107
- *
108
- * ADR-0040 § D2: guardrails are a HOME/BOUNDARY concern (filter user input before the SDK,
109
- * filter model output before the client). They REUSE the SDK runtime — this module makes zero
110
- * LLM calls. A guard reports one of three actions; the pipeline (`pipeline.ts`) enforces them.
111
- */
112
- /** What a guard decided for a piece of text. */
113
- type GuardrailAction = 'allow' | 'block' | 'redact';
114
- /**
115
- * The result of a single guard check.
116
- * - `allow` — text passes untouched.
117
- * - `block` — the pipeline throws {@link GuardrailViolationError}; the run stops fail-fast.
118
- * - `redact` — the pipeline replaces the text with {@link GuardrailResult.text} and continues.
119
- */
120
- interface GuardrailResult {
121
- action: GuardrailAction;
122
- /** Human-readable reason — required in spirit for `block`, surfaced in the thrown error. */
123
- reason?: string;
124
- /** The transformed text — present (and used) only when `action === 'redact'`. */
125
- text?: string;
126
- }
127
- /**
128
- * A guardrail. A guard MAY inspect input (before the model), output (after the model), or both.
129
- * A guard that omits a phase hook is skipped for that phase.
130
- */
131
- interface Guardrail {
132
- readonly name: string;
133
- checkInput?(text: string): GuardrailResult | Promise<GuardrailResult>;
134
- checkOutput?(text: string): GuardrailResult | Promise<GuardrailResult>;
135
- }
136
- /** Which boundary phase a violation happened in. */
137
- type GuardrailPhase = 'input' | 'output';
138
- /** Thrown (fail-fast) when a guard returns `action: 'block'`. Typed per error-handling.md. */
139
- declare class GuardrailViolationError extends Error {
140
- readonly guardName: string;
141
- readonly phase: GuardrailPhase;
142
- readonly reason: string;
143
- constructor(guardName: string, phase: GuardrailPhase, reason: string);
144
- }
145
- /** Thrown when {@link costGuard}'s cumulative token budget is exceeded. */
146
- declare class CostBudgetExceededError extends Error {
147
- readonly usedTokens: number;
148
- readonly maxTokens: number;
149
- constructor(usedTokens: number, maxTokens: number);
150
- }
151
-
152
107
  /**
153
108
  * M13 (theokit-ai-first) — per-request skills resolution (ADR-0040 § D2, home/boundary concern).
154
109
  *
@@ -420,6 +375,8 @@ interface ApprovalRequiredEvent {
420
375
  input?: unknown;
421
376
  callbackUrl: string;
422
377
  timeoutMs: number;
378
+ /** M20 — JSON-schema descriptor of the custom payload the approver may attach (optional). */
379
+ payloadSchema?: Record<string, unknown>;
423
380
  }
424
381
  /** Agent encountered an error. */
425
382
  interface ErrorEvent {
@@ -914,14 +871,27 @@ declare function agent(): AgentBuilder;
914
871
  * surfaces as a tool result the model self-corrects on).
915
872
  */
916
873
 
874
+ /**
875
+ * M20 — a settled HITL decision. Structural mirror of the harness's `ApprovalDecision` (the agents
876
+ * package must not import from `theokit` — dependency direction). `awaitApproval` may resolve a bare
877
+ * boolean (legacy) OR this object; the plugin normalizes both.
878
+ */
879
+ interface HitlDecision {
880
+ approved: boolean;
881
+ reason?: string;
882
+ payload?: unknown;
883
+ }
917
884
  /** Injected wiring — the harness (mount-agent) supplies these; the plugin stays pure. */
918
885
  interface HitlWiring {
919
886
  /** Tool name → its `@HumanInTheLoop` config. A tool absent here is NOT gated. */
920
887
  gated: Map<string, HumanInTheLoopOptions>;
921
888
  /** Push the approval-required event into the agent stream (the translator emits the chunk). */
922
889
  emit: (event: ApprovalRequiredEvent) => void;
923
- /** Await the human decision for `approvalId`; resolves true=approve, false=deny (or timeout). */
924
- awaitApproval: (approvalId: string, opts: HumanInTheLoopOptions, toolName: string) => Promise<boolean>;
890
+ /**
891
+ * Await the human decision for `approvalId`; resolves approve/deny (or timeout). M20 — may resolve
892
+ * a bare boolean (legacy) OR a {@link HitlDecision} carrying an approver `reason` + `payload`.
893
+ */
894
+ awaitApproval: (approvalId: string, opts: HumanInTheLoopOptions, toolName: string) => Promise<boolean | HitlDecision>;
925
895
  }
926
896
 
927
897
  /**
@@ -1281,11 +1251,17 @@ declare function delegate(SubAgentClass: Function, message: string, opts?: Deleg
1281
1251
  /**
1282
1252
  * M10 (theokit-ai-first) — createToolHooksPlugin: `beforeToolCall` / `afterToolCall` observability.
1283
1253
  *
1284
- * ADR-0040 § D2: a HOME/BOUNDARY plugin over the SDK's OWN `pre_tool_call` / `post_tool_call`
1285
- * hooks (mirrors {@link createHitlPlugin}). It calls no LLM, dispatches no tool, runs no second
1286
- * loop — the SDK owns the run. `beforeToolCall` may VETO a call; `afterToolCall` observes the
1287
- * result. The processor pipeline's remaining lifecycle hooks (LLM request/response) live in the
1288
- * SDK; this ships the two tool-boundary hooks the framework can wire today.
1254
+ * ADR-0040 § D2: a HOME/BOUNDARY plugin over the SDK's OWN `pre_tool_call` / `post_tool_call` /
1255
+ * `pre_llm_call` / `post_llm_call` / `pre_user_send` hooks (mirrors {@link createHitlPlugin}). It
1256
+ * calls no LLM, dispatches no tool, runs no second loop — the SDK owns the run. `beforeToolCall`
1257
+ * may VETO a call; `afterToolCall` observes the result.
1258
+ *
1259
+ * M19 — `processInput` completes the input side of the processor pipeline, wired to the SDK
1260
+ * `pre_user_send` hook. NOTE (honest ceiling): the SDK does NOT let a plugin mutate the raw
1261
+ * prompt/stream; `pre_user_send` lets a handler INJECT derived context (`recalledContext`) BEFORE
1262
+ * the model. So `processInput` receives the prompt and returns an optional string, which the SDK
1263
+ * injects as a `<memory-context>` block ahead of the prompt. The api-error side of M19 lives in
1264
+ * `./api-error-handler` (a sibling factory — the SDK owns retry and exposes no error hook).
1289
1265
  */
1290
1266
  /** A tool call about to run (mirrored from the SDK `pre_tool_call` context — type-only). */
1291
1267
  interface BeforeToolCallContext {
@@ -1314,6 +1290,19 @@ interface ToolHooks {
1314
1290
  beforeLLMCall?: (ctx: LLMCallContext) => void | Promise<void>;
1315
1291
  /** M10 — observe every LLM turn AFTER it completes (SDK `post_llm_call`). Observability only. */
1316
1292
  afterLLMCall?: (ctx: LLMCallContext) => void | Promise<void>;
1293
+ /**
1294
+ * M19 — pre-process the user input BEFORE the model runs (SDK `pre_user_send`). Receives the
1295
+ * prompt; return a string to INJECT as derived context ahead of it (the SDK wraps it in a
1296
+ * `<memory-context>` block), or `undefined` to inject nothing. The SDK does not expose raw-prompt
1297
+ * mutation to plugins, so this is additive, not a rewrite of the caller's stream.
1298
+ */
1299
+ processInput?: (ctx: ProcessInputContext) => string | undefined | Promise<string | undefined>;
1300
+ }
1301
+ /** Context of the input seam (mirrors the SDK `PreUserSendContext`). */
1302
+ interface ProcessInputContext {
1303
+ prompt: string;
1304
+ agentId: string;
1305
+ runId: string;
1317
1306
  }
1318
1307
  /** Context of an LLM turn (mirrors the SDK `LlmCallContext` for `pre_llm_call`/`post_llm_call`). */
1319
1308
  interface LLMCallContext {
@@ -1333,12 +1322,22 @@ interface ToolHookRawContext {
1333
1322
  args?: Record<string, unknown>;
1334
1323
  result?: unknown;
1335
1324
  iteration?: number;
1325
+ /** M19 — the user prompt, present on the `pre_user_send` seam. */
1326
+ prompt?: string;
1336
1327
  }
1337
1328
  interface ToolHooksPluginContext {
1338
1329
  on(hook: string, handler: (ctx: ToolHookRawContext) => unknown): void;
1339
1330
  }
1340
1331
  interface ToolHooksPlugin {
1341
1332
  name: string;
1333
+ /** SDK `BasePlugin.version` — required by the `@theokit/sdk` Plugin contract. */
1334
+ version: string;
1335
+ /**
1336
+ * SDK Plugin discriminator. MUST be `'general'` — the SDK's `isCodePlugin()` gate filters out any
1337
+ * plugin object lacking `kind: 'general'` (a `register()`-only object is silently dropped and its
1338
+ * hooks NEVER fire). Regression guard for the M10/M19 latent E2E bug.
1339
+ */
1340
+ kind: 'general';
1342
1341
  register(ctx: ToolHooksPluginContext): void;
1343
1342
  }
1344
1343
  /**
@@ -1347,6 +1346,168 @@ interface ToolHooksPlugin {
1347
1346
  */
1348
1347
  declare function createToolHooksPlugin(hooks: ToolHooks): ToolHooksPlugin;
1349
1348
 
1349
+ /**
1350
+ * M19 (theokit-ai-first) — `processApiError`: app-level fallback around an agent run.
1351
+ *
1352
+ * ADR-0040 § D2 + sdk-runtime.md: the `@theokit/sdk` runtime OWNS the LLM call AND its own
1353
+ * retry/backoff, and exposes NO api-error hook to plugins. This module is therefore NOT a plugin —
1354
+ * it is a thin app-boundary wrapper (the M19 DoD explicitly allows "a sibling factory"). It
1355
+ * RE-INVOKES the caller's run thunk on error; it never calls an LLM, never dispatches a tool, never
1356
+ * reimplements retry inside the loop (G2). The SDK's internal retry runs first; this handles what
1357
+ * survives it — a second, app-owned fallback layer (the M19 top-risk note: "app-level fallback, not
1358
+ * a second retry loop" inside the SDK).
1359
+ */
1360
+ /** What the app decides after seeing an API error. */
1361
+ interface ApiErrorDecision<R = unknown> {
1362
+ /** Re-invoke the run thunk once more. Ignored past `maxAttempts`. */
1363
+ retry?: boolean;
1364
+ /**
1365
+ * A value to return INSTEAD of rethrowing, when `retry` is false/absent. Lets the app degrade
1366
+ * gracefully (e.g. a canned response) rather than surface the raw provider error.
1367
+ */
1368
+ fallback?: R;
1369
+ }
1370
+ /** Context handed to the app's error handler for each failed attempt (1-based). */
1371
+ interface ApiErrorContext {
1372
+ error: unknown;
1373
+ /** 1-based attempt number that just failed. */
1374
+ attempt: number;
1375
+ }
1376
+ interface ApiErrorPolicy<R = unknown> {
1377
+ /** Called once per failed attempt. Return `{ retry: true }` to try again, or a `{ fallback }`. */
1378
+ processApiError: (ctx: ApiErrorContext) => ApiErrorDecision<R> | Promise<ApiErrorDecision<R>>;
1379
+ /**
1380
+ * Hard cap on total attempts (defaults to 3). A backstop so a handler that always returns
1381
+ * `{ retry: true }` cannot loop forever (mirrors the SDK's own bounded retry philosophy).
1382
+ */
1383
+ maxAttempts?: number;
1384
+ }
1385
+ /**
1386
+ * Run `thunk`, applying the app's `processApiError` policy on failure. Returns the run's value on
1387
+ * success, the policy's `fallback` when it declines to retry with one, or rethrows the last error.
1388
+ *
1389
+ * `thunk` is typically `() => agent.send(msg).then((r) => r.wait())` — a whole SDK run. On retry the
1390
+ * thunk is re-invoked from scratch (a fresh run), never resumed mid-loop.
1391
+ */
1392
+ declare function runWithApiErrorHandling<R>(thunk: () => Promise<R>, policy: ApiErrorPolicy<R>): Promise<R>;
1393
+ /**
1394
+ * Build a reusable guard bound to one policy. `const guard = createApiErrorHandler({ ... })` then
1395
+ * `guard(() => agent.send(m).then((r) => r.wait()))` — the same policy applied to many runs.
1396
+ */
1397
+ declare function createApiErrorHandler<R = unknown>(policy: ApiErrorPolicy<R>): (thunk: () => Promise<R>) => Promise<R>;
1398
+
1399
+ /**
1400
+ * M25 (theokit-ai-first) — background delegation + task-completion scoring.
1401
+ *
1402
+ * Two THIN wrappers over the M12 `delegate` (ADR 0038/0040): no new orchestration engine, no second
1403
+ * loop, no new store. `delegateBackground` kicks off a sub-agent without blocking the supervisor and
1404
+ * hands back a handle to await later. `delegateWithScoring` runs `delegate`, scores the result with
1405
+ * an injected scorer, and re-delegates with the scorer's feedback until it passes or `maxRounds` is
1406
+ * hit. The `delegate` implementation is injectable (`delegateFn`) so this is testable without a
1407
+ * SubAgent class or an LLM — and so it NEVER re-implements the delegation runtime.
1408
+ */
1409
+
1410
+ /** The delegation primitive both wrappers drive. Defaults to the M12 {@link delegate}. */
1411
+ type DelegateFn = (subAgent: Function, message: string, opts?: DelegateOptions) => Promise<DelegationResult>;
1412
+ /** A running background delegation the supervisor can await/poll later. */
1413
+ interface BackgroundDelegation {
1414
+ /** Await the sub-agent's result (or rejection). Idempotent — returns the same settled promise. */
1415
+ wait(): Promise<DelegationResult>;
1416
+ /** Whether the underlying delegation has resolved or rejected. */
1417
+ settled(): boolean;
1418
+ }
1419
+ /**
1420
+ * Start a sub-agent WITHOUT blocking the supervisor. Returns immediately with a handle; the
1421
+ * supervisor keeps working and calls `wait()` when it needs the result. A thin async wrapper over
1422
+ * `delegate` — not a scheduler (Top-risk 1). Rejections are still observable via `wait()`.
1423
+ */
1424
+ declare function delegateBackground(subAgent: Function, message: string, opts?: DelegateOptions & {
1425
+ delegateFn?: DelegateFn;
1426
+ }): BackgroundDelegation;
1427
+ /** A scorer's verdict on a sub-agent result. `feedback` is fed back into the next round on failure. */
1428
+ interface ScoreVerdict {
1429
+ pass: boolean;
1430
+ /** Optional numeric score (0..1) for logging/telemetry. */
1431
+ score?: number;
1432
+ /** Guidance appended to the next delegation when `pass` is false. */
1433
+ feedback?: string;
1434
+ }
1435
+ /** Scores a sub-agent result. Opt-in (Top-risk 2) — the caller supplies it, and pays its cost. */
1436
+ type Scorer = (result: DelegationResult) => ScoreVerdict | Promise<ScoreVerdict>;
1437
+ /** The outcome of a scored delegation: the final result plus the per-round verdict trail. */
1438
+ interface ScoredDelegation {
1439
+ result: DelegationResult;
1440
+ /** Rounds actually run (1..maxRounds). */
1441
+ rounds: number;
1442
+ /** Whether the final round passed the scorer. */
1443
+ passed: boolean;
1444
+ /** The verdict from each round, in order. */
1445
+ verdicts: ScoreVerdict[];
1446
+ }
1447
+ /**
1448
+ * Run `delegate`, score the result, and re-delegate with the scorer's feedback until it passes or
1449
+ * `maxRounds` is reached. Each round is ONE `delegate` call — no second loop, no new store. Returns
1450
+ * the final result (passing, or the last attempt) with the per-round verdict trail.
1451
+ */
1452
+ declare function delegateWithScoring(subAgent: Function, message: string, opts: DelegateOptions & {
1453
+ scorer: Scorer;
1454
+ maxRounds?: number;
1455
+ delegateFn?: DelegateFn;
1456
+ feedbackTemplate?: (message: string, feedback: string) => string;
1457
+ }): Promise<ScoredDelegation>;
1458
+
1459
+ /**
1460
+ * M24 (ADR-0041) — MCP follow-ups, framework-side layer over the `@MCP` config (ADR-0040 § D2).
1461
+ *
1462
+ * Three home/boundary helpers that compose with the existing `@MCP` / `defineAgent` surfaces — the
1463
+ * SDK still owns MCP server EXECUTION (`Agent.create({ mcpServers })`); these only shape the config:
1464
+ * - `resolveMcpServers` — per-request resolver so multi-tenant apps hand different MCP creds to
1465
+ * different callers (mirrors the M13 skills resolver);
1466
+ * - `mcpRegistry` — build a server config for a known MCP registry (Composio / mcp.run);
1467
+ * - `mcpToolApprovals` — mark MCP tools for approval, producing the M14 `approvals` entries so a
1468
+ * gated MCP tool routes through the (E2E-proven) HITL flow.
1469
+ */
1470
+
1471
+ /** The request context handed to an MCP resolver (the M7 run-context — opaque per-request data). */
1472
+ type McpRequestContext = Record<string, unknown>;
1473
+ /**
1474
+ * How the MCP server set is chosen:
1475
+ * - a map — static `@MCP`-style config.
1476
+ * - a function — resolved per request from the {@link McpRequestContext} (sync or async).
1477
+ */
1478
+ type McpSelection = McpServersMap | ((ctx: McpRequestContext) => McpServersMap | Promise<McpServersMap>);
1479
+ /**
1480
+ * Resolve the MCP servers for a request. Returns `undefined` when no selection is given. Fails fast
1481
+ * if a resolver returns a non-object (error-handling.md). Multi-tenant apps pass a function that
1482
+ * reads per-user credentials from `ctx`.
1483
+ */
1484
+ declare function resolveMcpServers(selection: McpSelection | undefined, ctx: McpRequestContext): Promise<McpServersMap | undefined>;
1485
+ /** Config for {@link mcpRegistry}. `registry` selects a known provider. */
1486
+ interface McpRegistryConfig {
1487
+ registry: 'composio' | 'mcp.run';
1488
+ /** The registry API key (kept in the server's env, never logged). */
1489
+ apiKey: string;
1490
+ /** Composio: the app toolkits to expose (e.g. `['github', 'slack']`). */
1491
+ apps?: string[];
1492
+ /** mcp.run: the profile to connect. */
1493
+ profile?: string;
1494
+ }
1495
+ /**
1496
+ * Build an {@link McpServersMap} for a known MCP registry. Emits an `npx`-launched server config with
1497
+ * the API key in `env`. Documented registries: **Composio** (`@composio/mcp`) and **mcp.run**
1498
+ * (`@mcp.run/cli`). Other registries are wired manually via a raw `@MCP` entry.
1499
+ */
1500
+ declare function mcpRegistry(config: McpRegistryConfig): McpServersMap;
1501
+ /** An MCP tool's approval spec: full {@link HumanInTheLoopOptions} or a bare question string. */
1502
+ type McpApprovalSpec = HumanInTheLoopOptions | string;
1503
+ /**
1504
+ * Mark MCP tools for human approval (`requireToolApproval`). Returns the `Record<toolName,
1505
+ * HumanInTheLoopOptions>` shape the M14 `defineAgent({ approvals })` map consumes — so a gated MCP
1506
+ * tool routes through the same (E2E-proven) HITL flow as a native gated tool. A bare string is
1507
+ * shorthand for `{ question }`.
1508
+ */
1509
+ declare function mcpToolApprovals(specs: Record<string, McpApprovalSpec>): Record<string, HumanInTheLoopOptions>;
1510
+
1350
1511
  /**
1351
1512
  * Agent manifest generator — build-time JSON describing all agents, tools, guards, policies.
1352
1513
  *
@@ -1430,4 +1591,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
1430
1591
  register(app: PluginApp): void;
1431
1592
  };
1432
1593
 
1433
- export { type ReflectionResult as $, type AgentManifestEntry as A, type BeforeToolCallContext as B, type CompiledAgentOptions as C, type DelegationResult as D, type DefineAgentConfig as E, type DelegateOptions as F, type Guardrail as G, DelegationError as H, type DoneEvent as I, type ErrorEvent as J, type FileEditEvent as K, type LoopStrategy as L, type GuardrailAction as M, type GuardrailPhase as N, type GuardrailResult as O, GuardrailViolationError as P, type InferAgentInput as Q, type ReflectionStrategy as R, type StreamEvent as S, type InferAgentToolNames as T, type IterationEvent as U, type LLMCallContext as V, type LoopFinishReason as W, type LoopOutcome as X, type LoopStrategyConfig as Y, type PartialToolCallEvent as Z, type ReflectionContext as _, type CompiledTool as a, type ReflectionStrategyConfig as a0, type RunStartedEvent as a1, type SdkMessage as a2, type Segment as a3, type SkillsRequestContext as a4, type SkillsSelection as a5, type StateUpdateEvent as a6, type TextDeltaEvent as a7, type ThinkingEvent as a8, type ToolCallEvent as a9, isAgentContext as aA, isAgentDefinition as aB, isApprovalRequired as aC, isDone as aD, isError as aE, isPartialToolCall as aF, isTextDelta as aG, isToolCall as aH, isToolResult as aI, ladderReflectionStrategy as aJ, loopStrategyConfigSchema as aK, noopReflectionStrategy as aL, projectContextMetadataOnlyKnobs as aM, reflectionStrategyConfigSchema as aN, resolveEnabledSkills as aO, resolveLoopStrategy as aP, streamAgentResponse as aQ, streamAgentUIMessages as aR, translateSdkEvent as aS, translateToUIMessageStream as aT, validateUniqueRoutes as aU, walkAgentMetadata as aV, type ToolCallVeto as aa, type ToolHooks as ab, type ToolHooksPlugin as ac, type ToolResultEvent as ad, type ToolWalkResult as ae, type ToolboxWalkResult as af, agent as ag, agentsPlugin as ah, buildModelSelection as ai, compileAgent as aj, compileAgentDefinition as ak, compileAgentModule as al, compileContextWindow as am, compileProjectContext as an, compileSkills as ao, compileTools as ap, contextualTool as aq, createAgentExecutionContext as ar, createSdkAgentStream as as, createThinkTagExtractor as at, createToolHooksPlugin as au, defineAgent as av, delegate as aw, extractThinkTagStream as ax, generateAgentManifest as ay, generateAgentRoutes as az, type RoundStreamFactory as b, AGENT_BRAND as c, type AfterToolCallContext as d, type AgentBuilder as e, type AgentDefinition as f, AgentDefinitionError as g, type AgentExecutionContext as h, type AgentManifest as i, type AgentManifestTool as j, type AgentRoute as k, type AgentRouteContext as l, type AgentRunInfo as m, type AgentStreamEvent as n, type AgentWalkResult as o, AgentWarningCode as p, type AgentsPluginOptions as q, type ApprovalRequiredEvent as r, type ArtifactChunkEvent as s, type ArtifactStartEvent as t, BudgetExceededError as u, type CheckpointSavedEvent as v, type CompiledContextWindow as w, type ContextualTool as x, CostBudgetExceededError as y, DEFAULT_MAX_ITERATIONS as z };
1594
+ export { type McpSelection as $, type AgentManifestEntry as A, type BackgroundDelegation as B, type CompiledAgentOptions as C, type DelegationResult as D, type CompiledContextWindow as E, type ContextualTool as F, DEFAULT_MAX_ITERATIONS as G, type DefineAgentConfig as H, type DelegateFn as I, type DelegateOptions as J, DelegationError as K, type LoopStrategy as L, type DoneEvent as M, type ErrorEvent as N, type FileEditEvent as O, type InferAgentInput as P, type InferAgentToolNames as Q, type ReflectionStrategy as R, type StreamEvent as S, type IterationEvent as T, type LLMCallContext as U, type LoopFinishReason as V, type LoopOutcome as W, type LoopStrategyConfig as X, type McpApprovalSpec as Y, type McpRegistryConfig as Z, type McpRequestContext as _, type CompiledTool as a, resolveLoopStrategy as a$, type PartialToolCallEvent as a0, type ProcessInputContext as a1, type ReflectionContext as a2, type ReflectionResult as a3, type ReflectionStrategyConfig as a4, type RunStartedEvent as a5, type ScoreVerdict as a6, type ScoredDelegation as a7, type Scorer as a8, type SdkMessage as a9, createSdkAgentStream as aA, createThinkTagExtractor as aB, createToolHooksPlugin as aC, defineAgent as aD, delegate as aE, delegateBackground as aF, delegateWithScoring as aG, extractThinkTagStream as aH, generateAgentManifest as aI, generateAgentRoutes as aJ, isAgentContext as aK, isAgentDefinition as aL, isApprovalRequired as aM, isDone as aN, isError as aO, isPartialToolCall as aP, isTextDelta as aQ, isToolCall as aR, isToolResult as aS, ladderReflectionStrategy as aT, loopStrategyConfigSchema as aU, mcpRegistry as aV, mcpToolApprovals as aW, noopReflectionStrategy as aX, projectContextMetadataOnlyKnobs as aY, reflectionStrategyConfigSchema as aZ, resolveEnabledSkills as a_, type Segment as aa, type SkillsRequestContext as ab, type SkillsSelection as ac, type StateUpdateEvent as ad, type TextDeltaEvent as ae, type ThinkingEvent as af, type ToolCallEvent as ag, type ToolCallVeto as ah, type ToolHooks as ai, type ToolHooksPlugin as aj, type ToolResultEvent as ak, type ToolWalkResult as al, type ToolboxWalkResult as am, agent as an, agentsPlugin as ao, buildModelSelection as ap, compileAgent as aq, compileAgentDefinition as ar, compileAgentModule as as, compileContextWindow as at, compileProjectContext as au, compileSkills as av, compileTools as aw, contextualTool as ax, createAgentExecutionContext as ay, createApiErrorHandler as az, type RoundStreamFactory as b, resolveMcpServers as b0, runWithApiErrorHandling as b1, streamAgentResponse as b2, streamAgentUIMessages as b3, translateSdkEvent as b4, translateToUIMessageStream as b5, validateUniqueRoutes as b6, walkAgentMetadata as b7, AGENT_BRAND as c, type AfterToolCallContext as d, type AgentBuilder as e, type AgentDefinition as f, AgentDefinitionError as g, type AgentExecutionContext as h, type AgentManifest as i, type AgentManifestTool as j, type AgentRoute as k, type AgentRouteContext as l, type AgentRunInfo as m, type AgentStreamEvent as n, type AgentWalkResult as o, AgentWarningCode as p, type AgentsPluginOptions as q, type ApiErrorContext as r, type ApiErrorDecision as s, type ApiErrorPolicy as t, type ApprovalRequiredEvent as u, type ArtifactChunkEvent as v, type ArtifactStartEvent as w, type BeforeToolCallContext as x, BudgetExceededError as y, type CheckpointSavedEvent as z };
package/dist/bridge.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, A as AgentManifestEntry, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentStreamEvent, o as AgentWalkResult, p as AgentWarningCode, q as AgentsPluginOptions, r as ApprovalRequiredEvent, s as ArtifactChunkEvent, t as ArtifactStartEvent, B as BeforeToolCallContext, u as BudgetExceededError, v as CheckpointSavedEvent, C as CompiledAgentOptions, w as CompiledContextWindow, a as CompiledTool, x as ContextualTool, E as DefineAgentConfig, F as DelegateOptions, H as DelegationError, D as DelegationResult, I as DoneEvent, J as ErrorEvent, K as FileEditEvent, Q as InferAgentInput, T as InferAgentToolNames, U as IterationEvent, V as LLMCallContext, Z as PartialToolCallEvent, a1 as RunStartedEvent, a2 as SdkMessage, a3 as Segment, a6 as StateUpdateEvent, S as StreamEvent, a7 as TextDeltaEvent, a8 as ThinkingEvent, a9 as ToolCallEvent, aa as ToolCallVeto, ab as ToolHooks, ac as ToolHooksPlugin, ad as ToolResultEvent, ae as ToolWalkResult, af as ToolboxWalkResult, ag as agent, ah as agentsPlugin, ai as buildModelSelection, aj as compileAgent, ak as compileAgentDefinition, al as compileAgentModule, am as compileContextWindow, an as compileProjectContext, ao as compileSkills, ap as compileTools, aq as contextualTool, ar as createAgentExecutionContext, as as createSdkAgentStream, at as createThinkTagExtractor, au as createToolHooksPlugin, av as defineAgent, aw as delegate, ax as extractThinkTagStream, ay as generateAgentManifest, az as generateAgentRoutes, aA as isAgentContext, aB as isAgentDefinition, aC as isApprovalRequired, aD as isDone, aE as isError, aF as isPartialToolCall, aG as isTextDelta, aH as isToolCall, aI as isToolResult, aM as projectContextMetadataOnlyKnobs, aQ as streamAgentResponse, aR as streamAgentUIMessages, aS as translateSdkEvent, aT as translateToUIMessageStream, aU as validateUniqueRoutes, aV as walkAgentMetadata } from './bridge-entry-DtDotZGW.js';
1
+ export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, A as AgentManifestEntry, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentStreamEvent, o as AgentWalkResult, p as AgentWarningCode, q as AgentsPluginOptions, r as ApiErrorContext, s as ApiErrorDecision, t as ApiErrorPolicy, u as ApprovalRequiredEvent, v as ArtifactChunkEvent, w as ArtifactStartEvent, B as BackgroundDelegation, x as BeforeToolCallContext, y as BudgetExceededError, z as CheckpointSavedEvent, C as CompiledAgentOptions, E as CompiledContextWindow, a as CompiledTool, F as ContextualTool, H as DefineAgentConfig, I as DelegateFn, J as DelegateOptions, K as DelegationError, D as DelegationResult, M as DoneEvent, N as ErrorEvent, O as FileEditEvent, P as InferAgentInput, Q as InferAgentToolNames, T as IterationEvent, U as LLMCallContext, Y as McpApprovalSpec, Z as McpRegistryConfig, _ as McpRequestContext, $ as McpSelection, a0 as PartialToolCallEvent, a1 as ProcessInputContext, a5 as RunStartedEvent, a6 as ScoreVerdict, a7 as ScoredDelegation, a8 as Scorer, a9 as SdkMessage, aa as Segment, ad as StateUpdateEvent, S as StreamEvent, ae as TextDeltaEvent, af as ThinkingEvent, ag as ToolCallEvent, ah as ToolCallVeto, ai as ToolHooks, aj as ToolHooksPlugin, ak as ToolResultEvent, al as ToolWalkResult, am as ToolboxWalkResult, an as agent, ao as agentsPlugin, ap as buildModelSelection, aq as compileAgent, ar as compileAgentDefinition, as as compileAgentModule, at as compileContextWindow, au as compileProjectContext, av as compileSkills, aw as compileTools, ax as contextualTool, ay as createAgentExecutionContext, az as createApiErrorHandler, aA as createSdkAgentStream, aB as createThinkTagExtractor, aC as createToolHooksPlugin, aD as defineAgent, aE as delegate, aF as delegateBackground, aG as delegateWithScoring, aH as extractThinkTagStream, aI as generateAgentManifest, aJ as generateAgentRoutes, aK as isAgentContext, aL as isAgentDefinition, aM as isApprovalRequired, aN as isDone, aO as isError, aP as isPartialToolCall, aQ as isTextDelta, aR as isToolCall, aS as isToolResult, aV as mcpRegistry, aW as mcpToolApprovals, aY as projectContextMetadataOnlyKnobs, b0 as resolveMcpServers, b1 as runWithApiErrorHandling, b2 as streamAgentResponse, b3 as streamAgentUIMessages, b4 as translateSdkEvent, b5 as translateToUIMessageStream, b6 as validateUniqueRoutes, b7 as walkAgentMetadata } from './bridge-entry-BydskfrI.js';
2
2
  import '@theokit/http';
3
- import './skills-Dx_KJ6Eg.js';
3
+ import './types-S7k_lt1_.js';
4
4
  import '@theokit/sdk';
5
5
  import 'zod';
6
6
  import 'ai';
package/dist/bridge.js CHANGED
@@ -16,11 +16,14 @@ import {
16
16
  compileTools,
17
17
  contextualTool,
18
18
  createAgentExecutionContext,
19
+ createApiErrorHandler,
19
20
  createSdkAgentStream,
20
21
  createThinkTagExtractor,
21
22
  createToolHooksPlugin,
22
23
  defineAgent,
23
24
  delegate,
25
+ delegateBackground,
26
+ delegateWithScoring,
24
27
  extractThinkTagStream,
25
28
  generateAgentManifest,
26
29
  generateAgentRoutes,
@@ -33,15 +36,19 @@ import {
33
36
  isTextDelta,
34
37
  isToolCall,
35
38
  isToolResult,
39
+ mcpRegistry,
40
+ mcpToolApprovals,
36
41
  projectContextMetadataOnlyKnobs,
42
+ resolveMcpServers,
43
+ runWithApiErrorHandling,
37
44
  streamAgentResponse,
38
45
  streamAgentUIMessages,
39
46
  translateSdkEvent,
40
47
  translateToUIMessageStream,
41
48
  validateUniqueRoutes,
42
49
  walkAgentMetadata
43
- } from "./chunk-BWYBOMKR.js";
44
- import "./chunk-FI6ZG2YP.js";
50
+ } from "./chunk-TXEY3IUO.js";
51
+ import "./chunk-MD35WBR4.js";
45
52
  import "./chunk-7QVYU63E.js";
46
53
  export {
47
54
  AGENT_BRAND,
@@ -61,11 +68,14 @@ export {
61
68
  compileTools,
62
69
  contextualTool,
63
70
  createAgentExecutionContext,
71
+ createApiErrorHandler,
64
72
  createSdkAgentStream,
65
73
  createThinkTagExtractor,
66
74
  createToolHooksPlugin,
67
75
  defineAgent,
68
76
  delegate,
77
+ delegateBackground,
78
+ delegateWithScoring,
69
79
  extractThinkTagStream,
70
80
  generateAgentManifest,
71
81
  generateAgentRoutes,
@@ -78,7 +88,11 @@ export {
78
88
  isTextDelta,
79
89
  isToolCall,
80
90
  isToolResult,
91
+ mcpRegistry,
92
+ mcpToolApprovals,
81
93
  projectContextMetadataOnlyKnobs,
94
+ resolveMcpServers,
95
+ runWithApiErrorHandling,
82
96
  streamAgentResponse,
83
97
  streamAgentUIMessages,
84
98
  translateSdkEvent,
@@ -5,7 +5,7 @@ import {
5
5
  TOOL_METHODS,
6
6
  getMeta,
7
7
  setMeta
8
- } from "./chunk-FI6ZG2YP.js";
8
+ } from "./chunk-MD35WBR4.js";
9
9
  import {
10
10
  __name
11
11
  } from "./chunk-7QVYU63E.js";
@@ -262,4 +262,4 @@ export {
262
262
  EditFormat,
263
263
  applyDecorators
264
264
  };
265
- //# sourceMappingURL=chunk-K4MCMREI.js.map
265
+ //# sourceMappingURL=chunk-GEV2EQW2.js.map
@@ -134,6 +134,19 @@ function getSkillsConfig(target) {
134
134
  }
135
135
  __name(getSkillsConfig, "getSkillsConfig");
136
136
 
137
+ // src/decorators/guardrails.ts
138
+ var GUARDRAILS_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:guardrails");
139
+ function Guardrails(guardrails) {
140
+ return (target) => {
141
+ setMeta(GUARDRAILS_CONFIG, target, guardrails);
142
+ };
143
+ }
144
+ __name(Guardrails, "Guardrails");
145
+ function getGuardrailsConfig(target) {
146
+ return getMeta(GUARDRAILS_CONFIG, target);
147
+ }
148
+ __name(getGuardrailsConfig, "getGuardrailsConfig");
149
+
137
150
  // src/decorators/mcp.ts
138
151
  var MCP_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:mcp");
139
152
  function MCP(servers) {
@@ -296,6 +309,8 @@ export {
296
309
  getMemoryConfig,
297
310
  Skills,
298
311
  getSkillsConfig,
312
+ Guardrails,
313
+ getGuardrailsConfig,
299
314
  MCP,
300
315
  getMcpConfig,
301
316
  HumanInTheLoop,
@@ -311,4 +326,4 @@ export {
311
326
  Mixin,
312
327
  getMixins
313
328
  };
314
- //# sourceMappingURL=chunk-FI6ZG2YP.js.map
329
+ //# sourceMappingURL=chunk-MD35WBR4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/metadata/index.ts","../src/metadata/keys.ts","../src/decorators/agent.ts","../src/decorators/policies.ts","../src/decorators/observability.ts","../src/decorators/gateway.ts","../src/decorators/sub-agents.ts","../src/decorators/memory.ts","../src/decorators/skills.ts","../src/decorators/guardrails.ts","../src/decorators/mcp.ts","../src/decorators/human-in-the-loop.ts","../src/decorators/context-window.ts","../src/decorators/compaction.ts","../src/decorators/checkpoint.ts","../src/decorators/project-context.ts","../src/decorators/mixin.ts"],"sourcesContent":["// Re-export setMeta/getMeta from http-decorators (DRY — single metadata engine)\n// Relative path for workspace-local usage; vitest resolves via alias\nexport { setMeta, getMeta } from '@theokit/http'\n\nexport * from './keys.js'\n","/** Symbol.for metadata keys for agent decorators — cross-module safe with SWC loader. */\n\nexport const AGENT_CONFIG = Symbol.for('theokit:agents:config')\nexport const AGENT_MAIN_LOOP = Symbol.for('theokit:agents:main-loop')\nexport const TOOLBOX_CONFIG = Symbol.for('theokit:agents:toolbox')\nexport const TOOL_CONFIG = Symbol.for('theokit:agents:tool')\nexport const TOOL_METHODS = Symbol.for('theokit:agents:tool-methods')\n","/**\n * @Agent() — marks a class as an AI agent controller.\n *\n * Convention over configuration:\n * @Agent() → name + route inferred from class name\n * @Agent({ model: '...' }) → name + route inferred, model explicit\n * @Agent({ name, route, model }) → fully explicit\n *\n * @example\n * ```ts\n * // Convention: SupportAgent → name: 'support', route: '/api/agents/support'\n * @Agent()\n * class SupportAgent { ... }\n *\n * // Partial: infer name + route, set model\n * @Agent({ model: 'claude-sonnet-4-5-20250929' })\n * class SupportAgent { ... }\n *\n * // Explicit: full control\n * @Agent({ name: 'support-agent', route: '/api/agents/support', model: '...' })\n * class SupportAgent { ... }\n * ```\n */\nimport { setMeta, getMeta, AGENT_CONFIG } from '../metadata/index.js'\nimport type { AgentOptions } from '../types.js'\n\n/**\n * Infer agent name and route from class name (Rails-style convention).\n *\n * SupportAgent → name: 'support', route: '/api/agents/support'\n * ResearchAgent → name: 'research', route: '/api/agents/research'\n * CodeReviewAgent → name: 'code-review', route: '/api/agents/code-review'\n */\nfunction inferAgentMeta(className: string): { name: string; route: string } {\n const stripped = className.replace(/Agent$/, '')\n const kebab = stripped\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')\n .toLowerCase()\n return { name: kebab, route: `/api/agents/${kebab}` }\n}\n\nexport function Agent(options?: Partial<AgentOptions>): ClassDecorator {\n return (target: Function) => {\n const inferred = inferAgentMeta(target.name)\n setMeta(AGENT_CONFIG, target, {\n stream: true,\n name: inferred.name,\n route: inferred.route,\n ...options, // explicit values override inferred\n })\n }\n}\n\nexport function getAgentConfig(target: Function): AgentOptions | undefined {\n return getMeta<AgentOptions>(AGENT_CONFIG, target)\n}\n","/**\n * Agent-native policy decorators — built on http-decorators' createDecorator<T>().\n *\n * These decorators work with Reflector.getAllAndOverride() for hierarchical\n * resolution: tool → toolbox → agent (method-level overrides class-level).\n */\nimport { createDecorator } from '@theokit/http'\n\nimport type { ApprovalOptions, BudgetOptions, PolicyHandler } from '../types.js'\n\n/** Mark a tool as requiring human approval before execution. */\nexport const RequiresApproval = createDecorator<ApprovalOptions>()\n\n/** Require specific capabilities (permissions) to execute a tool. */\nexport const RequiresCapability = createDecorator<string[]>()\n\n/** Set a cost budget for an agent or tool scope. */\nexport const Budget = createDecorator<BudgetOptions>()\n\n/** Attach policy handler functions (CASL-style authorization). */\nexport const Policy = createDecorator<PolicyHandler[]>()\n","/**\n * Observability decorators for agent tracing and auditing.\n */\nimport { createDecorator } from '@theokit/http'\n\n/** Enable distributed tracing for a tool/toolbox/agent. */\nexport const Trace = createDecorator<boolean>()\n\n/** Enable audit logging for a tool/toolbox/agent. */\nexport const Audit = createDecorator<boolean>()\n","/**\n * @Gateway() — declares which platform adapters an agent supports.\n *\n * Stores gateway configuration metadata on the agent class.\n * The GatewayRunner reads this to auto-wire adapters without manual plumbing.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Gateway({\n * platforms: ['telegram', 'discord', 'slack'],\n * sessionStrategy: 'per-user',\n * })\n * @UseGuards(AuthGuard)\n * class SupportAgent {\n * @MainLoop()\n * async run(ctx: AgentContext) { ... }\n * }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst GATEWAY_CONFIG = Symbol.for('theokit:agents:gateway')\n\nexport type PlatformName =\n | 'telegram'\n | 'discord'\n | 'slack'\n | 'whatsapp'\n | 'teams'\n | 'email'\n | 'sms'\n | 'mattermost'\n | 'line'\n | 'matrix'\n\nexport type SessionStrategy =\n | 'per-user' // telegram-dm-{userId}\n | 'per-channel' // telegram-grp-{channelId}\n | 'per-thread' // telegram-tpc-{channelId}-{topicId}\n\nexport interface GatewayOptions {\n /** Platform adapters this agent supports. */\n platforms: PlatformName[]\n /** How to resolve agentId from inbound events (default: 'per-user'). */\n sessionStrategy?: SessionStrategy\n /** Auto-start typing indicator while agent processes (default: true). */\n typing?: boolean\n}\n\nexport function Gateway(options: GatewayOptions): ClassDecorator {\n return (target: Function) => {\n setMeta(GATEWAY_CONFIG, target, { typing: true, sessionStrategy: 'per-user', ...options })\n }\n}\n\nexport function getGatewayConfig(target: Function): GatewayOptions | undefined {\n return getMeta<GatewayOptions>(GATEWAY_CONFIG, target)\n}\n\n/**\n * Resolve a stable agentId from a platform event based on the session strategy.\n *\n * Mirrors @theokit/gateway SessionRouter.defaultStrategy() but is configurable\n * via the @Gateway decorator.\n */\nexport function resolveSessionId(\n strategy: SessionStrategy,\n platform: string,\n sender: { id: string },\n channel: { id: string; type: 'dm' | 'group' | 'thread'; topicId?: string },\n): string {\n switch (strategy) {\n case 'per-user':\n return `${platform}-dm-${sender.id}`\n case 'per-channel':\n return `${platform}-grp-${channel.id}`\n case 'per-thread':\n return `${platform}-tpc-${channel.id}-${channel.topicId ?? 'main'}`\n }\n}\n","/**\n * @SubAgents() — declares child agents that a parent agent can handoff to.\n *\n * Compiles to the SDK's `AgentOptions.agents` map. The parent agent\n * can delegate work to sub-agents via the built-in Agent tool.\n *\n * @example\n * ```ts\n * @Agent({ name: 'orchestrator', route: '/api/agents/orchestrator' })\n * @SubAgents([ResearchAgent, CoderAgent, ReviewerAgent])\n * class OrchestratorAgent {\n * @MainLoop({ strategy: 'plan-act-reflect' })\n * async run(ctx: AgentContext) { ... }\n * }\n * ```\n *\n * Each referenced class MUST be decorated with @Agent().\n * The compiler reads their metadata to build the SDK agents map.\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nimport { getAgentConfig } from './agent.js'\n\nconst SUB_AGENTS = Symbol.for('theokit:agents:sub-agents')\n\nexport function SubAgents(agentClasses: Function[]): ClassDecorator {\n return (target: Function) => {\n // Validate at decoration time: all classes must have @Agent\n for (const cls of agentClasses) {\n const config = getAgentConfig(cls)\n if (!config) {\n throw new Error(\n `[@theokit/agents] @SubAgents on ${target.name}: class ${cls.name} is missing @Agent() decorator.`,\n )\n }\n }\n setMeta(SUB_AGENTS, target, agentClasses)\n }\n}\n\nexport function getSubAgents(target: Function): Function[] {\n return getMeta<Function[]>(SUB_AGENTS, target) ?? []\n}\n","/**\n * @Memory() — declares persistent memory configuration for an agent.\n *\n * Compiles to SDK's MemorySettings in Agent.create({ memory }).\n * Memory is per-agent, scoped by session strategy.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Memory({ provider: 'built-in', embeddings: true, fts: true, scope: 'per-user' })\n * class SupportAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst MEMORY_CONFIG = Symbol.for('theokit:agents:memory')\n\nexport type MemoryProvider = 'built-in' | 'honcho' | 'supermemory' | 'mem0'\nexport type MemoryScope = 'per-user' | 'per-agent' | 'per-tenant' | 'global'\n\nexport interface MemoryOptions {\n /** Memory provider backend. */\n provider?: MemoryProvider\n /** Enable semantic search via embeddings. */\n embeddings?: boolean\n /** Enable full-text search (FTS5). */\n fts?: boolean\n /** Memory isolation scope (default: 'per-user'). */\n scope?: MemoryScope\n /** Maximum facts to retain per scope (0 = unlimited). */\n maxFacts?: number\n}\n\nexport function Memory(options: MemoryOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(MEMORY_CONFIG, target, {\n provider: 'built-in',\n embeddings: false,\n fts: false,\n scope: 'per-user',\n ...options,\n })\n }\n}\n\nexport function getMemoryConfig(target: Function): MemoryOptions | undefined {\n return getMeta<MemoryOptions>(MEMORY_CONFIG, target)\n}\n","/**\n * @Skills() — declares markdown skill files injected into the agent's system prompt.\n *\n * Compiles to SDK's SkillsSettings in Agent.create({ skills }).\n * Skills are .theokit/skills/<name>/SKILL.md files discovered at agent creation.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Skills(['customer-service', 'refund-policy', 'escalation-protocol'])\n * class SupportAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst SKILLS_CONFIG = Symbol.for('theokit:agents:skills')\n\nexport interface SkillsOptions {\n /** Skill names to include (resolved from .theokit/skills/<name>/SKILL.md). */\n include: string[]\n /** Auto-discover all skills in .theokit/skills/ (default: false). */\n autoDiscover?: boolean\n}\n\nexport function Skills(namesOrOptions: string[] | SkillsOptions): ClassDecorator {\n return (target: Function) => {\n const options: SkillsOptions = Array.isArray(namesOrOptions)\n ? { include: namesOrOptions, autoDiscover: false }\n : namesOrOptions\n setMeta(SKILLS_CONFIG, target, options)\n }\n}\n\nexport function getSkillsConfig(target: Function): SkillsOptions | undefined {\n return getMeta<SkillsOptions>(SKILLS_CONFIG, target)\n}\n","/**\n * `@Guardrails([...])` — M9 class-decorator surface for input/output guardrails.\n *\n * The functional `defineAgent({ guardrails: [...] })` path already applies guards at the framework\n * boundary (ADR-0040 § D2). This decorator gives the `@Agent` class path the SAME capability: the\n * declared guards compile into `compiled.guardrails` (via `walkAgentMetadata`), so `AgentRunner`\n * applies them identically. Metadata-only (like `@MCP`/`@Skills`) — it describes, the runner runs.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Guardrails([promptInjectionDetector(), piiDetector({ redact: true })])\n * class SupportAgent {}\n * ```\n */\nimport type { Guardrail } from '../guardrails/index.js'\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst GUARDRAILS_CONFIG = Symbol.for('theokit:agents:guardrails')\n\nexport function Guardrails(guardrails: readonly Guardrail[]): ClassDecorator {\n return (target: Function) => {\n setMeta(GUARDRAILS_CONFIG, target, guardrails)\n }\n}\n\nexport function getGuardrailsConfig(target: Function): readonly Guardrail[] | undefined {\n return getMeta<readonly Guardrail[]>(GUARDRAILS_CONFIG, target)\n}\n","/**\n * @MCP() — declares Model Context Protocol servers available to an agent.\n *\n * Compiles to SDK's mcpServers in Agent.create({ mcpServers }).\n * Each key is a server name; the value is the server configuration.\n *\n * @example\n * ```ts\n * @Agent({ name: 'dev', route: '/api/agents/dev' })\n * @MCP({\n * github: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-github'] },\n * filesystem: { command: 'npx', args: ['-y', '@mcp/server-filesystem', '/workspace'] },\n * })\n * class DevAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst MCP_CONFIG = Symbol.for('theokit:agents:mcp')\n\nexport interface McpServerConfig {\n /** Command to start the MCP server. */\n command: string\n /** Arguments passed to the command. */\n args?: string[]\n /** Environment variables for the server process. */\n env?: Record<string, string>\n /** Working directory for the server process. */\n cwd?: string\n}\n\nexport type McpServersMap = Record<string, McpServerConfig>\n\nexport function MCP(servers: McpServersMap): ClassDecorator {\n return (target: Function) => {\n setMeta(MCP_CONFIG, target, servers)\n }\n}\n\nexport function getMcpConfig(target: Function): McpServersMap | undefined {\n return getMeta<McpServersMap>(MCP_CONFIG, target)\n}\n","/**\n * @HumanInTheLoop() — pause agent execution to request human approval.\n *\n * When applied to a @Tool method, the agent pauses before executing the tool\n * and emits an 'approval_required' SSE event. The client must POST to the\n * callback URL to approve or deny. If denied or timed out, the tool is skipped.\n *\n * @example\n * ```ts\n * @Toolbox({ namespace: 'ops' })\n * class OpsTools {\n * @Tool({ name: 'deploy', description: 'Deploy to prod', input: z.object({...}) })\n * @HumanInTheLoop({\n * question: 'Confirm deployment to production?',\n * timeout: 300_000,\n * onTimeout: 'abort',\n * })\n * async deploy(input: {...}) { ... }\n * }\n * ```\n *\n * SSE event emitted:\n * ```json\n * { \"type\": \"approval_required\", \"toolName\": \"ops.deploy\", \"question\": \"...\", \"callbackUrl\": \"/agents/x/approve/call-123\" }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst HITL_CONFIG = Symbol.for('theokit:agents:human-in-the-loop')\n\nexport type TimeoutAction = 'abort' | 'proceed' | 'retry'\n\nexport interface HumanInTheLoopOptions {\n /** Question shown to the human approver. */\n question: string\n /** Timeout in milliseconds before onTimeout fires (default: 300_000 = 5 min). */\n timeout?: number\n /** Action when timeout expires (default: 'abort'). */\n onTimeout?: TimeoutAction\n /** Show the tool input to the approver (default: true). */\n showInput?: boolean\n /**\n * M20 — an optional JSON-schema descriptor of the custom payload the approver may attach (edited\n * args, a review note). Carried into the `approval_required` event + `GET /approvals` so the UI\n * knows what to collect. A plain JSON object, not a live Zod schema (keeps the wire serializable).\n */\n payloadSchema?: Record<string, unknown>\n}\n\nexport function HumanInTheLoop(options: HumanInTheLoopOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n setMeta(\n HITL_CONFIG,\n actualTarget,\n {\n timeout: 300_000,\n onTimeout: 'abort',\n showInput: true,\n ...options,\n },\n propertyKey,\n )\n }\n}\n\nexport function getHumanInTheLoopConfig(\n target: Function,\n propertyKey: string | symbol,\n): HumanInTheLoopOptions | undefined {\n return getMeta<HumanInTheLoopOptions>(HITL_CONFIG, target, propertyKey)\n}\n","/**\n * @ContextWindow() — declares context window management strategy.\n *\n * Controls how the agent handles context when conversation history grows\n * beyond the LLM's context window. Mirrors Claude Code's PreCompact behavior.\n *\n * @example\n * ```ts\n * @Agent({ name: 'research', route: '/research' })\n * @ContextWindow({\n * maxTokens: 100_000,\n * compactionStrategy: 'summarize-oldest',\n * preserveSystemPrompt: true,\n * preserveLastN: 10,\n * })\n * class ResearchAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst CONTEXT_WINDOW_CONFIG = Symbol.for('theokit:agents:context-window')\n\nexport type ContextCompactionStrategy =\n | 'truncate-oldest' // Drop oldest messages beyond limit\n | 'summarize-oldest' // LLM-summarize oldest messages into a single message\n | 'sliding-window' // Keep last N messages only\n | 'priority-based' // Keep tool results + recent; summarize reasoning\n\nexport interface ContextWindowOptions {\n /** Maximum tokens before compaction triggers. */\n maxTokens?: number\n /** How to compact when maxTokens is exceeded. */\n compactionStrategy?: ContextCompactionStrategy\n /** Always preserve the system prompt during compaction (default: true). */\n preserveSystemPrompt?: boolean\n /** Number of recent messages to always keep intact (default: 10). */\n preserveLastN?: number\n /** Keep all tool results even during compaction (default: true). */\n preserveToolResults?: boolean\n}\n\nexport function ContextWindow(options: ContextWindowOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(CONTEXT_WINDOW_CONFIG, target, {\n maxTokens: 100_000,\n compactionStrategy: 'summarize-oldest',\n preserveSystemPrompt: true,\n preserveLastN: 10,\n preserveToolResults: true,\n ...options,\n })\n }\n}\n\nexport function getContextWindowConfig(target: Function): ContextWindowOptions | undefined {\n return getMeta<ContextWindowOptions>(CONTEXT_WINDOW_CONFIG, target)\n}\n","/**\n * `@Compaction(name, opts)` — declares the agent's transcript-compaction strategy\n * (V4-F). Metadata-only: it records the choice; `AgentRunner.build()` resolves it\n * to a concrete {@link TranscriptCompactionStrategy} via `resolveCompactionStrategy`\n * (EC-5 — an invalid name/budget fails fast at build, not at decoration).\n *\n * Mirrors the `@ContextWindow` metadata pattern (`setMeta`/`getMeta` + a unique\n * Symbol). NOT auto-applied by the loop (ADR D1) — the resolved strategy is exposed\n * as `runner.compaction` for the app to call.\n *\n * @example\n * ```ts\n * @Agent({ model })\n * @Compaction('token-budget', { keepTokens: 8000 })\n * class CodeAgent {}\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst COMPACTION_CONFIG = Symbol.for('theokit:agents:compaction')\n\n/** Stored `@Compaction` declaration (resolved + validated at `AgentRunner.build()`). */\nexport interface CompactionDecoratorConfig {\n /** Strategy name (e.g. `'token-budget'`). Validated at resolve time. */\n name: string\n /** Token budget for `'token-budget'`. Required at resolve time (EC-2). */\n keepTokens?: number\n}\n\nexport function Compaction(name: string, options: { keepTokens?: number } = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(COMPACTION_CONFIG, target, { name, keepTokens: options.keepTokens })\n }\n}\n\nexport function getCompactionConfig(target: Function): CompactionDecoratorConfig | undefined {\n return getMeta<CompactionDecoratorConfig>(COMPACTION_CONFIG, target)\n}\n","/**\n * @Checkpoint() — enables resumable agent execution from the last successful step.\n *\n * Long-running agents (research, code review, multi-step workflows) can fail\n * partway through. Without checkpointing, users restart from step 1 — wasting\n * tokens, time, and cost.\n *\n * Inspired by tRPC's tracked() + lastEventId pattern and Dapr's actor state\n * checkpointing. The agent persists a recovery point after each successful\n * tool call or iteration, and can resume from that point on retry.\n *\n * @example\n * ```ts\n * @Agent({ name: 'research', route: '/research' })\n * @Checkpoint({\n * storage: 'filesystem', // only 'filesystem' resumes across requests in the M2 harness (M4)\n * strategy: 'after-tool-call',\n * maxCheckpoints: 20,\n * ttl: 3_600_000, // 1h\n * })\n * class ResearchAgent {\n * @MainLoop({ strategy: 'plan-act-reflect', maxIterations: 15 })\n * async run() {}\n * }\n *\n * // Resume: a follow-up POST /api/agents/research with the SAME sessionId replays the persisted\n * // history. NOTE (M4): only `storage: 'filesystem'` resumes across requests today — `memory`\n * // (the default below) is per-run; `drizzle`/`redis` are not shipped by the SDK. A non-filesystem\n * // @Checkpoint emits a THEO_AGENT_CHECKPOINT_STORAGE_METADATA_ONLY warning (honest enforcement).\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst CHECKPOINT_CONFIG = Symbol.for('theokit:agents:checkpoint')\n\nexport type CheckpointStrategy =\n | 'after-tool-call' // checkpoint after every successful tool execution\n | 'after-iteration' // checkpoint after every loop iteration\n | 'manual' // only checkpoint when explicitly called via ctx.checkpoint()\n\nexport type CheckpointStorage = 'memory' | 'filesystem' | 'drizzle' | 'redis'\n\nexport interface CheckpointOptions {\n /** Where to persist checkpoints. */\n storage?: CheckpointStorage\n /** When to auto-checkpoint (default: 'after-tool-call'). */\n strategy?: CheckpointStrategy\n /** Maximum checkpoints to retain per run (rolling window). */\n maxCheckpoints?: number\n /** Time-to-live in ms before checkpoints expire (default: 3_600_000 = 1h). */\n ttl?: number\n}\n\n/** Serializable checkpoint state. */\nexport interface CheckpointState {\n id: string\n runId: string\n agentName: string\n step: number\n messages: unknown[]\n toolResults: unknown[]\n createdAt: number\n resumeToken: string\n}\n\nexport function Checkpoint(options: CheckpointOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(CHECKPOINT_CONFIG, target, {\n storage: 'memory',\n strategy: 'after-tool-call',\n maxCheckpoints: 10,\n ttl: 3_600_000,\n ...options,\n })\n }\n}\n\nexport function getCheckpointConfig(target: Function): CheckpointOptions | undefined {\n return getMeta<CheckpointOptions>(CHECKPOINT_CONFIG, target)\n}\n","/**\n * @ProjectContext() — declares how the agent understands the codebase.\n *\n * A code assistant needs to know: what's the project root, which files\n * are relevant, how to parse code structure, what to ignore. This\n * metadata feeds the context window management and file discovery.\n *\n * @example\n * ```ts\n * @Agent({ name: 'coder', route: '/agents/coder' })\n * @ProjectContext({\n * rootMarkers: ['package.json', 'tsconfig.json'],\n * indexStrategy: 'tree-sitter',\n * maxFilesInContext: 20,\n * relevanceStrategy: 'git-history',\n * ignorePatterns: ['node_modules', 'dist', '.git'],\n * })\n * class CoderAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst PROJECT_CONTEXT_CONFIG = Symbol.for('theokit:agents:project-context')\n\nexport type IndexStrategy =\n | 'tree-sitter' // Parse AST for structural understanding\n | 'regex' // Simple regex-based symbol extraction\n | 'none' // No indexing — rely on grep/glob only\n\nexport type RelevanceStrategy =\n | 'git-history' // Prioritize recently-edited files\n | 'import-graph' // Follow import chains from entry points\n | 'semantic' // Embedding-based similarity search\n | 'manual' // Only files explicitly provided\n\nexport interface ProjectContextOptions {\n /** Files that mark the project root (searched upward from cwd). */\n rootMarkers?: string[]\n /** How to index the codebase for structural understanding. */\n indexStrategy?: IndexStrategy\n /** Maximum files to include in context per request. */\n maxFilesInContext?: number\n /** How to rank file relevance when selecting context. */\n relevanceStrategy?: RelevanceStrategy\n /** Glob patterns to exclude from indexing and context. */\n ignorePatterns?: string[]\n /** File extensions to include in indexing (default: all text files). */\n includeExtensions?: string[]\n}\n\nexport function ProjectContext(options: ProjectContextOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(PROJECT_CONTEXT_CONFIG, target, {\n rootMarkers: ['package.json', 'tsconfig.json', 'go.mod', 'Cargo.toml', 'pyproject.toml'],\n indexStrategy: 'regex',\n maxFilesInContext: 20,\n relevanceStrategy: 'git-history',\n ignorePatterns: ['node_modules', 'dist', 'build', '.git', 'coverage', '__pycache__'],\n ...options,\n })\n }\n}\n\nexport function getProjectContextConfig(target: Function): ProjectContextOptions | undefined {\n return getMeta<ProjectContextOptions>(PROJECT_CONTEXT_CONFIG, target)\n}\n","/**\n * @Mixin() — compose reusable capability classes into an agent.\n *\n * Mixins are classes with @Tool methods that can be shared across agents.\n * @Mixin copies tool metadata from mixin classes to the decorated agent,\n * making those tools available without inheritance.\n *\n * @example\n * ```ts\n * // Define reusable capabilities\n * class WithSearchCapability {\n * @Tool({ name: 'web_search', description: 'Search', input: z.object({...}) })\n * async webSearch(input) { ... }\n * }\n *\n * class WithFileSystem {\n * @Tool({ name: 'read_file', description: 'Read', input: z.object({...}) })\n * async readFile(input) { ... }\n * }\n *\n * // Compose into agent\n * @Agent({ name: 'research', route: '/research' })\n * @Mixin(WithSearchCapability, WithFileSystem)\n * class ResearchAgent {\n * @MainLoop()\n * async run() {}\n * }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst MIXIN_CLASSES = Symbol.for('theokit:agents:mixins')\n\nexport function Mixin(...mixinClasses: Function[]): ClassDecorator {\n return (target: Function) => {\n const existing = getMeta<Function[]>(MIXIN_CLASSES, target) ?? []\n setMeta(MIXIN_CLASSES, target, [...existing, ...mixinClasses])\n }\n}\n\nexport function getMixins(target: Function): Function[] {\n return getMeta<Function[]>(MIXIN_CLASSES, target) ?? []\n}\n"],"mappings":"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","names":["setMeta","getMeta","AGENT_CONFIG","Symbol","for","AGENT_MAIN_LOOP","TOOLBOX_CONFIG","TOOL_CONFIG","TOOL_METHODS","inferAgentMeta","className","stripped","replace","kebab","toLowerCase","name","route","Agent","options","target","inferred","setMeta","AGENT_CONFIG","stream","getAgentConfig","getMeta","createDecorator","RequiresApproval","RequiresCapability","Budget","Policy","createDecorator","Trace","Audit","GATEWAY_CONFIG","Symbol","for","Gateway","options","target","setMeta","typing","sessionStrategy","getGatewayConfig","getMeta","resolveSessionId","strategy","platform","sender","channel","id","topicId","SUB_AGENTS","Symbol","for","SubAgents","agentClasses","target","cls","config","getAgentConfig","Error","name","setMeta","getSubAgents","getMeta","MEMORY_CONFIG","Symbol","for","Memory","options","target","setMeta","provider","embeddings","fts","scope","getMemoryConfig","getMeta","SKILLS_CONFIG","Symbol","for","Skills","namesOrOptions","target","options","Array","isArray","include","autoDiscover","setMeta","getSkillsConfig","getMeta","GUARDRAILS_CONFIG","Symbol","for","Guardrails","guardrails","target","setMeta","getGuardrailsConfig","getMeta","MCP_CONFIG","Symbol","for","MCP","servers","target","setMeta","getMcpConfig","getMeta","HITL_CONFIG","Symbol","for","HumanInTheLoop","options","target","propertyKey","actualTarget","setMeta","timeout","onTimeout","showInput","getHumanInTheLoopConfig","getMeta","CONTEXT_WINDOW_CONFIG","Symbol","for","ContextWindow","options","target","setMeta","maxTokens","compactionStrategy","preserveSystemPrompt","preserveLastN","preserveToolResults","getContextWindowConfig","getMeta","COMPACTION_CONFIG","Symbol","for","Compaction","name","options","target","setMeta","keepTokens","getCompactionConfig","getMeta","CHECKPOINT_CONFIG","Symbol","for","Checkpoint","options","target","setMeta","storage","strategy","maxCheckpoints","ttl","getCheckpointConfig","getMeta","PROJECT_CONTEXT_CONFIG","Symbol","for","ProjectContext","options","target","setMeta","rootMarkers","indexStrategy","maxFilesInContext","relevanceStrategy","ignorePatterns","getProjectContextConfig","getMeta","MIXIN_CLASSES","Symbol","for","Mixin","mixinClasses","target","existing","getMeta","setMeta","getMixins"]}