@limo-labs/deity 0.2.1 → 0.3.0-alpha.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/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ZodSchema, z } from 'zod';
2
- import { V as Validator, T as ToolSpec, A as AgentNode, P as PromptNode, E as ExecutionContext$1, S as SystemNode, U as UserNode, L as LLMLoopResult, O as ObserveNode, R as ResultNode, a as ValidationRules, b as ValidateNode, c as RetryNode, d as ToolDefNode, e as ToolsNode, f as ToolRefNode, W as WorkflowChildNode, g as WorkflowSequenceNode, h as WorkflowParallelNode, i as WorkflowConditionalNode, j as WorkflowLoopNode, k as WorkflowForEachNode, l as WorkflowNode, m as AgentComponent, n as WorkflowConfig, o as ExecutionNode, p as ASTNode, M as Message, q as ValidationResult$1, r as LLMAdapter$1, G as GenerationConfig$1, s as StateStore$1, t as TraceLogger, u as TraceEntry, v as ExecutionStats, C as ConversationManager, w as LimoMemoryManager, x as UIUpdateBridge, y as SessionStore, z as ConversationConfig, B as MemoryConfig, D as SessionConfig } from './jsx-dev-runtime-Dg782FK5.cjs';
3
- export { J as JSXComponent, F as JSXElementType, H as JSXProps, I as LLMLoopState, K as LLMResponse, N as MessageRole, Q as TemplatePart, X as ToolCall, Y as ToolResult, Z as ValidationRule, _ as isAgentNode, $ as isObserveNode, a0 as isPromptNode, a1 as isResultNode, a2 as isRetryNode, a3 as isSystemNode, a4 as isToolDefNode, a5 as isToolRefNode, a6 as isToolsNode, a7 as isUserNode, a8 as isValidateNode, a9 as isWorkflowConditionalNode, aa as isWorkflowForEachNode, ab as isWorkflowLoopNode, ac as isWorkflowNode, ad as isWorkflowParallelNode, ae as isWorkflowSequenceNode } from './jsx-dev-runtime-Dg782FK5.cjs';
2
+ import { V as Validator, T as ToolSpec, A as AgentNode, P as PromptNode, E as ExecutionContext$1, S as SystemNode, U as UserNode, L as LLMLoopResult, O as ObserveNode, R as ResultNode, a as ValidationRules, b as ValidateNode, c as RetryNode, d as ToolDefNode, e as ToolsNode, f as ToolRefNode, W as WorkflowChildNode, g as WorkflowSequenceNode, h as WorkflowParallelNode, i as WorkflowConditionalNode, j as WorkflowLoopNode, k as WorkflowForEachNode, l as WorkflowNode, m as AgentComponent, n as WorkflowConfig, o as ExecutionNode, p as ASTNode, M as Message, q as ValidationResult$1, r as LLMAdapter$1, G as GenerationConfig$1, s as StateStore$1, t as TraceLogger, u as TraceEntry, v as ExecutionStats, C as ConversationManager, w as LimoMemoryManager, x as UIUpdateBridge, y as SessionStore, z as ConversationConfig, B as MemoryConfig, D as SessionConfig } from './jsx-dev-runtime-BQMsrQII.cjs';
3
+ export { J as JSXComponent, F as JSXElementType, H as JSXProps, I as LLMLoopState, K as LLMResponse, N as MessageRole, Q as TemplatePart, X as ToolCall, Y as ToolResult, Z as ValidationRule, _ as isAgentNode, $ as isObserveNode, a0 as isPromptNode, a1 as isResultNode, a2 as isRetryNode, a3 as isSystemNode, a4 as isToolDefNode, a5 as isToolRefNode, a6 as isToolsNode, a7 as isUserNode, a8 as isValidateNode, a9 as isWorkflowConditionalNode, aa as isWorkflowForEachNode, ab as isWorkflowLoopNode, ac as isWorkflowNode, ad as isWorkflowParallelNode, ae as isWorkflowSequenceNode } from './jsx-dev-runtime-BQMsrQII.cjs';
4
4
 
5
5
  /**
6
6
  * Deity TSX - Agent Component
@@ -37,6 +37,8 @@ interface AgentProps<I = unknown, O = unknown> {
37
37
  loopConfig?: LLMLoopConfig$1;
38
38
  /** Optional tool definitions (backward compatible - can also use <Tools> child) */
39
39
  tools?: ToolSpec[];
40
+ /** Execution mode: 'llm' (default) requires LLM adapter, 'pure' skips LLM */
41
+ mode?: 'llm' | 'pure';
40
42
  /** Child components (Tools, Prompt, Observe, Result, Validate, Retry) */
41
43
  children?: any[];
42
44
  }
@@ -2359,7 +2361,7 @@ declare class DebugLogger {
2359
2361
  declare const logger: DebugLogger;
2360
2362
 
2361
2363
  /**
2362
- * Deity 4.0 - Retry Mechanism
2364
+ * Deity - Retry Mechanism
2363
2365
  *
2364
2366
  * Validation-based retry with dynamic stop conditions
2365
2367
  */
@@ -2383,11 +2385,15 @@ interface RetryExecutionResult<O> {
2383
2385
  }
2384
2386
 
2385
2387
  /**
2386
- * Deity 4.0 - Component Executor
2388
+ * Deity -Component Executor
2387
2389
  *
2388
2390
  * Orchestrates AgentComponent execution
2389
2391
  */
2390
2392
 
2393
+ /**
2394
+ * Empty LLM loop result for pure-function agents that skip LLM execution
2395
+ */
2396
+ declare const EMPTY_LLM_RESULT: LLMLoopResult;
2391
2397
  /**
2392
2398
  * Result from component execution
2393
2399
  */
@@ -2419,7 +2425,7 @@ interface ComponentExecutionResult<O> {
2419
2425
  declare function executeComponent<I, O>(component: AgentComponent<I, O>, ctx: ExecutionContext$1<I>, adapter: LLMAdapter$1, config?: GenerationConfig$1): Promise<ComponentExecutionResult<O>>;
2420
2426
 
2421
2427
  /**
2422
- * Deity 4.0 - LLM Execution Loop
2428
+ * Deity - LLM Execution Loop
2423
2429
  *
2424
2430
  * Handles LLM calls with tool execution loop.
2425
2431
  *
@@ -2459,6 +2465,12 @@ interface LLMLoopConfig {
2459
2465
  /** Memory injection configuration */
2460
2466
  memoryInjection?: MemoryInjectionConfig;
2461
2467
  }
2468
+ /**
2469
+ * Deadline prompt injected when timeout or maxToolRounds is reached.
2470
+ * Instructs the LLM to immediately provide its final answer without further tool calls.
2471
+ * Exported for testing and external customization.
2472
+ */
2473
+ declare const DEADLINE_PROMPT = "\u26A0\uFE0F DEADLINE REACHED: You have reached the maximum allowed rounds or time limit. You MUST immediately provide your final answer based on the information gathered so far. Do NOT call any more tools. Respond with your best final output NOW.";
2462
2474
  /**
2463
2475
  * Execute LLM with tool calling loop
2464
2476
  *
@@ -2479,7 +2491,7 @@ interface LLMLoopConfig {
2479
2491
  declare function executeLLMLoop(adapter: LLMAdapter$1, initialMessages: Message[], tools: ToolSpec[] | undefined, config: GenerationConfig$1 | undefined, ctx: ExecutionContext$1, loopConfig?: LLMLoopConfig, validator?: Validator): Promise<LLMLoopResult>;
2480
2492
 
2481
2493
  /**
2482
- * Deity 4.0 - Workflow Runner
2494
+ * Deity - Workflow Runner
2483
2495
  *
2484
2496
  * Orchestrates workflow execution with checkpoint/resume
2485
2497
  */
@@ -2568,7 +2580,7 @@ declare function createConditionalNode(condition: (ctx: ExecutionContext$1) => b
2568
2580
  declare function createLoopNode(child: ExecutionNode, maxIterations: number): ExecutionNode;
2569
2581
 
2570
2582
  /**
2571
- * Deity 4.0 - In-Memory Stores
2583
+ * Deity - In-Memory Stores
2572
2584
  *
2573
2585
  * Simple in-memory implementations for testing
2574
2586
  */
@@ -2601,7 +2613,7 @@ declare class InMemoryTrace implements TraceLogger {
2601
2613
  }
2602
2614
 
2603
2615
  /**
2604
- * Deity 4.0 - Enhanced Execution Context
2616
+ * Deity -Enhanced Execution Context
2605
2617
  *
2606
2618
  * Unified context with integrated managers:
2607
2619
  * - ConversationManager (Phase 2)
@@ -2772,7 +2784,7 @@ declare class ExecutionContext<I = unknown> implements ExecutionContext$1<I> {
2772
2784
  }
2773
2785
 
2774
2786
  /**
2775
- * Deity 4.0 - Context Factory
2787
+ * Deity - Context Factory
2776
2788
  *
2777
2789
  * Factory functions for creating ExecutionContext instances
2778
2790
  */
@@ -2815,4 +2827,4 @@ interface ContextConfig<I = unknown> {
2815
2827
  */
2816
2828
  declare function createEnhancedContext<I = unknown>(config: ContextConfig<I>): Promise<ExecutionContext<I>>;
2817
2829
 
2818
- export { ASTNode, Agent, AgentComponent, AgentNode, type AgentProps, Conditional, type ConditionalProps, DEBUG_ENABLED, DebugLogger, type ErrorMode, ExecutionContext$1 as ExecutionContext, ForEach, type ForEachProps, type ForEachResult, type FullAgentTestOptions, type FullAgentTestResult, GenerationConfig$1 as GenerationConfig, InMemoryStore, InMemoryTrace, type ItemMode, LLMAdapter$1 as LLMAdapter, type LLMLoopConfig, LLMLoopResult, type LogLevel, Loop, type LoopProps, Message, Observe, type ObserveFunction, ObserveNode, type ObserveProps, ObserveUtils, Parallel, type ParallelProps, PreflightChecker, type PreflightResult, Prompt, PromptNode, type PromptProps, PromptResourceLoader, Result, ResultNode, type ResultProps, ResultUtils, Retry, type RetryContext, RetryNode, type RetryProps, RetryUtils, Sequence, type SequenceProps, StateStore$1 as StateStore, System, SystemNode, type SystemProps, Tool, ToolDef, ToolDefNode, type ToolDefProps, type ToolProps, ToolRef, ToolRefNode, type ToolRefProps, type ToolRefTarget, ToolSpec, Tools, ToolsNode, type ToolsProps, TraceLogger, User, UserNode, type UserProps, Validate, ValidateNode, type ValidateProps, ValidateUtils, type ValidationResult, ValidationRules, Validator, Workflow, WorkflowChildNode, WorkflowConditionalNode, type WorkflowEnhancements, WorkflowForEachNode, type GenerationConfig as WorkflowGenerationConfig, type LLMAdapter as WorkflowLLMAdapter, WorkflowLoopNode, WorkflowNode, WorkflowParallelNode, type WorkflowProps, WorkflowSequenceNode, type StateStore as WorkflowStateStore, compileAgent, compileWorkflow, compileWorkflowNode, createConditionalNode, createEnhancedContext, createLoopNode, createParallelNode, createSequenceNode, createStepNode, executeComponent, executeLLMLoop, getResourceLoader, logger, preflight, runTSXWorkflow, runWorkflow, setResourceLoader, testFullAgent, toAgent, toWorkflow };
2830
+ export { ASTNode, Agent, AgentComponent, AgentNode, type AgentProps, Conditional, type ConditionalProps, DEADLINE_PROMPT, DEBUG_ENABLED, DebugLogger, EMPTY_LLM_RESULT, type ErrorMode, ExecutionContext$1 as ExecutionContext, ForEach, type ForEachProps, type ForEachResult, type FullAgentTestOptions, type FullAgentTestResult, GenerationConfig$1 as GenerationConfig, InMemoryStore, InMemoryTrace, type ItemMode, LLMAdapter$1 as LLMAdapter, type LLMLoopConfig, LLMLoopResult, type LogLevel, Loop, type LoopProps, Message, Observe, type ObserveFunction, ObserveNode, type ObserveProps, ObserveUtils, Parallel, type ParallelProps, PreflightChecker, type PreflightResult, Prompt, PromptNode, type PromptProps, PromptResourceLoader, Result, ResultNode, type ResultProps, ResultUtils, Retry, type RetryContext, RetryNode, type RetryProps, RetryUtils, Sequence, type SequenceProps, StateStore$1 as StateStore, System, SystemNode, type SystemProps, Tool, ToolDef, ToolDefNode, type ToolDefProps, type ToolProps, ToolRef, ToolRefNode, type ToolRefProps, type ToolRefTarget, ToolSpec, Tools, ToolsNode, type ToolsProps, TraceLogger, User, UserNode, type UserProps, Validate, ValidateNode, type ValidateProps, ValidateUtils, type ValidationResult, ValidationRules, Validator, Workflow, WorkflowChildNode, WorkflowConditionalNode, type WorkflowEnhancements, WorkflowForEachNode, type GenerationConfig as WorkflowGenerationConfig, type LLMAdapter as WorkflowLLMAdapter, WorkflowLoopNode, WorkflowNode, WorkflowParallelNode, type WorkflowProps, WorkflowSequenceNode, type StateStore as WorkflowStateStore, compileAgent, compileWorkflow, compileWorkflowNode, createConditionalNode, createEnhancedContext, createLoopNode, createParallelNode, createSequenceNode, createStepNode, executeComponent, executeLLMLoop, getResourceLoader, logger, preflight, runTSXWorkflow, runWorkflow, setResourceLoader, testFullAgent, toAgent, toWorkflow };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ZodSchema, z } from 'zod';
2
- import { V as Validator, T as ToolSpec, A as AgentNode, P as PromptNode, E as ExecutionContext$1, S as SystemNode, U as UserNode, L as LLMLoopResult, O as ObserveNode, R as ResultNode, a as ValidationRules, b as ValidateNode, c as RetryNode, d as ToolDefNode, e as ToolsNode, f as ToolRefNode, W as WorkflowChildNode, g as WorkflowSequenceNode, h as WorkflowParallelNode, i as WorkflowConditionalNode, j as WorkflowLoopNode, k as WorkflowForEachNode, l as WorkflowNode, m as AgentComponent, n as WorkflowConfig, o as ExecutionNode, p as ASTNode, M as Message, q as ValidationResult$1, r as LLMAdapter$1, G as GenerationConfig$1, s as StateStore$1, t as TraceLogger, u as TraceEntry, v as ExecutionStats, C as ConversationManager, w as LimoMemoryManager, x as UIUpdateBridge, y as SessionStore, z as ConversationConfig, B as MemoryConfig, D as SessionConfig } from './jsx-dev-runtime-Dg782FK5.js';
3
- export { J as JSXComponent, F as JSXElementType, H as JSXProps, I as LLMLoopState, K as LLMResponse, N as MessageRole, Q as TemplatePart, X as ToolCall, Y as ToolResult, Z as ValidationRule, _ as isAgentNode, $ as isObserveNode, a0 as isPromptNode, a1 as isResultNode, a2 as isRetryNode, a3 as isSystemNode, a4 as isToolDefNode, a5 as isToolRefNode, a6 as isToolsNode, a7 as isUserNode, a8 as isValidateNode, a9 as isWorkflowConditionalNode, aa as isWorkflowForEachNode, ab as isWorkflowLoopNode, ac as isWorkflowNode, ad as isWorkflowParallelNode, ae as isWorkflowSequenceNode } from './jsx-dev-runtime-Dg782FK5.js';
2
+ import { V as Validator, T as ToolSpec, A as AgentNode, P as PromptNode, E as ExecutionContext$1, S as SystemNode, U as UserNode, L as LLMLoopResult, O as ObserveNode, R as ResultNode, a as ValidationRules, b as ValidateNode, c as RetryNode, d as ToolDefNode, e as ToolsNode, f as ToolRefNode, W as WorkflowChildNode, g as WorkflowSequenceNode, h as WorkflowParallelNode, i as WorkflowConditionalNode, j as WorkflowLoopNode, k as WorkflowForEachNode, l as WorkflowNode, m as AgentComponent, n as WorkflowConfig, o as ExecutionNode, p as ASTNode, M as Message, q as ValidationResult$1, r as LLMAdapter$1, G as GenerationConfig$1, s as StateStore$1, t as TraceLogger, u as TraceEntry, v as ExecutionStats, C as ConversationManager, w as LimoMemoryManager, x as UIUpdateBridge, y as SessionStore, z as ConversationConfig, B as MemoryConfig, D as SessionConfig } from './jsx-dev-runtime-BQMsrQII.js';
3
+ export { J as JSXComponent, F as JSXElementType, H as JSXProps, I as LLMLoopState, K as LLMResponse, N as MessageRole, Q as TemplatePart, X as ToolCall, Y as ToolResult, Z as ValidationRule, _ as isAgentNode, $ as isObserveNode, a0 as isPromptNode, a1 as isResultNode, a2 as isRetryNode, a3 as isSystemNode, a4 as isToolDefNode, a5 as isToolRefNode, a6 as isToolsNode, a7 as isUserNode, a8 as isValidateNode, a9 as isWorkflowConditionalNode, aa as isWorkflowForEachNode, ab as isWorkflowLoopNode, ac as isWorkflowNode, ad as isWorkflowParallelNode, ae as isWorkflowSequenceNode } from './jsx-dev-runtime-BQMsrQII.js';
4
4
 
5
5
  /**
6
6
  * Deity TSX - Agent Component
@@ -37,6 +37,8 @@ interface AgentProps<I = unknown, O = unknown> {
37
37
  loopConfig?: LLMLoopConfig$1;
38
38
  /** Optional tool definitions (backward compatible - can also use <Tools> child) */
39
39
  tools?: ToolSpec[];
40
+ /** Execution mode: 'llm' (default) requires LLM adapter, 'pure' skips LLM */
41
+ mode?: 'llm' | 'pure';
40
42
  /** Child components (Tools, Prompt, Observe, Result, Validate, Retry) */
41
43
  children?: any[];
42
44
  }
@@ -2359,7 +2361,7 @@ declare class DebugLogger {
2359
2361
  declare const logger: DebugLogger;
2360
2362
 
2361
2363
  /**
2362
- * Deity 4.0 - Retry Mechanism
2364
+ * Deity - Retry Mechanism
2363
2365
  *
2364
2366
  * Validation-based retry with dynamic stop conditions
2365
2367
  */
@@ -2383,11 +2385,15 @@ interface RetryExecutionResult<O> {
2383
2385
  }
2384
2386
 
2385
2387
  /**
2386
- * Deity 4.0 - Component Executor
2388
+ * Deity -Component Executor
2387
2389
  *
2388
2390
  * Orchestrates AgentComponent execution
2389
2391
  */
2390
2392
 
2393
+ /**
2394
+ * Empty LLM loop result for pure-function agents that skip LLM execution
2395
+ */
2396
+ declare const EMPTY_LLM_RESULT: LLMLoopResult;
2391
2397
  /**
2392
2398
  * Result from component execution
2393
2399
  */
@@ -2419,7 +2425,7 @@ interface ComponentExecutionResult<O> {
2419
2425
  declare function executeComponent<I, O>(component: AgentComponent<I, O>, ctx: ExecutionContext$1<I>, adapter: LLMAdapter$1, config?: GenerationConfig$1): Promise<ComponentExecutionResult<O>>;
2420
2426
 
2421
2427
  /**
2422
- * Deity 4.0 - LLM Execution Loop
2428
+ * Deity - LLM Execution Loop
2423
2429
  *
2424
2430
  * Handles LLM calls with tool execution loop.
2425
2431
  *
@@ -2459,6 +2465,12 @@ interface LLMLoopConfig {
2459
2465
  /** Memory injection configuration */
2460
2466
  memoryInjection?: MemoryInjectionConfig;
2461
2467
  }
2468
+ /**
2469
+ * Deadline prompt injected when timeout or maxToolRounds is reached.
2470
+ * Instructs the LLM to immediately provide its final answer without further tool calls.
2471
+ * Exported for testing and external customization.
2472
+ */
2473
+ declare const DEADLINE_PROMPT = "\u26A0\uFE0F DEADLINE REACHED: You have reached the maximum allowed rounds or time limit. You MUST immediately provide your final answer based on the information gathered so far. Do NOT call any more tools. Respond with your best final output NOW.";
2462
2474
  /**
2463
2475
  * Execute LLM with tool calling loop
2464
2476
  *
@@ -2479,7 +2491,7 @@ interface LLMLoopConfig {
2479
2491
  declare function executeLLMLoop(adapter: LLMAdapter$1, initialMessages: Message[], tools: ToolSpec[] | undefined, config: GenerationConfig$1 | undefined, ctx: ExecutionContext$1, loopConfig?: LLMLoopConfig, validator?: Validator): Promise<LLMLoopResult>;
2480
2492
 
2481
2493
  /**
2482
- * Deity 4.0 - Workflow Runner
2494
+ * Deity - Workflow Runner
2483
2495
  *
2484
2496
  * Orchestrates workflow execution with checkpoint/resume
2485
2497
  */
@@ -2568,7 +2580,7 @@ declare function createConditionalNode(condition: (ctx: ExecutionContext$1) => b
2568
2580
  declare function createLoopNode(child: ExecutionNode, maxIterations: number): ExecutionNode;
2569
2581
 
2570
2582
  /**
2571
- * Deity 4.0 - In-Memory Stores
2583
+ * Deity - In-Memory Stores
2572
2584
  *
2573
2585
  * Simple in-memory implementations for testing
2574
2586
  */
@@ -2601,7 +2613,7 @@ declare class InMemoryTrace implements TraceLogger {
2601
2613
  }
2602
2614
 
2603
2615
  /**
2604
- * Deity 4.0 - Enhanced Execution Context
2616
+ * Deity -Enhanced Execution Context
2605
2617
  *
2606
2618
  * Unified context with integrated managers:
2607
2619
  * - ConversationManager (Phase 2)
@@ -2772,7 +2784,7 @@ declare class ExecutionContext<I = unknown> implements ExecutionContext$1<I> {
2772
2784
  }
2773
2785
 
2774
2786
  /**
2775
- * Deity 4.0 - Context Factory
2787
+ * Deity - Context Factory
2776
2788
  *
2777
2789
  * Factory functions for creating ExecutionContext instances
2778
2790
  */
@@ -2815,4 +2827,4 @@ interface ContextConfig<I = unknown> {
2815
2827
  */
2816
2828
  declare function createEnhancedContext<I = unknown>(config: ContextConfig<I>): Promise<ExecutionContext<I>>;
2817
2829
 
2818
- export { ASTNode, Agent, AgentComponent, AgentNode, type AgentProps, Conditional, type ConditionalProps, DEBUG_ENABLED, DebugLogger, type ErrorMode, ExecutionContext$1 as ExecutionContext, ForEach, type ForEachProps, type ForEachResult, type FullAgentTestOptions, type FullAgentTestResult, GenerationConfig$1 as GenerationConfig, InMemoryStore, InMemoryTrace, type ItemMode, LLMAdapter$1 as LLMAdapter, type LLMLoopConfig, LLMLoopResult, type LogLevel, Loop, type LoopProps, Message, Observe, type ObserveFunction, ObserveNode, type ObserveProps, ObserveUtils, Parallel, type ParallelProps, PreflightChecker, type PreflightResult, Prompt, PromptNode, type PromptProps, PromptResourceLoader, Result, ResultNode, type ResultProps, ResultUtils, Retry, type RetryContext, RetryNode, type RetryProps, RetryUtils, Sequence, type SequenceProps, StateStore$1 as StateStore, System, SystemNode, type SystemProps, Tool, ToolDef, ToolDefNode, type ToolDefProps, type ToolProps, ToolRef, ToolRefNode, type ToolRefProps, type ToolRefTarget, ToolSpec, Tools, ToolsNode, type ToolsProps, TraceLogger, User, UserNode, type UserProps, Validate, ValidateNode, type ValidateProps, ValidateUtils, type ValidationResult, ValidationRules, Validator, Workflow, WorkflowChildNode, WorkflowConditionalNode, type WorkflowEnhancements, WorkflowForEachNode, type GenerationConfig as WorkflowGenerationConfig, type LLMAdapter as WorkflowLLMAdapter, WorkflowLoopNode, WorkflowNode, WorkflowParallelNode, type WorkflowProps, WorkflowSequenceNode, type StateStore as WorkflowStateStore, compileAgent, compileWorkflow, compileWorkflowNode, createConditionalNode, createEnhancedContext, createLoopNode, createParallelNode, createSequenceNode, createStepNode, executeComponent, executeLLMLoop, getResourceLoader, logger, preflight, runTSXWorkflow, runWorkflow, setResourceLoader, testFullAgent, toAgent, toWorkflow };
2830
+ export { ASTNode, Agent, AgentComponent, AgentNode, type AgentProps, Conditional, type ConditionalProps, DEADLINE_PROMPT, DEBUG_ENABLED, DebugLogger, EMPTY_LLM_RESULT, type ErrorMode, ExecutionContext$1 as ExecutionContext, ForEach, type ForEachProps, type ForEachResult, type FullAgentTestOptions, type FullAgentTestResult, GenerationConfig$1 as GenerationConfig, InMemoryStore, InMemoryTrace, type ItemMode, LLMAdapter$1 as LLMAdapter, type LLMLoopConfig, LLMLoopResult, type LogLevel, Loop, type LoopProps, Message, Observe, type ObserveFunction, ObserveNode, type ObserveProps, ObserveUtils, Parallel, type ParallelProps, PreflightChecker, type PreflightResult, Prompt, PromptNode, type PromptProps, PromptResourceLoader, Result, ResultNode, type ResultProps, ResultUtils, Retry, type RetryContext, RetryNode, type RetryProps, RetryUtils, Sequence, type SequenceProps, StateStore$1 as StateStore, System, SystemNode, type SystemProps, Tool, ToolDef, ToolDefNode, type ToolDefProps, type ToolProps, ToolRef, ToolRefNode, type ToolRefProps, type ToolRefTarget, ToolSpec, Tools, ToolsNode, type ToolsProps, TraceLogger, User, UserNode, type UserProps, Validate, ValidateNode, type ValidateProps, ValidateUtils, type ValidationResult, ValidationRules, Validator, Workflow, WorkflowChildNode, WorkflowConditionalNode, type WorkflowEnhancements, WorkflowForEachNode, type GenerationConfig as WorkflowGenerationConfig, type LLMAdapter as WorkflowLLMAdapter, WorkflowLoopNode, WorkflowNode, WorkflowParallelNode, type WorkflowProps, WorkflowSequenceNode, type StateStore as WorkflowStateStore, compileAgent, compileWorkflow, compileWorkflowNode, createConditionalNode, createEnhancedContext, createLoopNode, createParallelNode, createSequenceNode, createStepNode, executeComponent, executeLLMLoop, getResourceLoader, logger, preflight, runTSXWorkflow, runWorkflow, setResourceLoader, testFullAgent, toAgent, toWorkflow };
package/dist/index.js CHANGED
@@ -42,7 +42,8 @@ var init_compile_observe = __esm({
42
42
 
43
43
  // src/components/Agent.tsx
44
44
  function Agent(props) {
45
- const { id, input, output, description, tags, loopValidator, loopConfig, tools: propsTools, children } = props;
45
+ const { id, input, output, description, tags, loopValidator, loopConfig, tools: propsTools, mode, children } = props;
46
+ const resolvedMode = mode ?? "llm";
46
47
  if (!id) {
47
48
  throw new Error("Agent: id is required");
48
49
  }
@@ -53,13 +54,31 @@ function Agent(props) {
53
54
  throw new Error("Agent: output schema is required");
54
55
  }
55
56
  if (!children || children.length === 0) {
57
+ if (resolvedMode === "pure") {
58
+ throw new Error("Agent: pure mode must have at least a Result child");
59
+ }
56
60
  throw new Error("Agent: must have at least Prompt and Result children");
57
61
  }
58
62
  const toolsNode = children.find((child) => child?.type === "Tools");
59
63
  const nonToolsChildren = children.filter((child) => child?.type !== "Tools");
60
- const [prompt, ...rest] = nonToolsChildren;
61
- if (!prompt || prompt.type !== "Prompt") {
62
- throw new Error("Agent: first non-Tools child must be a Prompt component");
64
+ let prompt;
65
+ let rest;
66
+ if (resolvedMode === "pure") {
67
+ const firstNonTools = nonToolsChildren[0];
68
+ if (firstNonTools?.type === "Prompt") {
69
+ prompt = firstNonTools;
70
+ rest = nonToolsChildren.slice(1);
71
+ } else {
72
+ prompt = void 0;
73
+ rest = nonToolsChildren;
74
+ }
75
+ } else {
76
+ const [first, ...remaining] = nonToolsChildren;
77
+ if (!first || first.type !== "Prompt") {
78
+ throw new Error("Agent: first non-Tools child must be a Prompt component");
79
+ }
80
+ prompt = first;
81
+ rest = remaining;
63
82
  }
64
83
  const result = rest.find((child) => child?.type === "Result");
65
84
  if (!result) {
@@ -69,9 +88,8 @@ function Agent(props) {
69
88
  const validate = rest.find((child) => child?.type === "Validate");
70
89
  const retry = rest.find((child) => child?.type === "Retry");
71
90
  const mergedTools = mergeTools(propsTools, toolsNode);
72
- const orderedChildren = [
73
- prompt
74
- ];
91
+ const orderedChildren = [];
92
+ if (prompt) orderedChildren.push(prompt);
75
93
  if (observe) orderedChildren.push(observe);
76
94
  orderedChildren.push(result);
77
95
  if (validate) orderedChildren.push(validate);
@@ -87,7 +105,8 @@ function Agent(props) {
87
105
  tags,
88
106
  loopValidator,
89
107
  loopConfig,
90
- tools: mergedTools
108
+ tools: mergedTools,
109
+ mode: resolvedMode
91
110
  },
92
111
  children: orderedChildren
93
112
  };
@@ -1057,13 +1076,14 @@ function compileAgent(ast) {
1057
1076
  const resultNode = children.find((n) => n?.type === "Result");
1058
1077
  const validateNode = children.find((n) => n?.type === "Validate");
1059
1078
  const retryNode = children.find((n) => n?.type === "Retry");
1060
- if (!promptNode) {
1079
+ const mode = ast.props.mode ?? "llm";
1080
+ if (mode !== "pure" && !promptNode) {
1061
1081
  throw new Error("Agent must have a Prompt node");
1062
1082
  }
1063
1083
  if (!resultNode) {
1064
1084
  throw new Error("Agent must have a Result node");
1065
1085
  }
1066
- const buildPrompt = compilePrompt(promptNode);
1086
+ const buildPrompt = promptNode ? compilePrompt(promptNode) : () => [];
1067
1087
  const observe = observeNode ? compileObserve(observeNode) : void 0;
1068
1088
  const extractOutput = compileResult(resultNode, observe);
1069
1089
  const validateOutput = validateNode ? compileValidate(validateNode) : void 0;
@@ -1075,6 +1095,9 @@ function compileAgent(ast) {
1075
1095
  buildPrompt,
1076
1096
  extractOutput
1077
1097
  };
1098
+ if (mode === "pure") {
1099
+ component.mode = "pure";
1100
+ }
1078
1101
  if (validateOutput) {
1079
1102
  component.validateOutput = validateOutput;
1080
1103
  }
@@ -1215,6 +1238,9 @@ function createLazyAgentComponent(astNode) {
1215
1238
  get loopConfig() {
1216
1239
  return astNode.props.loopConfig;
1217
1240
  },
1241
+ get mode() {
1242
+ return astNode.props.mode;
1243
+ },
1218
1244
  // Lazy methods - compile on first call
1219
1245
  buildPrompt(ctx) {
1220
1246
  return ensureCompiled().buildPrompt(ctx);
@@ -2854,6 +2880,7 @@ var DEFAULT_LLM_LOOP_CONFIG = {
2854
2880
  // 2 minutes
2855
2881
  verbose: false
2856
2882
  };
2883
+ var DEADLINE_PROMPT = `\u26A0\uFE0F DEADLINE REACHED: You have reached the maximum allowed rounds or time limit. You MUST immediately provide your final answer based on the information gathered so far. Do NOT call any more tools. Respond with your best final output NOW.`;
2857
2884
  async function executeLLMLoop(adapter, initialMessages, tools, config, ctx, loopConfig = {}, validator) {
2858
2885
  const cfg = { ...DEFAULT_LLM_LOOP_CONFIG, ...loopConfig };
2859
2886
  const messagesWithMemory = await injectRelevantMemories(
@@ -2867,6 +2894,7 @@ async function executeLLMLoop(adapter, initialMessages, tools, config, ctx, loop
2867
2894
  let toolCallsExecuted = 0;
2868
2895
  let response;
2869
2896
  let toolCallsThisRound = [];
2897
+ const startTime = Date.now();
2870
2898
  while (rounds < cfg.maxToolRounds) {
2871
2899
  rounds++;
2872
2900
  toolCallsThisRound = [];
@@ -2914,10 +2942,6 @@ async function executeLLMLoop(adapter, initialMessages, tools, config, ctx, loop
2914
2942
  }
2915
2943
  break;
2916
2944
  }
2917
- if (rounds >= cfg.maxToolRounds) {
2918
- errors.push(`Maximum tool rounds (${cfg.maxToolRounds}) exceeded`);
2919
- break;
2920
- }
2921
2945
  for (const toolCall of response.toolCalls) {
2922
2946
  const alreadyExecuted = toolCall._alreadyExecuted;
2923
2947
  if (alreadyExecuted) {
@@ -2985,6 +3009,23 @@ async function executeLLMLoop(adapter, initialMessages, tools, config, ctx, loop
2985
3009
  if (allPreExecuted) {
2986
3010
  break;
2987
3011
  }
3012
+ const isTimeout = cfg.timeout > 0 && Date.now() - startTime >= cfg.timeout;
3013
+ const isLastRound = rounds >= cfg.maxToolRounds;
3014
+ if (isTimeout || isLastRound) {
3015
+ messages.push({
3016
+ role: "user",
3017
+ content: DEADLINE_PROMPT
3018
+ });
3019
+ try {
3020
+ response = await adapter.generate(messages, void 0, config, ctx);
3021
+ messages.push({ role: "assistant", content: response.content });
3022
+ } catch (_error) {
3023
+ }
3024
+ errors.push(
3025
+ isTimeout ? `Timeout reached (${cfg.timeout}ms)` : `Maximum tool rounds (${cfg.maxToolRounds}) reached`
3026
+ );
3027
+ break;
3028
+ }
2988
3029
  }
2989
3030
  return {
2990
3031
  response,
@@ -3224,6 +3265,17 @@ async function executeWithRetry(component, ctx, executeFn) {
3224
3265
  }
3225
3266
  const shouldRetry = retryConfig.shouldRetry ? retryConfig.shouldRetry(attempts, output, ctx) : attempts < retryConfig.maxAttempts;
3226
3267
  if (!shouldRetry) {
3268
+ const lastOutput = outputHistory[outputHistory.length - 1];
3269
+ if (lastOutput !== void 0) {
3270
+ return {
3271
+ output: lastOutput,
3272
+ success: true,
3273
+ attempts,
3274
+ errors: validation.errors ?? ["Validation failed (used best-effort output)"],
3275
+ validationHistory,
3276
+ outputHistory
3277
+ };
3278
+ }
3227
3279
  return {
3228
3280
  success: false,
3229
3281
  attempts,
@@ -3308,6 +3360,13 @@ function parseComponentOutput(content, schema) {
3308
3360
  }
3309
3361
 
3310
3362
  // src/engine/executor.ts
3363
+ var EMPTY_LLM_RESULT = {
3364
+ response: { content: "" },
3365
+ messages: [],
3366
+ rounds: 0,
3367
+ toolCallsExecuted: 0,
3368
+ errors: []
3369
+ };
3311
3370
  async function executeComponent(component, ctx, adapter, config) {
3312
3371
  const startTime = Date.now();
3313
3372
  const llmResults = [];
@@ -4322,7 +4381,7 @@ z.object({
4322
4381
  sessionId: z.string().min(1, "Session ID cannot be empty"),
4323
4382
  workflowName: z.string().min(1, "Workflow name cannot be empty"),
4324
4383
  pausedAt: z.string().datetime("Must be ISO 8601 datetime"),
4325
- version: z.string().regex(/^\d+\.\d+\.\d+$/, "Must be semver format (e.g., 4.0.0)"),
4384
+ version: z.string().regex(/^\d+\.\d+\.\d+$/, "Must be semver format (e.g., 1.0.0)"),
4326
4385
  state: PausedSessionStateSchema,
4327
4386
  metadata: PausedSessionMetadataSchema
4328
4387
  });
@@ -4338,7 +4397,7 @@ var SessionSerializer = class {
4338
4397
  metadata;
4339
4398
  constructor() {
4340
4399
  this.metadata = {
4341
- version: "4.0.0",
4400
+ version: "1.0.0",
4342
4401
  timestamp: /* @__PURE__ */ new Date(),
4343
4402
  specialFields: []
4344
4403
  };
@@ -5008,6 +5067,9 @@ async function executeStepNode(node, ctx, adapter, config) {
5008
5067
  if (!node.component) {
5009
5068
  throw new Error("Step node missing component");
5010
5069
  }
5070
+ if (node.component.mode === "pure") {
5071
+ return executePureComponent(node.component, ctx);
5072
+ }
5011
5073
  if (!adapter) {
5012
5074
  if (node.component.model?.adapter) {
5013
5075
  adapter = node.component.model.adapter;
@@ -5195,6 +5257,56 @@ function createIterationContext(baseCtx, currentItem, index, totalItems, itemMod
5195
5257
  isLastIteration: index === totalItems - 1
5196
5258
  };
5197
5259
  }
5260
+ async function executePureComponent(component, ctx) {
5261
+ ctx.ui?.startStep(component.id, component.id);
5262
+ await ctx.trace.log({
5263
+ type: "stage_start",
5264
+ stageId: component.id,
5265
+ timestamp: /* @__PURE__ */ new Date()
5266
+ });
5267
+ try {
5268
+ if (!component.extractOutput) {
5269
+ throw new Error(`Pure component '${component.id}' must have extractOutput defined`);
5270
+ }
5271
+ const output = await Promise.resolve(
5272
+ component.extractOutput(ctx, EMPTY_LLM_RESULT)
5273
+ );
5274
+ const schemaResult = component.outputSchema.safeParse(output);
5275
+ if (!schemaResult.success) {
5276
+ const errors = schemaResult.error.issues.map((e) => `${e.path.join(".")}: ${e.message}`).join("; ");
5277
+ throw new Error(`Pure component '${component.id}' output validation failed: ${errors}`);
5278
+ }
5279
+ const validatedOutput = schemaResult.data;
5280
+ if (component.validateOutput) {
5281
+ const validationResult = await Promise.resolve(
5282
+ component.validateOutput(validatedOutput, ctx)
5283
+ );
5284
+ if (!validationResult.valid) {
5285
+ const feedback = validationResult.feedback || validationResult.errors?.join("; ") || "Validation failed";
5286
+ throw new Error(`Pure component '${component.id}' validateOutput failed: ${feedback}`);
5287
+ }
5288
+ }
5289
+ if (ctx instanceof ExecutionContext) {
5290
+ ctx.previousOutputs[component.id] = validatedOutput;
5291
+ }
5292
+ await ctx.trace.log({
5293
+ type: "stage_complete",
5294
+ output: validatedOutput,
5295
+ timestamp: /* @__PURE__ */ new Date()
5296
+ });
5297
+ ctx.ui?.completeStep(component.id, "Pure execution complete");
5298
+ return validatedOutput;
5299
+ } catch (error) {
5300
+ const errorMessage = error instanceof Error ? error.message : String(error);
5301
+ await ctx.trace.log({
5302
+ type: "stage_failed",
5303
+ error: errorMessage,
5304
+ timestamp: /* @__PURE__ */ new Date()
5305
+ });
5306
+ ctx.ui?.failStep(component.id, errorMessage);
5307
+ throw error;
5308
+ }
5309
+ }
5198
5310
  function createStepNode(component) {
5199
5311
  return {
5200
5312
  type: "step",
@@ -5228,6 +5340,6 @@ function createLoopNode(child, maxIterations) {
5228
5340
  };
5229
5341
  }
5230
5342
 
5231
- export { Agent, Conditional, DEBUG_ENABLED, DebugLogger, ForEach, InMemoryStore, InMemoryTrace, Loop, Observe, ObserveUtils, Parallel, PreflightChecker, Prompt, PromptResourceLoader, Result, ResultUtils, Retry, RetryUtils, Sequence, System, Tool, ToolDef, ToolRef, Tools, User, Validate, ValidateUtils, Workflow, compileAgent, compileWorkflow, compileWorkflowNode, createConditionalNode, createEnhancedContext, createLoopNode, createParallelNode, createSequenceNode, createStepNode, executeComponent, executeLLMLoop, getResourceLoader, isAgentNode, isObserveNode, isPromptNode, isResultNode, isRetryNode, isSystemNode, isToolDefNode, isToolRefNode, isToolsNode, isUserNode, isValidateNode, isWorkflowConditionalNode, isWorkflowForEachNode, isWorkflowLoopNode, isWorkflowNode, isWorkflowParallelNode, isWorkflowSequenceNode, logger, preflight, runTSXWorkflow, runWorkflow, setResourceLoader, testFullAgent, toAgent, toWorkflow };
5343
+ export { Agent, Conditional, DEADLINE_PROMPT, DEBUG_ENABLED, DebugLogger, EMPTY_LLM_RESULT, ForEach, InMemoryStore, InMemoryTrace, Loop, Observe, ObserveUtils, Parallel, PreflightChecker, Prompt, PromptResourceLoader, Result, ResultUtils, Retry, RetryUtils, Sequence, System, Tool, ToolDef, ToolRef, Tools, User, Validate, ValidateUtils, Workflow, compileAgent, compileWorkflow, compileWorkflowNode, createConditionalNode, createEnhancedContext, createLoopNode, createParallelNode, createSequenceNode, createStepNode, executeComponent, executeLLMLoop, getResourceLoader, isAgentNode, isObserveNode, isPromptNode, isResultNode, isRetryNode, isSystemNode, isToolDefNode, isToolRefNode, isToolsNode, isUserNode, isValidateNode, isWorkflowConditionalNode, isWorkflowForEachNode, isWorkflowLoopNode, isWorkflowNode, isWorkflowParallelNode, isWorkflowSequenceNode, logger, preflight, runTSXWorkflow, runWorkflow, setResourceLoader, testFullAgent, toAgent, toWorkflow };
5232
5344
  //# sourceMappingURL=index.js.map
5233
5345
  //# sourceMappingURL=index.js.map