@theokit/agents 0.32.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.
- package/dist/{bridge-entry-1r1DL-mS.d.ts → bridge-entry-BydskfrI.d.ts} +4 -49
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +2 -2
- package/dist/{chunk-AAG26UJ7.js → chunk-GEV2EQW2.js} +2 -2
- package/dist/{chunk-3AX6M5TF.js → chunk-MD35WBR4.js} +16 -1
- package/dist/chunk-MD35WBR4.js.map +1 -0
- package/dist/{chunk-5VIRIPVV.js → chunk-TXEY3IUO.js} +63 -53
- package/dist/chunk-TXEY3IUO.js.map +1 -0
- package/dist/decorators.d.ts +22 -3
- package/dist/decorators.js +6 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/{skills-DvI_LYWZ.d.ts → types-S7k_lt1_.d.ts} +48 -1
- package/package.json +1 -1
- package/dist/chunk-3AX6M5TF.js.map +0 -1
- package/dist/chunk-5VIRIPVV.js.map +0 -1
- /package/dist/{chunk-AAG26UJ7.js.map → chunk-GEV2EQW2.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
|
-
import { A as AgentOptions,
|
|
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
|
*
|
|
@@ -1636,4 +1591,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
|
|
|
1636
1591
|
register(app: PluginApp): void;
|
|
1637
1592
|
};
|
|
1638
1593
|
|
|
1639
|
-
export { type
|
|
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 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,
|
|
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 './
|
|
3
|
+
import './types-S7k_lt1_.js';
|
|
4
4
|
import '@theokit/sdk';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|
package/dist/bridge.js
CHANGED
|
@@ -47,8 +47,8 @@ import {
|
|
|
47
47
|
translateToUIMessageStream,
|
|
48
48
|
validateUniqueRoutes,
|
|
49
49
|
walkAgentMetadata
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import "./chunk-
|
|
50
|
+
} from "./chunk-TXEY3IUO.js";
|
|
51
|
+
import "./chunk-MD35WBR4.js";
|
|
52
52
|
import "./chunk-7QVYU63E.js";
|
|
53
53
|
export {
|
|
54
54
|
AGENT_BRAND,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
TOOL_METHODS,
|
|
6
6
|
getMeta,
|
|
7
7
|
setMeta
|
|
8
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
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":";;;;;AAEA,SAASA,SAASC,eAAe;;;ACA1B,IAAMC,eAAeC,uBAAOC,IAAI,uBAAA;AAChC,IAAMC,kBAAkBF,uBAAOC,IAAI,0BAAA;AACnC,IAAME,iBAAiBH,uBAAOC,IAAI,wBAAA;AAClC,IAAMG,cAAcJ,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,QAAgB;AACxC,SAAOE,QAAoBP,eAAeK,MAAAA,KAAW,CAAA;AACvD;AAFgBI;","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"]}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getCompactionConfig,
|
|
14
14
|
getContextWindowConfig,
|
|
15
15
|
getGatewayConfig,
|
|
16
|
+
getGuardrailsConfig,
|
|
16
17
|
getHumanInTheLoopConfig,
|
|
17
18
|
getMcpConfig,
|
|
18
19
|
getMemoryConfig,
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
getProjectContextConfig,
|
|
22
23
|
getSkillsConfig,
|
|
23
24
|
getSubAgents
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-MD35WBR4.js";
|
|
25
26
|
import {
|
|
26
27
|
__name
|
|
27
28
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -214,6 +215,7 @@ function walkAgentMetadata(AgentClass, toolboxClasses = []) {
|
|
|
214
215
|
const memory = getMemoryConfig(AgentClass);
|
|
215
216
|
const skills = getSkillsConfig(AgentClass);
|
|
216
217
|
const mcpServers = getMcpConfig(AgentClass);
|
|
218
|
+
const guardrails = getGuardrailsConfig(AgentClass);
|
|
217
219
|
const contextWindow = getContextWindowConfig(AgentClass);
|
|
218
220
|
const projectContext = getProjectContextConfig(AgentClass);
|
|
219
221
|
warnUnmappedDecoratorKnobs(AgentClass.name, contextWindow, projectContext);
|
|
@@ -235,6 +237,7 @@ function walkAgentMetadata(AgentClass, toolboxClasses = []) {
|
|
|
235
237
|
contextWindow,
|
|
236
238
|
projectContext,
|
|
237
239
|
mcpServers,
|
|
240
|
+
guardrails,
|
|
238
241
|
compaction,
|
|
239
242
|
checkpoint
|
|
240
243
|
};
|
|
@@ -342,6 +345,7 @@ function compileAgent(walkResult, toolboxInstances = /* @__PURE__ */ new Map())
|
|
|
342
345
|
context: walkResult.contextWindow ? compileContextWindow(walkResult.contextWindow).context : void 0,
|
|
343
346
|
projectContext: walkResult.projectContext,
|
|
344
347
|
mcpServers: walkResult.mcpServers,
|
|
348
|
+
guardrails: walkResult.guardrails,
|
|
345
349
|
maxIterations: walkResult.mainLoop.maxIterations ?? walkResult.agentConfig.maxIterations,
|
|
346
350
|
timeoutMs: walkResult.mainLoop.timeoutMs ?? walkResult.agentConfig.timeoutMs,
|
|
347
351
|
stream: walkResult.agentConfig.stream ?? true,
|
|
@@ -800,6 +804,63 @@ async function* extractThinkTagStream(source) {
|
|
|
800
804
|
}
|
|
801
805
|
__name(extractThinkTagStream, "extractThinkTagStream");
|
|
802
806
|
|
|
807
|
+
// src/bridge/sdk-adapter-create-options.ts
|
|
808
|
+
function assembleM8CreateOptions(compiled) {
|
|
809
|
+
const options = {};
|
|
810
|
+
const applied = [];
|
|
811
|
+
const base = compiled.systemPrompt;
|
|
812
|
+
if (compiled.skills) {
|
|
813
|
+
options.skills = compiled.skills;
|
|
814
|
+
options.local = {
|
|
815
|
+
settingSources: [
|
|
816
|
+
"project"
|
|
817
|
+
]
|
|
818
|
+
};
|
|
819
|
+
applied.push("skills");
|
|
820
|
+
}
|
|
821
|
+
if (compiled.context) {
|
|
822
|
+
options.context = compiled.context;
|
|
823
|
+
applied.push("context");
|
|
824
|
+
}
|
|
825
|
+
if (compiled.projectContext) {
|
|
826
|
+
options.systemPrompt = compileProjectContext(compiled.projectContext, base);
|
|
827
|
+
applied.push("projectContext");
|
|
828
|
+
} else if (base !== void 0) {
|
|
829
|
+
options.systemPrompt = base;
|
|
830
|
+
}
|
|
831
|
+
if (compiled.mcpServers && Object.keys(compiled.mcpServers).length > 0) {
|
|
832
|
+
options.mcpServers = compiled.mcpServers;
|
|
833
|
+
applied.push("mcpServers");
|
|
834
|
+
}
|
|
835
|
+
return {
|
|
836
|
+
options,
|
|
837
|
+
applied
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
__name(assembleM8CreateOptions, "assembleM8CreateOptions");
|
|
841
|
+
function realUsageDone(result, t0) {
|
|
842
|
+
const u = result.usage;
|
|
843
|
+
const inputTokens = u?.inputTokens ?? 0;
|
|
844
|
+
const outputTokens = u?.outputTokens ?? 0;
|
|
845
|
+
return {
|
|
846
|
+
type: "done",
|
|
847
|
+
result: result.result ?? "",
|
|
848
|
+
// V4-O: forward the SDK reasoning/cache buckets (0 when the provider omits them) so a
|
|
849
|
+
// consumer keeps full per-turn usage through the loop into DelegationResult (passthrough — ADR D1).
|
|
850
|
+
usage: {
|
|
851
|
+
inputTokens,
|
|
852
|
+
outputTokens,
|
|
853
|
+
totalTokens: inputTokens + outputTokens,
|
|
854
|
+
reasoningTokens: u?.reasoningTokens ?? 0,
|
|
855
|
+
cacheReadTokens: u?.cacheReadTokens ?? 0,
|
|
856
|
+
cacheWriteTokens: u?.cacheWriteTokens ?? 0
|
|
857
|
+
},
|
|
858
|
+
durationMs: Date.now() - t0,
|
|
859
|
+
cost: result.cost?.amount ?? 0
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
__name(realUsageDone, "realUsageDone");
|
|
863
|
+
|
|
803
864
|
// src/bridge/tool-dialect-stripper.ts
|
|
804
865
|
var OPEN2 = "<function=";
|
|
805
866
|
var CLOSE2 = "</tool_call>";
|
|
@@ -899,57 +960,6 @@ async function* stripToolDialectStream(source) {
|
|
|
899
960
|
__name(stripToolDialectStream, "stripToolDialectStream");
|
|
900
961
|
|
|
901
962
|
// src/bridge/sdk-adapter.ts
|
|
902
|
-
function assembleM8CreateOptions(compiled) {
|
|
903
|
-
const options = {};
|
|
904
|
-
const applied = [];
|
|
905
|
-
const base = compiled.systemPrompt;
|
|
906
|
-
if (compiled.skills) {
|
|
907
|
-
options.skills = compiled.skills;
|
|
908
|
-
options.local = {
|
|
909
|
-
settingSources: [
|
|
910
|
-
"project"
|
|
911
|
-
]
|
|
912
|
-
};
|
|
913
|
-
applied.push("skills");
|
|
914
|
-
}
|
|
915
|
-
if (compiled.context) {
|
|
916
|
-
options.context = compiled.context;
|
|
917
|
-
applied.push("context");
|
|
918
|
-
}
|
|
919
|
-
if (compiled.projectContext) {
|
|
920
|
-
options.systemPrompt = compileProjectContext(compiled.projectContext, base);
|
|
921
|
-
applied.push("projectContext");
|
|
922
|
-
} else if (base !== void 0) {
|
|
923
|
-
options.systemPrompt = base;
|
|
924
|
-
}
|
|
925
|
-
return {
|
|
926
|
-
options,
|
|
927
|
-
applied
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
__name(assembleM8CreateOptions, "assembleM8CreateOptions");
|
|
931
|
-
function realUsageDone(result, t0) {
|
|
932
|
-
const u = result.usage;
|
|
933
|
-
const inputTokens = u?.inputTokens ?? 0;
|
|
934
|
-
const outputTokens = u?.outputTokens ?? 0;
|
|
935
|
-
return {
|
|
936
|
-
type: "done",
|
|
937
|
-
result: result.result ?? "",
|
|
938
|
-
// V4-O: forward the SDK reasoning/cache buckets (0 when the provider omits them) so a
|
|
939
|
-
// consumer keeps full per-turn usage through the loop into DelegationResult (passthrough — ADR D1).
|
|
940
|
-
usage: {
|
|
941
|
-
inputTokens,
|
|
942
|
-
outputTokens,
|
|
943
|
-
totalTokens: inputTokens + outputTokens,
|
|
944
|
-
reasoningTokens: u?.reasoningTokens ?? 0,
|
|
945
|
-
cacheReadTokens: u?.cacheReadTokens ?? 0,
|
|
946
|
-
cacheWriteTokens: u?.cacheWriteTokens ?? 0
|
|
947
|
-
},
|
|
948
|
-
durationMs: Date.now() - t0,
|
|
949
|
-
cost: result.cost?.amount ?? 0
|
|
950
|
-
};
|
|
951
|
-
}
|
|
952
|
-
__name(realUsageDone, "realUsageDone");
|
|
953
963
|
function withLeakedDialectRecovery(providers) {
|
|
954
964
|
return {
|
|
955
965
|
...providers,
|
|
@@ -2916,4 +2926,4 @@ export {
|
|
|
2916
2926
|
generateAgentManifest,
|
|
2917
2927
|
agentsPlugin
|
|
2918
2928
|
};
|
|
2919
|
-
//# sourceMappingURL=chunk-
|
|
2929
|
+
//# sourceMappingURL=chunk-TXEY3IUO.js.map
|