@limo-labs/deity 0.2.2 → 0.3.0-alpha.1
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.cjs +124 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +124 -10
- package/dist/index.js.map +1 -1
- package/dist/{jsx-dev-runtime-1R5Vpr7w.d.cts → jsx-dev-runtime-CCicXopP.d.cts} +37 -28
- package/dist/{jsx-dev-runtime-1R5Vpr7w.d.ts → jsx-dev-runtime-CCicXopP.d.ts} +37 -28
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.d.cts +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/package.json +1 -1
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-
|
|
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-
|
|
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-CCicXopP.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-CCicXopP.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Deity TSX - Agent Component
|
|
@@ -27,6 +27,8 @@ interface AgentProps<I = unknown, O = unknown> {
|
|
|
27
27
|
input: ZodSchema<I>;
|
|
28
28
|
/** Output schema (Zod) */
|
|
29
29
|
output: ZodSchema<O>;
|
|
30
|
+
/** Agent execution mode: 'llm' (default) calls LLM, 'pure' runs code only */
|
|
31
|
+
mode?: 'llm' | 'pure';
|
|
30
32
|
/** Optional description */
|
|
31
33
|
description?: string;
|
|
32
34
|
/** Optional tags for categorization */
|
|
@@ -2227,6 +2229,14 @@ declare function setResourceLoader(loader: PromptResourceLoader): void;
|
|
|
2227
2229
|
* - Observe Testing: Test observation logic with mock data
|
|
2228
2230
|
*/
|
|
2229
2231
|
|
|
2232
|
+
/**
|
|
2233
|
+
* Empty LLM result for testing pure-mode agents.
|
|
2234
|
+
*
|
|
2235
|
+
* Pure-mode agents don't call LLM, but their extractOutput function
|
|
2236
|
+
* still receives an LLMLoopResult. This constant provides a minimal
|
|
2237
|
+
* empty result for use in tests.
|
|
2238
|
+
*/
|
|
2239
|
+
declare const EMPTY_LLM_RESULT: LLMLoopResult;
|
|
2230
2240
|
/**
|
|
2231
2241
|
* Full Agent Test Options
|
|
2232
2242
|
*/
|
|
@@ -2821,4 +2831,4 @@ interface ContextConfig<I = unknown> {
|
|
|
2821
2831
|
*/
|
|
2822
2832
|
declare function createEnhancedContext<I = unknown>(config: ContextConfig<I>): Promise<ExecutionContext<I>>;
|
|
2823
2833
|
|
|
2824
|
-
export { ASTNode, Agent, AgentComponent, AgentNode, type AgentProps, Conditional, type ConditionalProps, DEADLINE_PROMPT, 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 };
|
|
2834
|
+
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-
|
|
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-
|
|
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-CCicXopP.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-CCicXopP.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Deity TSX - Agent Component
|
|
@@ -27,6 +27,8 @@ interface AgentProps<I = unknown, O = unknown> {
|
|
|
27
27
|
input: ZodSchema<I>;
|
|
28
28
|
/** Output schema (Zod) */
|
|
29
29
|
output: ZodSchema<O>;
|
|
30
|
+
/** Agent execution mode: 'llm' (default) calls LLM, 'pure' runs code only */
|
|
31
|
+
mode?: 'llm' | 'pure';
|
|
30
32
|
/** Optional description */
|
|
31
33
|
description?: string;
|
|
32
34
|
/** Optional tags for categorization */
|
|
@@ -2227,6 +2229,14 @@ declare function setResourceLoader(loader: PromptResourceLoader): void;
|
|
|
2227
2229
|
* - Observe Testing: Test observation logic with mock data
|
|
2228
2230
|
*/
|
|
2229
2231
|
|
|
2232
|
+
/**
|
|
2233
|
+
* Empty LLM result for testing pure-mode agents.
|
|
2234
|
+
*
|
|
2235
|
+
* Pure-mode agents don't call LLM, but their extractOutput function
|
|
2236
|
+
* still receives an LLMLoopResult. This constant provides a minimal
|
|
2237
|
+
* empty result for use in tests.
|
|
2238
|
+
*/
|
|
2239
|
+
declare const EMPTY_LLM_RESULT: LLMLoopResult;
|
|
2230
2240
|
/**
|
|
2231
2241
|
* Full Agent Test Options
|
|
2232
2242
|
*/
|
|
@@ -2821,4 +2831,4 @@ interface ContextConfig<I = unknown> {
|
|
|
2821
2831
|
*/
|
|
2822
2832
|
declare function createEnhancedContext<I = unknown>(config: ContextConfig<I>): Promise<ExecutionContext<I>>;
|
|
2823
2833
|
|
|
2824
|
-
export { ASTNode, Agent, AgentComponent, AgentNode, type AgentProps, Conditional, type ConditionalProps, DEADLINE_PROMPT, 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 };
|
|
2834
|
+
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, mode, description, tags, loopValidator, loopConfig, tools: propsTools, children } = props;
|
|
46
|
+
const isPure = mode === "pure";
|
|
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 (isPure) {
|
|
58
|
+
throw new Error("Agent: pure mode agent 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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
let prompt;
|
|
65
|
+
let rest;
|
|
66
|
+
if (isPure) {
|
|
67
|
+
const firstChild = nonToolsChildren[0];
|
|
68
|
+
if (firstChild?.type === "Prompt") {
|
|
69
|
+
prompt = firstChild;
|
|
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
|
-
|
|
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);
|
|
@@ -83,6 +101,7 @@ function Agent(props) {
|
|
|
83
101
|
id,
|
|
84
102
|
input,
|
|
85
103
|
output,
|
|
104
|
+
mode,
|
|
86
105
|
description,
|
|
87
106
|
tags,
|
|
88
107
|
loopValidator,
|
|
@@ -1052,24 +1071,26 @@ function compileAgent(ast) {
|
|
|
1052
1071
|
if (!children || children.length === 0) {
|
|
1053
1072
|
throw new Error("Agent must have children");
|
|
1054
1073
|
}
|
|
1074
|
+
const isPure = ast.props.mode === "pure";
|
|
1055
1075
|
const promptNode = children.find((n) => n?.type === "Prompt");
|
|
1056
1076
|
const observeNode = children.find((n) => n?.type === "Observe");
|
|
1057
1077
|
const resultNode = children.find((n) => n?.type === "Result");
|
|
1058
1078
|
const validateNode = children.find((n) => n?.type === "Validate");
|
|
1059
1079
|
const retryNode = children.find((n) => n?.type === "Retry");
|
|
1060
|
-
if (!promptNode) {
|
|
1080
|
+
if (!isPure && !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;
|
|
1070
1090
|
const retry = retryNode ? compileRetry(retryNode) : void 0;
|
|
1071
1091
|
const component = {
|
|
1072
1092
|
id: ast.props.id,
|
|
1093
|
+
mode: ast.props.mode,
|
|
1073
1094
|
inputSchema: ast.props.input,
|
|
1074
1095
|
outputSchema: ast.props.output,
|
|
1075
1096
|
buildPrompt,
|
|
@@ -1200,6 +1221,9 @@ function createLazyAgentComponent(astNode) {
|
|
|
1200
1221
|
get id() {
|
|
1201
1222
|
return astNode.props.id;
|
|
1202
1223
|
},
|
|
1224
|
+
get mode() {
|
|
1225
|
+
return astNode.props.mode;
|
|
1226
|
+
},
|
|
1203
1227
|
get inputSchema() {
|
|
1204
1228
|
return astNode.props.input;
|
|
1205
1229
|
},
|
|
@@ -2574,6 +2598,18 @@ var PreflightChecker = class {
|
|
|
2574
2598
|
* Check agent structure
|
|
2575
2599
|
*/
|
|
2576
2600
|
checkAgentStructure(agent, errors) {
|
|
2601
|
+
const isPure = agent.props.mode === "pure";
|
|
2602
|
+
if (isPure) {
|
|
2603
|
+
const resultNode2 = agent.children.find((n) => n?.type === "Result");
|
|
2604
|
+
if (!resultNode2) {
|
|
2605
|
+
errors.push({
|
|
2606
|
+
type: "invalid_structure",
|
|
2607
|
+
message: "Pure mode Agent must have a Result node",
|
|
2608
|
+
nodeType: "Agent"
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
return;
|
|
2612
|
+
}
|
|
2577
2613
|
const [promptNode, ...rest] = agent.children;
|
|
2578
2614
|
if (!promptNode || promptNode.type !== "Prompt") {
|
|
2579
2615
|
errors.push({
|
|
@@ -2673,6 +2709,13 @@ async function preflight(agent, options) {
|
|
|
2673
2709
|
}
|
|
2674
2710
|
|
|
2675
2711
|
// src/testing/test-utils.ts
|
|
2712
|
+
var EMPTY_LLM_RESULT = {
|
|
2713
|
+
response: { content: "", toolCalls: void 0 },
|
|
2714
|
+
messages: [],
|
|
2715
|
+
rounds: 0,
|
|
2716
|
+
toolCallsExecuted: 0,
|
|
2717
|
+
errors: []
|
|
2718
|
+
};
|
|
2676
2719
|
async function runObserve(agent, options) {
|
|
2677
2720
|
const observeNode = agent.children.find((n) => n?.type === "Observe");
|
|
2678
2721
|
if (!observeNode) {
|
|
@@ -3343,6 +3386,73 @@ async function executeComponent(component, ctx, adapter, config) {
|
|
|
3343
3386
|
stageId: component.id,
|
|
3344
3387
|
timestamp: /* @__PURE__ */ new Date()
|
|
3345
3388
|
});
|
|
3389
|
+
if (component.mode === "pure") {
|
|
3390
|
+
try {
|
|
3391
|
+
ctx.ui?.stepProgress(component.id, 50, "Executing pure agent...");
|
|
3392
|
+
const syntheticLLMResult = {
|
|
3393
|
+
response: { content: "", toolCalls: void 0 },
|
|
3394
|
+
messages: [],
|
|
3395
|
+
rounds: 0,
|
|
3396
|
+
toolCallsExecuted: 0,
|
|
3397
|
+
errors: []
|
|
3398
|
+
};
|
|
3399
|
+
let output;
|
|
3400
|
+
if (component.extractOutput) {
|
|
3401
|
+
const extracted = await Promise.resolve(component.extractOutput(ctx, syntheticLLMResult));
|
|
3402
|
+
const validation = component.outputSchema.safeParse(extracted);
|
|
3403
|
+
if (!validation.success) {
|
|
3404
|
+
const errors = validation.error.issues.map((e) => `${e.path.join(".")}: ${e.message}`).join("; ");
|
|
3405
|
+
throw new Error(`Output validation failed: ${errors}`);
|
|
3406
|
+
}
|
|
3407
|
+
output = validation.data;
|
|
3408
|
+
} else {
|
|
3409
|
+
throw new Error("Pure mode agent must have an extractOutput (Result) function");
|
|
3410
|
+
}
|
|
3411
|
+
if (component.validateOutput) {
|
|
3412
|
+
const validationResult = await Promise.resolve(component.validateOutput(output, ctx));
|
|
3413
|
+
if (!validationResult.valid) {
|
|
3414
|
+
const errorMessages = validationResult.errors?.join("; ") ?? validationResult.feedback ?? "Validation failed";
|
|
3415
|
+
throw new Error(errorMessages);
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
const duration2 = Date.now() - startTime;
|
|
3419
|
+
await ctx.trace.log({
|
|
3420
|
+
type: "stage_complete",
|
|
3421
|
+
output,
|
|
3422
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
3423
|
+
});
|
|
3424
|
+
ctx.ui?.completeStep(
|
|
3425
|
+
component.id,
|
|
3426
|
+
`Completed (pure) in ${Math.round(duration2 / 1e3)}s`
|
|
3427
|
+
);
|
|
3428
|
+
return {
|
|
3429
|
+
output,
|
|
3430
|
+
success: true,
|
|
3431
|
+
attempts: 1,
|
|
3432
|
+
llmResults: [syntheticLLMResult],
|
|
3433
|
+
retryResult: {
|
|
3434
|
+
success: true,
|
|
3435
|
+
output,
|
|
3436
|
+
attempts: 1,
|
|
3437
|
+
errors: [],
|
|
3438
|
+
validationHistory: [],
|
|
3439
|
+
outputHistory: [output]
|
|
3440
|
+
},
|
|
3441
|
+
duration: duration2
|
|
3442
|
+
};
|
|
3443
|
+
} catch (error) {
|
|
3444
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
3445
|
+
await ctx.trace.log({
|
|
3446
|
+
type: "stage_failed",
|
|
3447
|
+
error: errorMessage,
|
|
3448
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
3449
|
+
});
|
|
3450
|
+
ctx.ui?.failStep(component.id, errorMessage);
|
|
3451
|
+
throw new Error(
|
|
3452
|
+
`Component ${component.id} (pure mode) failed: ${errorMessage}`
|
|
3453
|
+
);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3346
3456
|
const retryResult = await executeWithRetry(
|
|
3347
3457
|
component,
|
|
3348
3458
|
ctx,
|
|
@@ -5038,6 +5148,10 @@ async function executeStepNode(node, ctx, adapter, config) {
|
|
|
5038
5148
|
if (node.component.model?.adapter) {
|
|
5039
5149
|
adapter = node.component.model.adapter;
|
|
5040
5150
|
config = node.component.model.config;
|
|
5151
|
+
} else if (node.component.mode === "pure") {
|
|
5152
|
+
adapter = {
|
|
5153
|
+
generate: async () => ({ content: "", toolCalls: void 0 })
|
|
5154
|
+
};
|
|
5041
5155
|
} else {
|
|
5042
5156
|
throw new Error("No LLM adapter provided");
|
|
5043
5157
|
}
|
|
@@ -5254,6 +5368,6 @@ function createLoopNode(child, maxIterations) {
|
|
|
5254
5368
|
};
|
|
5255
5369
|
}
|
|
5256
5370
|
|
|
5257
|
-
export { Agent, Conditional, DEADLINE_PROMPT, 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 };
|
|
5371
|
+
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 };
|
|
5258
5372
|
//# sourceMappingURL=index.js.map
|
|
5259
5373
|
//# sourceMappingURL=index.js.map
|