@limo-labs/deity 0.1.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/README.md +519 -0
- package/dist/src/component.d.ts +19 -0
- package/dist/src/component.d.ts.map +1 -0
- package/dist/src/component.js +2 -0
- package/dist/src/component.js.map +1 -0
- package/dist/src/context/context-scope.d.ts +24 -0
- package/dist/src/context/context-scope.d.ts.map +1 -0
- package/dist/src/context/context-scope.js +19 -0
- package/dist/src/context/context-scope.js.map +1 -0
- package/dist/src/context/memory-view.d.ts +62 -0
- package/dist/src/context/memory-view.d.ts.map +1 -0
- package/dist/src/context/memory-view.js +104 -0
- package/dist/src/context/memory-view.js.map +1 -0
- package/dist/src/context/scoped-context.d.ts +51 -0
- package/dist/src/context/scoped-context.d.ts.map +1 -0
- package/dist/src/context/scoped-context.js +74 -0
- package/dist/src/context/scoped-context.js.map +1 -0
- package/dist/src/context/scoped-execution-context.d.ts +55 -0
- package/dist/src/context/scoped-execution-context.d.ts.map +1 -0
- package/dist/src/context/scoped-execution-context.js +78 -0
- package/dist/src/context/scoped-execution-context.js.map +1 -0
- package/dist/src/conversation/conversation-manager.d.ts +272 -0
- package/dist/src/conversation/conversation-manager.d.ts.map +1 -0
- package/dist/src/conversation/conversation-manager.js +11 -0
- package/dist/src/conversation/conversation-manager.js.map +1 -0
- package/dist/src/conversation/conversation-pruner.d.ts +190 -0
- package/dist/src/conversation/conversation-pruner.d.ts.map +1 -0
- package/dist/src/conversation/conversation-pruner.js +274 -0
- package/dist/src/conversation/conversation-pruner.js.map +1 -0
- package/dist/src/conversation/conversation-tree.d.ts +185 -0
- package/dist/src/conversation/conversation-tree.d.ts.map +1 -0
- package/dist/src/conversation/conversation-tree.js +288 -0
- package/dist/src/conversation/conversation-tree.js.map +1 -0
- package/dist/src/conversation/file-conversation-store.d.ts +93 -0
- package/dist/src/conversation/file-conversation-store.d.ts.map +1 -0
- package/dist/src/conversation/file-conversation-store.js +284 -0
- package/dist/src/conversation/file-conversation-store.js.map +1 -0
- package/dist/src/conversation/in-memory-conversation-store.d.ts +36 -0
- package/dist/src/conversation/in-memory-conversation-store.d.ts.map +1 -0
- package/dist/src/conversation/in-memory-conversation-store.js +146 -0
- package/dist/src/conversation/in-memory-conversation-store.js.map +1 -0
- package/dist/src/copilot-adapter.d.ts +33 -0
- package/dist/src/copilot-adapter.d.ts.map +1 -0
- package/dist/src/copilot-adapter.js +119 -0
- package/dist/src/copilot-adapter.js.map +1 -0
- package/dist/src/file-trace-enhanced.d.ts +123 -0
- package/dist/src/file-trace-enhanced.d.ts.map +1 -0
- package/dist/src/file-trace-enhanced.js +177 -0
- package/dist/src/file-trace-enhanced.js.map +1 -0
- package/dist/src/file-trace.d.ts +24 -0
- package/dist/src/file-trace.d.ts.map +1 -0
- package/dist/src/file-trace.js +60 -0
- package/dist/src/file-trace.js.map +1 -0
- package/dist/src/index.d.ts +63 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +40 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/json-store.d.ts +27 -0
- package/dist/src/json-store.d.ts.map +1 -0
- package/dist/src/json-store.js +93 -0
- package/dist/src/json-store.js.map +1 -0
- package/dist/src/llm.d.ts +35 -0
- package/dist/src/llm.d.ts.map +1 -0
- package/dist/src/llm.js +2 -0
- package/dist/src/llm.js.map +1 -0
- package/dist/src/memory/cold-storage.d.ts +60 -0
- package/dist/src/memory/cold-storage.d.ts.map +1 -0
- package/dist/src/memory/cold-storage.js +132 -0
- package/dist/src/memory/cold-storage.js.map +1 -0
- package/dist/src/memory/compression.d.ts +161 -0
- package/dist/src/memory/compression.d.ts.map +1 -0
- package/dist/src/memory/compression.js +193 -0
- package/dist/src/memory/compression.js.map +1 -0
- package/dist/src/memory/hot-memory.d.ts +69 -0
- package/dist/src/memory/hot-memory.d.ts.map +1 -0
- package/dist/src/memory/hot-memory.js +116 -0
- package/dist/src/memory/hot-memory.js.map +1 -0
- package/dist/src/memory/memory-budget.d.ts +162 -0
- package/dist/src/memory/memory-budget.d.ts.map +1 -0
- package/dist/src/memory/memory-budget.js +241 -0
- package/dist/src/memory/memory-budget.js.map +1 -0
- package/dist/src/memory/memory-config.d.ts +419 -0
- package/dist/src/memory/memory-config.d.ts.map +1 -0
- package/dist/src/memory/memory-config.js +297 -0
- package/dist/src/memory/memory-config.js.map +1 -0
- package/dist/src/memory/prefetcher.d.ts +137 -0
- package/dist/src/memory/prefetcher.d.ts.map +1 -0
- package/dist/src/memory/prefetcher.js +186 -0
- package/dist/src/memory/prefetcher.js.map +1 -0
- package/dist/src/memory/tiered-memory.d.ts +116 -0
- package/dist/src/memory/tiered-memory.d.ts.map +1 -0
- package/dist/src/memory/tiered-memory.js +215 -0
- package/dist/src/memory/tiered-memory.js.map +1 -0
- package/dist/src/memory/warm-storage.d.ts +74 -0
- package/dist/src/memory/warm-storage.d.ts.map +1 -0
- package/dist/src/memory/warm-storage.js +207 -0
- package/dist/src/memory/warm-storage.js.map +1 -0
- package/dist/src/openai-adapter.d.ts +20 -0
- package/dist/src/openai-adapter.d.ts.map +1 -0
- package/dist/src/openai-adapter.js +73 -0
- package/dist/src/openai-adapter.js.map +1 -0
- package/dist/src/parser.d.ts +27 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +76 -0
- package/dist/src/parser.js.map +1 -0
- package/dist/src/runtime.d.ts +172 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/runtime.js +436 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/schema-utils.d.ts +7 -0
- package/dist/src/schema-utils.d.ts.map +1 -0
- package/dist/src/schema-utils.js +71 -0
- package/dist/src/schema-utils.js.map +1 -0
- package/dist/src/stage.d.ts +139 -0
- package/dist/src/stage.d.ts.map +1 -0
- package/dist/src/stage.js +2 -0
- package/dist/src/stage.js.map +1 -0
- package/dist/src/store.d.ts +51 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +2 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/tool.d.ts +12 -0
- package/dist/src/tool.d.ts.map +1 -0
- package/dist/src/tool.js +2 -0
- package/dist/src/tool.js.map +1 -0
- package/dist/src/trace.d.ts +60 -0
- package/dist/src/trace.d.ts.map +1 -0
- package/dist/src/trace.js +2 -0
- package/dist/src/trace.js.map +1 -0
- package/dist/src/validator.d.ts +17 -0
- package/dist/src/validator.d.ts.map +1 -0
- package/dist/src/validator.js +21 -0
- package/dist/src/validator.js.map +1 -0
- package/dist/src/workflow.d.ts +192 -0
- package/dist/src/workflow.d.ts.map +1 -0
- package/dist/src/workflow.js +50 -0
- package/dist/src/workflow.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { parseOutput } from "./parser.js";
|
|
2
|
+
import { hashPrompt } from "./json-store.js";
|
|
3
|
+
import { InMemoryConversationStore } from "./conversation/in-memory-conversation-store.js";
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a stage fails permanently (exhausts all retries).
|
|
6
|
+
*/
|
|
7
|
+
export class StageFailedError extends Error {
|
|
8
|
+
stageId;
|
|
9
|
+
errors;
|
|
10
|
+
constructor(stageId, errors) {
|
|
11
|
+
super(`Stage "${stageId}" failed: ${errors.join("; ")}`);
|
|
12
|
+
this.stageId = stageId;
|
|
13
|
+
this.errors = errors;
|
|
14
|
+
this.name = "StageFailedError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown when a stage attempts to access another stage's output
|
|
19
|
+
* that is not in its declared scope.
|
|
20
|
+
*
|
|
21
|
+
* @since 2.0.0
|
|
22
|
+
*/
|
|
23
|
+
export class ScopeViolationError extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "ScopeViolationError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export { defineWorkflow } from "./workflow.js";
|
|
30
|
+
/**
|
|
31
|
+
* Get the list of visible stages for a component based on its scope declaration.
|
|
32
|
+
* Returns "*" for wildcard access or an array of accessible stage IDs.
|
|
33
|
+
* Supports dynamic scopes that are computed based on inputs.
|
|
34
|
+
*
|
|
35
|
+
* @param component - The agent component to check
|
|
36
|
+
* @param inputs - The inputs to the current stage (for dynamic scopes)
|
|
37
|
+
* @returns "*" for full access, or string[] for limited visibility
|
|
38
|
+
* @since 2.0.0
|
|
39
|
+
*/
|
|
40
|
+
function getVisibleStages(component, inputs) {
|
|
41
|
+
// No scope = full access (backward compatibility)
|
|
42
|
+
if (!component.scope) {
|
|
43
|
+
return "*";
|
|
44
|
+
}
|
|
45
|
+
// Isolated = no dependencies
|
|
46
|
+
if (component.scope.isolated) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
// Use visibility if explicitly set
|
|
50
|
+
if (component.scope.visibility !== undefined) {
|
|
51
|
+
const visibility = component.scope.visibility;
|
|
52
|
+
// If visibility is a function, call it with inputs
|
|
53
|
+
if (typeof visibility === "function") {
|
|
54
|
+
return visibility(inputs);
|
|
55
|
+
}
|
|
56
|
+
return visibility;
|
|
57
|
+
}
|
|
58
|
+
// Default to full access
|
|
59
|
+
return "*";
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if a stage ID is accessible based on visibility rules.
|
|
63
|
+
*
|
|
64
|
+
* @param stageId - The stage ID to check access for
|
|
65
|
+
* @param visibleStages - Visibility rules ("*" or string[])
|
|
66
|
+
* @returns true if accessible, false otherwise
|
|
67
|
+
* @since 2.0.0
|
|
68
|
+
*/
|
|
69
|
+
function isStageAccessible(stageId, visibleStages) {
|
|
70
|
+
if (visibleStages === "*") {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return visibleStages.includes(stageId);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Define a pipeline from config and stages.
|
|
77
|
+
*
|
|
78
|
+
* Creates a pipeline configuration that can be executed with runPipeline().
|
|
79
|
+
* Pipelines define a sequence of agent components (stages) that process data
|
|
80
|
+
* with automatic checkpointing, retry logic, and validation.
|
|
81
|
+
*
|
|
82
|
+
* @deprecated Use `defineWorkflow()` instead. This function will be removed in v3.0.0.
|
|
83
|
+
* See TERMINOLOGY.md for migration guide.
|
|
84
|
+
*
|
|
85
|
+
* @param options - Pipeline configuration and stages
|
|
86
|
+
* @returns Pipeline definition ready for execution
|
|
87
|
+
*
|
|
88
|
+
* @since 1.0.0
|
|
89
|
+
*/
|
|
90
|
+
export function definePipeline(options) {
|
|
91
|
+
const { stages, ...config } = options;
|
|
92
|
+
return { config, stages };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Execute multiple promises with concurrency limit.
|
|
96
|
+
*
|
|
97
|
+
* @param items - Array of items to process
|
|
98
|
+
* @param limit - Maximum number of concurrent executions
|
|
99
|
+
* @param fn - Async function to execute for each item
|
|
100
|
+
* @returns Array of results in the same order as items
|
|
101
|
+
*/
|
|
102
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
103
|
+
const results = new Array(items.length);
|
|
104
|
+
let currentIndex = 0;
|
|
105
|
+
const executeNext = async () => {
|
|
106
|
+
const index = currentIndex++;
|
|
107
|
+
if (index >= items.length) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
results[index] = await fn(items[index]);
|
|
111
|
+
await executeNext();
|
|
112
|
+
};
|
|
113
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, () => executeNext());
|
|
114
|
+
await Promise.all(workers);
|
|
115
|
+
return results;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Execute multiple tool calls with concurrency control.
|
|
119
|
+
*
|
|
120
|
+
* All tool calls are considered independent and executed in parallel up to
|
|
121
|
+
* the concurrency limit.
|
|
122
|
+
*
|
|
123
|
+
* @param toolCalls - Tool calls to execute
|
|
124
|
+
* @param tools - Available tools
|
|
125
|
+
* @param stageId - Current stage ID for logging
|
|
126
|
+
* @param trace - Trace logger
|
|
127
|
+
* @param conversation - Conversation manager
|
|
128
|
+
* @param concurrencyLimit - Maximum concurrent executions
|
|
129
|
+
* @returns Array of tool result messages
|
|
130
|
+
*/
|
|
131
|
+
async function executeToolCalls(toolCalls, tools, stageId, trace, conversation, concurrencyLimit) {
|
|
132
|
+
return mapWithConcurrency(toolCalls, concurrencyLimit, async (toolCall) => {
|
|
133
|
+
const tool = tools?.find((t) => t.name === toolCall.toolName);
|
|
134
|
+
if (!tool) {
|
|
135
|
+
trace.log({
|
|
136
|
+
stageId,
|
|
137
|
+
event: "tool_call",
|
|
138
|
+
data: { toolName: toolCall.toolName, error: "Tool not found" },
|
|
139
|
+
});
|
|
140
|
+
const toolMessage = {
|
|
141
|
+
role: "tool",
|
|
142
|
+
content: JSON.stringify({ error: `Tool "${toolCall.toolName}" not found` }),
|
|
143
|
+
toolCallId: toolCall.id,
|
|
144
|
+
};
|
|
145
|
+
await conversation.addMessage(toolMessage, { stageId });
|
|
146
|
+
return { toolCall, message: toolMessage };
|
|
147
|
+
}
|
|
148
|
+
trace.log({
|
|
149
|
+
stageId,
|
|
150
|
+
event: "tool_call",
|
|
151
|
+
data: { toolName: toolCall.toolName, arguments: toolCall.arguments },
|
|
152
|
+
});
|
|
153
|
+
try {
|
|
154
|
+
const startTime = Date.now();
|
|
155
|
+
const result = await tool.execute(toolCall.arguments);
|
|
156
|
+
const duration = Date.now() - startTime;
|
|
157
|
+
trace.log({
|
|
158
|
+
stageId,
|
|
159
|
+
event: "tool_result",
|
|
160
|
+
data: { toolName: toolCall.toolName, result, toolDuration: duration },
|
|
161
|
+
});
|
|
162
|
+
const toolMessage = {
|
|
163
|
+
role: "tool",
|
|
164
|
+
content: JSON.stringify(result),
|
|
165
|
+
toolCallId: toolCall.id,
|
|
166
|
+
};
|
|
167
|
+
await conversation.addMessage(toolMessage, { stageId });
|
|
168
|
+
return { toolCall, message: toolMessage };
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
172
|
+
trace.log({
|
|
173
|
+
stageId,
|
|
174
|
+
event: "tool_result",
|
|
175
|
+
data: { toolName: toolCall.toolName, error: errorMsg },
|
|
176
|
+
});
|
|
177
|
+
const toolMessage = {
|
|
178
|
+
role: "tool",
|
|
179
|
+
content: JSON.stringify({ error: errorMsg }),
|
|
180
|
+
toolCallId: toolCall.id,
|
|
181
|
+
};
|
|
182
|
+
await conversation.addMessage(toolMessage, { stageId });
|
|
183
|
+
return { toolCall, message: toolMessage };
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Run the tool calling loop for a single stage execution.
|
|
189
|
+
* Manages the cycle: LLM request → tool calls → results → back to LLM.
|
|
190
|
+
* Automatically records all messages to the conversation manager.
|
|
191
|
+
*
|
|
192
|
+
* @since 2.0.0 (conversation parameter added)
|
|
193
|
+
*/
|
|
194
|
+
async function runToolLoop(adapter, messages, tools, config, maxRounds, trace, stageId, conversation, concurrencyLimit = Infinity) {
|
|
195
|
+
let currentMessages = [...messages];
|
|
196
|
+
let response;
|
|
197
|
+
// Record initial user/system messages from buildPrompt
|
|
198
|
+
// (only on first round, these are the prompt messages)
|
|
199
|
+
for (const msg of messages) {
|
|
200
|
+
await conversation.addMessage(msg, { stageId });
|
|
201
|
+
}
|
|
202
|
+
for (let round = 0; round < maxRounds; round++) {
|
|
203
|
+
trace.log({
|
|
204
|
+
stageId,
|
|
205
|
+
event: "llm_request",
|
|
206
|
+
data: { round, messageCount: currentMessages.length },
|
|
207
|
+
});
|
|
208
|
+
response = await adapter.generate(currentMessages, tools, config);
|
|
209
|
+
trace.log({
|
|
210
|
+
stageId,
|
|
211
|
+
event: "llm_response",
|
|
212
|
+
data: {
|
|
213
|
+
round,
|
|
214
|
+
contentLength: response.content.length,
|
|
215
|
+
toolCallCount: response.toolCalls?.length ?? 0,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
// Record assistant response to conversation
|
|
219
|
+
await conversation.addMessage({
|
|
220
|
+
role: "assistant",
|
|
221
|
+
content: response.content,
|
|
222
|
+
}, { stageId });
|
|
223
|
+
// If no tool calls, we're done
|
|
224
|
+
if (!response.toolCalls || response.toolCalls.length === 0) {
|
|
225
|
+
return response;
|
|
226
|
+
}
|
|
227
|
+
// Execute tool calls in parallel with concurrency limit
|
|
228
|
+
const toolResults = await executeToolCalls(response.toolCalls, tools, stageId, trace, conversation, concurrencyLimit);
|
|
229
|
+
// Append tool result messages to conversation
|
|
230
|
+
for (const { message } of toolResults) {
|
|
231
|
+
currentMessages.push(message);
|
|
232
|
+
}
|
|
233
|
+
// Add assistant message with tool calls for conversation context
|
|
234
|
+
currentMessages.push({
|
|
235
|
+
role: "assistant",
|
|
236
|
+
content: response.content || "",
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
// If we exhausted rounds, return the last response
|
|
240
|
+
return response;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Execute a complete workflow.
|
|
244
|
+
* This is the core runtime loop that drives the entire framework.
|
|
245
|
+
*
|
|
246
|
+
* A workflow represents a single agent's deterministic execution through
|
|
247
|
+
* a sequence of steps, with automatic checkpointing, retry logic, and validation.
|
|
248
|
+
*
|
|
249
|
+
* @param workflow - Workflow definition with configuration and steps
|
|
250
|
+
* @param inputs - Input data for the workflow
|
|
251
|
+
* @param store - State storage for checkpoints
|
|
252
|
+
* @param trace - Trace logger for execution history
|
|
253
|
+
* @param conversation - Optional conversation manager (defaults to in-memory store)
|
|
254
|
+
* @param adapterOverride - Optional LLM adapter override
|
|
255
|
+
* @returns Record of all step outputs
|
|
256
|
+
*
|
|
257
|
+
* @since 2.0.0
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* import { runWorkflow, defineWorkflow } from '@limo-labs/deity';
|
|
262
|
+
*
|
|
263
|
+
* const workflow = defineWorkflow({
|
|
264
|
+
* name: "research-workflow",
|
|
265
|
+
* defaultModel: { adapter: llm },
|
|
266
|
+
* steps: [ResearchStep, AnalysisStep, ReportStep]
|
|
267
|
+
* });
|
|
268
|
+
*
|
|
269
|
+
* const result = await runWorkflow(
|
|
270
|
+
* workflow,
|
|
271
|
+
* { topic: "AI agents" },
|
|
272
|
+
* store,
|
|
273
|
+
* trace
|
|
274
|
+
* );
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
export async function runWorkflow(workflow, inputs, store, trace, conversation, adapterOverride) {
|
|
278
|
+
const adapter = adapterOverride ?? workflow.config.defaultModel?.adapter;
|
|
279
|
+
if (!adapter) {
|
|
280
|
+
throw new Error("No LLM adapter provided. Set defaultModel in workflow config or pass adapterOverride.");
|
|
281
|
+
}
|
|
282
|
+
const defaultConfig = workflow.config.defaultModel?.config;
|
|
283
|
+
const maxToolRounds = workflow.config.maxToolRounds ?? 10;
|
|
284
|
+
const onFailure = workflow.config.onStageFailure ?? "abort";
|
|
285
|
+
const parallelToolConcurrency = workflow.config.parallelToolConcurrency ?? Infinity;
|
|
286
|
+
// Create default conversation manager if not provided
|
|
287
|
+
const conversationManager = conversation ?? new InMemoryConversationStore();
|
|
288
|
+
const outputs = {};
|
|
289
|
+
// Load existing completed outputs for resume
|
|
290
|
+
const existingRecords = await store.loadAll();
|
|
291
|
+
for (const [id, record] of Object.entries(existingRecords)) {
|
|
292
|
+
if (record.status === "completed") {
|
|
293
|
+
outputs[id] = record.output;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
for (const stage of workflow.steps) {
|
|
297
|
+
// Determine visibility based on component scope declaration (supports dynamic scopes)
|
|
298
|
+
const visibleStages = getVisibleStages(stage, inputs);
|
|
299
|
+
// Build prompt to compute hash (needed for cache invalidation check)
|
|
300
|
+
const ctx = {
|
|
301
|
+
inputs,
|
|
302
|
+
previousOutputs: { ...outputs },
|
|
303
|
+
store,
|
|
304
|
+
trace,
|
|
305
|
+
conversation: conversationManager,
|
|
306
|
+
getOutput(stageId) {
|
|
307
|
+
// Check scope permissions before allowing access
|
|
308
|
+
if (!isStageAccessible(stageId, visibleStages)) {
|
|
309
|
+
throw new ScopeViolationError(`Stage "${stage.id}" cannot access output from "${stageId}". ` +
|
|
310
|
+
`Visible stages: ${visibleStages === "*" ? "all" : visibleStages.join(", ")}`);
|
|
311
|
+
}
|
|
312
|
+
if (!(stageId in outputs)) {
|
|
313
|
+
throw new Error(`Stage "${stageId}" has not completed yet.`);
|
|
314
|
+
}
|
|
315
|
+
return outputs[stageId];
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
const promptMessages = await Promise.resolve(stage.buildPrompt(ctx));
|
|
319
|
+
const currentPromptHash = hashPrompt(promptMessages);
|
|
320
|
+
// Check for valid checkpoint (skip if completed with same prompt hash)
|
|
321
|
+
if (await store.hasValidCheckpoint(stage.id, currentPromptHash)) {
|
|
322
|
+
const cached = await store.load(stage.id);
|
|
323
|
+
outputs[stage.id] = cached;
|
|
324
|
+
trace.log({
|
|
325
|
+
stageId: stage.id,
|
|
326
|
+
event: "stage_complete",
|
|
327
|
+
data: { cached: true },
|
|
328
|
+
});
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
// Clear any stale checkpoint
|
|
332
|
+
await store.clear(stage.id);
|
|
333
|
+
trace.log({ stageId: stage.id, event: "stage_start" });
|
|
334
|
+
const maxAttempts = stage.retry?.maxAttempts ?? 0;
|
|
335
|
+
let lastErrors = [];
|
|
336
|
+
let stageCompleted = false;
|
|
337
|
+
const allToolCalls = [];
|
|
338
|
+
for (let attempt = 0; attempt <= maxAttempts; attempt++) {
|
|
339
|
+
const messages = [...promptMessages];
|
|
340
|
+
// On retry, inject validation errors for self-correction
|
|
341
|
+
if (attempt > 0 && stage.retry?.feedbackOnError !== false) {
|
|
342
|
+
trace.log({
|
|
343
|
+
stageId: stage.id,
|
|
344
|
+
event: "retry",
|
|
345
|
+
data: { attempt, errors: lastErrors },
|
|
346
|
+
});
|
|
347
|
+
messages.push({
|
|
348
|
+
role: "user",
|
|
349
|
+
content: `Previous attempt failed validation:\n${lastErrors.join("\n")}\nPlease correct your output.`,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// Run tool calling loop
|
|
353
|
+
const raw = await runToolLoop(adapter, messages, stage.tools, defaultConfig, maxToolRounds, trace, stage.id, conversationManager, parallelToolConcurrency);
|
|
354
|
+
// Parse output
|
|
355
|
+
const parsed = parseOutput(raw, stage.outputSchema);
|
|
356
|
+
if (!parsed.success) {
|
|
357
|
+
trace.log({
|
|
358
|
+
stageId: stage.id,
|
|
359
|
+
event: "parse_error",
|
|
360
|
+
data: { error: parsed.error, attempt },
|
|
361
|
+
});
|
|
362
|
+
lastErrors = [parsed.error];
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
// Validate output (semantic validation)
|
|
366
|
+
const validation = stage.validate(parsed.data, ctx);
|
|
367
|
+
if (validation.valid) {
|
|
368
|
+
trace.log({
|
|
369
|
+
stageId: stage.id,
|
|
370
|
+
event: "validation_pass",
|
|
371
|
+
data: { attempt },
|
|
372
|
+
});
|
|
373
|
+
await store.save(stage.id, parsed.data, {
|
|
374
|
+
promptHash: currentPromptHash,
|
|
375
|
+
modelName: undefined,
|
|
376
|
+
generationConfig: defaultConfig,
|
|
377
|
+
toolCalls: allToolCalls.length > 0 ? allToolCalls : undefined,
|
|
378
|
+
});
|
|
379
|
+
outputs[stage.id] = parsed.data;
|
|
380
|
+
stageCompleted = true;
|
|
381
|
+
trace.log({
|
|
382
|
+
stageId: stage.id,
|
|
383
|
+
event: "stage_complete",
|
|
384
|
+
data: { cached: false, attempts: attempt + 1 },
|
|
385
|
+
});
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
trace.log({
|
|
389
|
+
stageId: stage.id,
|
|
390
|
+
event: "validation_fail",
|
|
391
|
+
data: { errors: validation.errors, attempt },
|
|
392
|
+
});
|
|
393
|
+
lastErrors = validation.errors ?? ["Unknown validation error"];
|
|
394
|
+
}
|
|
395
|
+
if (!stageCompleted) {
|
|
396
|
+
await store.markFailed(stage.id, lastErrors, {
|
|
397
|
+
promptHash: currentPromptHash,
|
|
398
|
+
});
|
|
399
|
+
trace.log({
|
|
400
|
+
stageId: stage.id,
|
|
401
|
+
event: "stage_failed",
|
|
402
|
+
data: { errors: lastErrors },
|
|
403
|
+
});
|
|
404
|
+
if (onFailure === "abort") {
|
|
405
|
+
throw new StageFailedError(stage.id, lastErrors);
|
|
406
|
+
}
|
|
407
|
+
// "skip": continue to next stage
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return outputs;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Execute a complete pipeline.
|
|
414
|
+
*
|
|
415
|
+
* @deprecated Use `runWorkflow()` instead. This function will be removed in v3.0.0.
|
|
416
|
+
* See TERMINOLOGY.md for migration guide.
|
|
417
|
+
*
|
|
418
|
+
* @param pipeline - Pipeline configuration
|
|
419
|
+
* @param inputs - Input data for the pipeline
|
|
420
|
+
* @param store - State storage for checkpoints
|
|
421
|
+
* @param trace - Trace logger for execution history
|
|
422
|
+
* @param conversation - Optional conversation manager
|
|
423
|
+
* @param adapterOverride - Optional LLM adapter override
|
|
424
|
+
* @returns Record of all stage outputs
|
|
425
|
+
*
|
|
426
|
+
* @since 1.0.0
|
|
427
|
+
*/
|
|
428
|
+
export async function runPipeline(pipeline, inputs, store, trace, conversation, adapterOverride) {
|
|
429
|
+
// Convert Pipeline to Workflow format
|
|
430
|
+
const workflow = {
|
|
431
|
+
config: pipeline.config,
|
|
432
|
+
steps: pipeline.stages,
|
|
433
|
+
};
|
|
434
|
+
return runWorkflow(workflow, inputs, store, trace, conversation, adapterOverride);
|
|
435
|
+
}
|
|
436
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EA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IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;YACnD,CAAC;YACD,iCAAiC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,QAAkB,EAClB,MAAe,EACf,KAAiB,EACjB,KAAkB,EAClB,YAAkC,EAClC,eAA4B;IAE5B,sCAAsC;IACtC,MAAM,QAAQ,GAAa;QACzB,MAAM,EAAE,QAAQ,CAAC,MAAwB;QACzC,KAAK,EAAE,QAAQ,CAAC,MAAM;KACvB,CAAC;IAEF,OAAO,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ZodSchema } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Convert a Zod schema to JSON Schema for LLM tool definitions.
|
|
4
|
+
* Uses Zod's built-in method if available, otherwise returns a minimal schema.
|
|
5
|
+
*/
|
|
6
|
+
export declare function zodToJsonSchema(schema: ZodSchema<any>): Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=schema-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../../src/schema-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAK/E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a Zod schema to JSON Schema for LLM tool definitions.
|
|
3
|
+
* Uses Zod's built-in method if available, otherwise returns a minimal schema.
|
|
4
|
+
*/
|
|
5
|
+
export function zodToJsonSchema(schema) {
|
|
6
|
+
// Zod v3 doesn't have built-in JSON schema conversion,
|
|
7
|
+
// but the schema description can be extracted from _def.
|
|
8
|
+
// For MVP, we use a simple recursive converter.
|
|
9
|
+
return convertZodDef(schema._def);
|
|
10
|
+
}
|
|
11
|
+
function convertZodDef(def) {
|
|
12
|
+
if (!def)
|
|
13
|
+
return { type: "object" };
|
|
14
|
+
const typeName = def.typeName;
|
|
15
|
+
switch (typeName) {
|
|
16
|
+
case "ZodString":
|
|
17
|
+
return { type: "string" };
|
|
18
|
+
case "ZodNumber":
|
|
19
|
+
return { type: "number" };
|
|
20
|
+
case "ZodBoolean":
|
|
21
|
+
return { type: "boolean" };
|
|
22
|
+
case "ZodArray":
|
|
23
|
+
return {
|
|
24
|
+
type: "array",
|
|
25
|
+
items: convertZodDef(def.type?._def),
|
|
26
|
+
};
|
|
27
|
+
case "ZodObject": {
|
|
28
|
+
const properties = {};
|
|
29
|
+
const required = [];
|
|
30
|
+
const shape = def.shape?.();
|
|
31
|
+
if (shape) {
|
|
32
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
33
|
+
const fieldDef = value?._def;
|
|
34
|
+
if (fieldDef?.typeName === "ZodOptional") {
|
|
35
|
+
properties[key] = convertZodDef(fieldDef.innerType?._def);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
properties[key] = convertZodDef(fieldDef);
|
|
39
|
+
required.push(key);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const result = { type: "object", properties };
|
|
44
|
+
if (required.length > 0)
|
|
45
|
+
result.required = required;
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
case "ZodOptional":
|
|
49
|
+
return convertZodDef(def.innerType?._def);
|
|
50
|
+
case "ZodEnum":
|
|
51
|
+
return { type: "string", enum: def.values };
|
|
52
|
+
case "ZodLiteral":
|
|
53
|
+
return { type: typeof def.value, const: def.value };
|
|
54
|
+
case "ZodRecord":
|
|
55
|
+
return {
|
|
56
|
+
type: "object",
|
|
57
|
+
additionalProperties: convertZodDef(def.valueType?._def),
|
|
58
|
+
};
|
|
59
|
+
case "ZodUnion": {
|
|
60
|
+
const options = def.options?.map((opt) => convertZodDef(opt._def));
|
|
61
|
+
return { oneOf: options ?? [] };
|
|
62
|
+
}
|
|
63
|
+
case "ZodNullable": {
|
|
64
|
+
const inner = convertZodDef(def.innerType?._def);
|
|
65
|
+
return { ...inner, nullable: true };
|
|
66
|
+
}
|
|
67
|
+
default:
|
|
68
|
+
return { type: "object" };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=schema-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-utils.js","sourceRoot":"","sources":["../../src/schema-utils.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAsB;IACpD,uDAAuD;IACvD,yDAAyD;IACzD,gDAAgD;IAChD,OAAO,aAAa,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,aAAa,CAAC,GAAQ;IAC7B,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEpC,MAAM,QAAQ,GAAW,GAAG,CAAC,QAAQ,CAAC;IAEtC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC5B,KAAK,WAAW;YACd,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC5B,KAAK,YAAY;YACf,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7B,KAAK,UAAU;YACb,OAAO;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;aACrC,CAAC;QACJ,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EAAE,QAAQ;gBACd,oBAAoB,EAAE,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC;aACzD,CAAC;QACJ,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,MAAM,OAAO,GAAI,GAAG,CAAC,OAAiB,EAAE,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CACvD,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CACxB,CAAC;YACF,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;QAClC,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACjD,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACtC,CAAC;QACD;YACE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { ZodSchema } from "zod";
|
|
2
|
+
import type { Message, ValidationResult } from "./component.js";
|
|
3
|
+
import type { StateStore } from "./store.js";
|
|
4
|
+
import type { TraceLogger } from "./trace.js";
|
|
5
|
+
import type { Tool } from "./tool.js";
|
|
6
|
+
import type { ConversationManager } from "./conversation/conversation-manager.js";
|
|
7
|
+
/**
|
|
8
|
+
* Execution context passed to each component during stage execution.
|
|
9
|
+
*
|
|
10
|
+
* Provides access to inputs, stage outputs, storage, tracing, and conversation history.
|
|
11
|
+
*
|
|
12
|
+
* @since 1.0.0 (conversation field added in 2.0.0)
|
|
13
|
+
*/
|
|
14
|
+
export interface ExecutionContext<I = unknown> {
|
|
15
|
+
inputs: I;
|
|
16
|
+
previousOutputs: Record<string, unknown>;
|
|
17
|
+
store: StateStore;
|
|
18
|
+
trace: TraceLogger;
|
|
19
|
+
/**
|
|
20
|
+
* Conversation history manager.
|
|
21
|
+
*
|
|
22
|
+
* Provides access to the full conversation history for this pipeline execution.
|
|
23
|
+
* Components can use this to query past messages, add context-specific messages,
|
|
24
|
+
* or implement conversational logic.
|
|
25
|
+
*
|
|
26
|
+
* @since 2.0.0
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* buildPrompt(ctx: ExecutionContext<I>) {
|
|
31
|
+
* // Get recent conversation history
|
|
32
|
+
* const recent = await ctx.conversation.getRecent(10);
|
|
33
|
+
*
|
|
34
|
+
* // Search for specific messages
|
|
35
|
+
* const systemMessages = await ctx.conversation.search({
|
|
36
|
+
* role: "system"
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* return [
|
|
40
|
+
* ...systemMessages.map(m => m.message),
|
|
41
|
+
* { role: "user", content: "Continue the conversation..." }
|
|
42
|
+
* ];
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
conversation: ConversationManager;
|
|
47
|
+
/**
|
|
48
|
+
* Type-safe accessor for a specific stage's output.
|
|
49
|
+
* Throws if the requested stage has not completed yet.
|
|
50
|
+
*/
|
|
51
|
+
getOutput<T>(stageId: string): T;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* AgentComponent is the atomic unit of work in the framework.
|
|
55
|
+
* Each component co-locates prompt, schema, validation, and retry policy.
|
|
56
|
+
*/
|
|
57
|
+
export interface AgentComponent<I = unknown, O = unknown> {
|
|
58
|
+
id: string;
|
|
59
|
+
inputSchema: ZodSchema<I>;
|
|
60
|
+
outputSchema: ZodSchema<O>;
|
|
61
|
+
buildPrompt(ctx: ExecutionContext<I>): Message[] | Promise<Message[]>;
|
|
62
|
+
tools?: Tool[];
|
|
63
|
+
validate(output: O, ctx: ExecutionContext<I>): ValidationResult;
|
|
64
|
+
retry?: {
|
|
65
|
+
maxAttempts: number;
|
|
66
|
+
/**
|
|
67
|
+
* When true (default), runtime automatically appends validation errors
|
|
68
|
+
* to the prompt on retry so the LLM can self-correct.
|
|
69
|
+
*/
|
|
70
|
+
feedbackOnError?: boolean;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Optional scope declaration for access control.
|
|
74
|
+
* Controls which stage outputs this component can access.
|
|
75
|
+
*
|
|
76
|
+
* @since 2.0.0
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* // Full access (default when undefined)
|
|
81
|
+
* scope: undefined
|
|
82
|
+
*
|
|
83
|
+
* // Limited visibility - can only access Stage1 and Stage2
|
|
84
|
+
* scope: {
|
|
85
|
+
* visibility: ["Stage1", "Stage2"]
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* // Read-only access - can see all but cannot modify
|
|
89
|
+
* scope: {
|
|
90
|
+
* visibility: "*",
|
|
91
|
+
* readonly: true
|
|
92
|
+
* }
|
|
93
|
+
*
|
|
94
|
+
* // Completely isolated - no dependencies
|
|
95
|
+
* scope: {
|
|
96
|
+
* isolated: true
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* // Dynamic visibility based on inputs
|
|
100
|
+
* scope: {
|
|
101
|
+
* visibility: (inputs) => inputs.useCache ? ["Stage1"] : ["Stage2"]
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* // Dynamic readonly based on inputs
|
|
105
|
+
* scope: {
|
|
106
|
+
* visibility: "*",
|
|
107
|
+
* readonly: (inputs) => inputs.mode === "readonly"
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
scope?: {
|
|
112
|
+
/**
|
|
113
|
+
* Stage IDs this component can access.
|
|
114
|
+
* - `"*"`: Can access all stages (default behavior)
|
|
115
|
+
* - `string[]`: Can only access listed stages
|
|
116
|
+
* - `[]`: Isolated - no stage dependencies
|
|
117
|
+
* - `(inputs: I) => string[] | "*"`: Dynamic visibility based on inputs
|
|
118
|
+
*
|
|
119
|
+
* @default "*" (when undefined)
|
|
120
|
+
*/
|
|
121
|
+
visibility?: string[] | "*" | ((inputs: I) => string[] | "*");
|
|
122
|
+
/**
|
|
123
|
+
* Whether this component can only read, not write.
|
|
124
|
+
* Useful for validation or analysis stages.
|
|
125
|
+
* Can be a boolean or a function that computes the readonly state based on inputs.
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
readonly?: boolean | ((inputs: I) => boolean);
|
|
130
|
+
/**
|
|
131
|
+
* Whether this component is completely isolated (no dependencies).
|
|
132
|
+
* Equivalent to `visibility: []`.
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
isolated?: boolean;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=stage.d.ts.map
|