@theokit/agents 0.3.0 → 0.4.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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ExecutionContext } from '@theokit/http-decorators';
2
- import { A as AgentOptions, T as ToolOptions, c as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, b as GatewayOptions, h as MemoryOptions, m as SkillsOptions, f as McpServersMap } from './mcp-DmtwLSF-.js';
1
+ import { ExecutionContext } from '@theokit/http';
2
+ import { A as AgentOptions, T as ToolOptions, c as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, b as GatewayOptions, h as MemoryOptions, m as SkillsOptions, f as McpServersMap } from './mcp-yyfC5u7t.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
@@ -36,6 +36,15 @@ declare function isAgentContext(ctx: ExecutionContext): ctx is AgentExecutionCon
36
36
  * EC-4: throws on duplicate routes across agents.
37
37
  */
38
38
 
39
+ /**
40
+ * Stable warning codes for agent pipeline metadata-only decorators.
41
+ * Test by code, not by message string. Document in agent support matrix.
42
+ */
43
+ declare const AgentWarningCode: {
44
+ readonly INTERCEPTOR_METADATA_ONLY: "THEO_AGENT_INTERCEPTOR_METADATA_ONLY";
45
+ readonly FILTER_METADATA_ONLY: "THEO_AGENT_FILTER_METADATA_ONLY";
46
+ readonly BUDGET_TOP_LEVEL_METADATA_ONLY: "THEO_AGENT_BUDGET_TOP_LEVEL_METADATA_ONLY";
47
+ };
39
48
  interface AgentWalkResult {
40
49
  agentConfig: AgentOptions;
41
50
  mainLoop: MainLoopMeta;
@@ -291,18 +300,48 @@ interface AgentRouteContext {
291
300
  declare function generateAgentRoutes(ctx: AgentRouteContext): AgentRoute[];
292
301
 
293
302
  /**
294
- * Real LLM Agent Runner v1.1 all 7 dogfood gaps fixed.
303
+ * SDK Adapter bridges @theokit/agents decorators @theokit/sdk runtime.
295
304
  *
296
- * 1. Token-by-token streaming (stream: true + SSE delta parsing + EC-1 buffer safety)
297
- * 2. Multi-turn conversation (session Map + EC-2 TTL eviction)
298
- * 3. Model from decorator metadata (EC-5 provider prefix auto-detect)
299
- * 4. Consistent tool names (dot underscore bidirectional mapping)
300
- * 5. Robust Zod→JSON Schema via Zod v4 native z.toJSONSchema()
301
- * 6. Budget enforcement (per-session cost tracking from EC-3 last-chunk usage)
302
- * 7. AbortController cancel (EC-4 race-safe signal.aborted check)
305
+ * Per rule sdk-runtime.md (INQUEBRÁVEL): @theokit/sdk is the ONLY agent runtime.
306
+ * This adapter replaces llm-runner.ts (which called OpenRouter API directly).
307
+ *
308
+ * Flow: @Agent decorator compileAgent() createSdkAgentStream() SDK Agent.create() → Run.stream()
303
309
  */
304
310
 
305
- declare function createRealAgentStream(agentWalk: AgentWalkResult, compiledTools: CompiledTool[], apiKey: string, envModel?: string): (message: string, sessionId: string) => AsyncIterable<StreamEvent>;
311
+ /**
312
+ * Creates an agent stream factory using @theokit/sdk as the runtime.
313
+ *
314
+ * Returns a function that, given a message + sessionId, yields TheoKit
315
+ * AgentStreamEvent via the SDK's Agent.create() + Run.stream() pipeline.
316
+ */
317
+ declare function createSdkAgentStream(agentWalk: AgentWalkResult, compiledTools: CompiledTool[], apiKey: string, envModel?: string): (message: string, _sessionId: string) => AsyncIterable<StreamEvent>;
318
+
319
+ /**
320
+ * Translates @theokit/sdk SDKMessage events → TheoKit AgentStreamEvent.
321
+ *
322
+ * The SDK yields SDKMessage (system/assistant/tool_call/thinking/status).
323
+ * TheoKit devtools + SSE handler expect AgentStreamEvent (run_started/text_delta/tool_call/done).
324
+ * This module bridges the two — Adapter pattern (per sdk-integration-blueprint ADR-D2).
325
+ */
326
+
327
+ /** Minimal SDK message shape — duck-typed to avoid hard import of @theokit/sdk types. */
328
+ interface SdkMessage {
329
+ type: string;
330
+ [key: string]: unknown;
331
+ }
332
+ /**
333
+ * Translate a single SDK message to zero or more TheoKit stream events.
334
+ * Returns an array because one SDK message may map to multiple TheoKit events.
335
+ */
336
+ declare function translateSdkEvent(msg: SdkMessage, runId: string): StreamEvent[];
337
+
338
+ /**
339
+ * Multi-agent orchestration runtime.
340
+ *
341
+ * Provides `delegate()` — a function that lets a parent agent invoke a
342
+ * sub-agent and receive its result. Handles budget clamping (D4),
343
+ * tool sharing, and toolbox auto-instantiation (EC-1).
344
+ */
306
345
 
307
346
  interface DelegateOptions {
308
347
  /** Max USD for this sub-agent call. */
@@ -419,7 +458,7 @@ interface AgentsPluginOptions {
419
458
  interface PluginApp {
420
459
  addHook(name: string, fn: (ctx: {
421
460
  request: Request;
422
- }) => Promise<Response | void>): void;
461
+ }) => Promise<Response | undefined>): void;
423
462
  }
424
463
  /**
425
464
  * Create a TheoKit plugin that mounts agent routes.
@@ -430,4 +469,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
430
469
  register(app: PluginApp): void;
431
470
  };
432
471
 
433
- export { type AgentExecutionContext, type AgentManifest, type AgentManifestEntry, type AgentManifestTool, type AgentRoute, type AgentRouteContext, type AgentRunInfo, type AgentStreamEvent, type AgentWalkResult, type AgentsPluginOptions, type ApprovalRequiredEvent, type ArtifactChunkEvent, type ArtifactStartEvent, BudgetExceededError, type CheckpointSavedEvent, type CompiledAgentOptions, type CompiledTool, type DelegateOptions, DelegationError, type DelegationResult, type DoneEvent, type ErrorEvent, type FileEditEvent, type IterationEvent, type RunStartedEvent, type StateUpdateEvent, type StreamEvent, type TextDeltaEvent, type ThinkingEvent, type ToolCallEvent, type ToolResultEvent, type ToolWalkResult, type ToolboxWalkResult, agentsPlugin, compileAgent, compileTools, createAgentExecutionContext, createRealAgentStream, delegate, generateAgentManifest, generateAgentRoutes, isAgentContext, isApprovalRequired, isDone, isError, isTextDelta, isToolCall, isToolResult, streamAgentResponse, validateUniqueRoutes, walkAgentMetadata };
472
+ export { type AgentExecutionContext, type AgentManifest, type AgentManifestEntry, type AgentManifestTool, type AgentRoute, type AgentRouteContext, type AgentRunInfo, type AgentStreamEvent, type AgentWalkResult, AgentWarningCode, type AgentsPluginOptions, type ApprovalRequiredEvent, type ArtifactChunkEvent, type ArtifactStartEvent, BudgetExceededError, type CheckpointSavedEvent, type CompiledAgentOptions, type CompiledTool, type DelegateOptions, DelegationError, type DelegationResult, type DoneEvent, type ErrorEvent, type FileEditEvent, type IterationEvent, type RunStartedEvent, type SdkMessage, type StateUpdateEvent, type StreamEvent, type TextDeltaEvent, type ThinkingEvent, type ToolCallEvent, type ToolResultEvent, type ToolWalkResult, type ToolboxWalkResult, agentsPlugin, compileAgent, compileTools, createAgentExecutionContext, createSdkAgentStream, delegate, generateAgentManifest, generateAgentRoutes, isAgentContext, isApprovalRequired, isDone, isError, isTextDelta, isToolCall, isToolResult, streamAgentResponse, translateSdkEvent, validateUniqueRoutes, walkAgentMetadata };
package/dist/bridge.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import {
2
+ AgentWarningCode,
2
3
  BudgetExceededError,
3
4
  DelegationError,
4
5
  agentsPlugin,
5
6
  compileAgent,
6
7
  compileTools,
7
8
  createAgentExecutionContext,
8
- createRealAgentStream,
9
+ createSdkAgentStream,
9
10
  delegate,
10
11
  generateAgentManifest,
11
12
  generateAgentRoutes,
@@ -17,18 +18,21 @@ import {
17
18
  isToolCall,
18
19
  isToolResult,
19
20
  streamAgentResponse,
21
+ translateSdkEvent,
20
22
  validateUniqueRoutes,
21
23
  walkAgentMetadata
22
- } from "./chunk-SWPOX3LR.js";
23
- import "./chunk-3LCIXX3T.js";
24
+ } from "./chunk-NC5EE7HN.js";
25
+ import "./chunk-O4UG4RXE.js";
26
+ import "./chunk-7QVYU63E.js";
24
27
  export {
28
+ AgentWarningCode,
25
29
  BudgetExceededError,
26
30
  DelegationError,
27
31
  agentsPlugin,
28
32
  compileAgent,
29
33
  compileTools,
30
34
  createAgentExecutionContext,
31
- createRealAgentStream,
35
+ createSdkAgentStream,
32
36
  delegate,
33
37
  generateAgentManifest,
34
38
  generateAgentRoutes,
@@ -40,6 +44,7 @@ export {
40
44
  isToolCall,
41
45
  isToolResult,
42
46
  streamAgentResponse,
47
+ translateSdkEvent,
43
48
  validateUniqueRoutes,
44
49
  walkAgentMetadata
45
50
  };
@@ -0,0 +1,7 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ export {
5
+ __name
6
+ };
7
+ //# sourceMappingURL=chunk-7QVYU63E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}