@modular-prompt/process 0.1.11
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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/dialogue.d.ts +39 -0
- package/dist/modules/dialogue.d.ts.map +1 -0
- package/dist/modules/dialogue.js +106 -0
- package/dist/modules/dialogue.js.map +1 -0
- package/dist/modules/index.d.ts +9 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/material.d.ts +21 -0
- package/dist/modules/material.d.ts.map +1 -0
- package/dist/modules/material.js +41 -0
- package/dist/modules/material.js.map +1 -0
- package/dist/modules/stream-processing.d.ts +26 -0
- package/dist/modules/stream-processing.d.ts.map +1 -0
- package/dist/modules/stream-processing.js +128 -0
- package/dist/modules/stream-processing.js.map +1 -0
- package/dist/modules/summarize.d.ts +32 -0
- package/dist/modules/summarize.d.ts.map +1 -0
- package/dist/modules/summarize.js +97 -0
- package/dist/modules/summarize.js.map +1 -0
- package/dist/workflows/agent-workflow.d.ts +55 -0
- package/dist/workflows/agent-workflow.d.ts.map +1 -0
- package/dist/workflows/agent-workflow.js +337 -0
- package/dist/workflows/agent-workflow.js.map +1 -0
- package/dist/workflows/agentic-workflow/agentic-workflow.d.ts +13 -0
- package/dist/workflows/agentic-workflow/agentic-workflow.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/agentic-workflow.js +235 -0
- package/dist/workflows/agentic-workflow/agentic-workflow.js.map +1 -0
- package/dist/workflows/agentic-workflow/index.d.ts +4 -0
- package/dist/workflows/agentic-workflow/index.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/index.js +5 -0
- package/dist/workflows/agentic-workflow/index.js.map +1 -0
- package/dist/workflows/agentic-workflow/modules/agentic.d.ts +12 -0
- package/dist/workflows/agentic-workflow/modules/agentic.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/modules/agentic.js +22 -0
- package/dist/workflows/agentic-workflow/modules/agentic.js.map +1 -0
- package/dist/workflows/agentic-workflow/modules/execution-freeform.d.ts +15 -0
- package/dist/workflows/agentic-workflow/modules/execution-freeform.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/modules/execution-freeform.js +140 -0
- package/dist/workflows/agentic-workflow/modules/execution-freeform.js.map +1 -0
- package/dist/workflows/agentic-workflow/modules/execution.d.ts +11 -0
- package/dist/workflows/agentic-workflow/modules/execution.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/modules/execution.js +180 -0
- package/dist/workflows/agentic-workflow/modules/execution.js.map +1 -0
- package/dist/workflows/agentic-workflow/modules/index.d.ts +6 -0
- package/dist/workflows/agentic-workflow/modules/index.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/modules/index.js +7 -0
- package/dist/workflows/agentic-workflow/modules/index.js.map +1 -0
- package/dist/workflows/agentic-workflow/modules/integration.d.ts +11 -0
- package/dist/workflows/agentic-workflow/modules/integration.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/modules/integration.js +85 -0
- package/dist/workflows/agentic-workflow/modules/integration.js.map +1 -0
- package/dist/workflows/agentic-workflow/modules/planning.d.ts +11 -0
- package/dist/workflows/agentic-workflow/modules/planning.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/modules/planning.js +103 -0
- package/dist/workflows/agentic-workflow/modules/planning.js.map +1 -0
- package/dist/workflows/agentic-workflow/types.d.ts +60 -0
- package/dist/workflows/agentic-workflow/types.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/types.js +2 -0
- package/dist/workflows/agentic-workflow/types.js.map +1 -0
- package/dist/workflows/concat-process-workflow.d.ts +29 -0
- package/dist/workflows/concat-process-workflow.d.ts.map +1 -0
- package/dist/workflows/concat-process-workflow.js +121 -0
- package/dist/workflows/concat-process-workflow.js.map +1 -0
- package/dist/workflows/dialogue-workflow.d.ts +25 -0
- package/dist/workflows/dialogue-workflow.d.ts.map +1 -0
- package/dist/workflows/dialogue-workflow.js +139 -0
- package/dist/workflows/dialogue-workflow.js.map +1 -0
- package/dist/workflows/index.d.ts +14 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +13 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/self-prompting-workflow/index.d.ts +12 -0
- package/dist/workflows/self-prompting-workflow/index.d.ts.map +1 -0
- package/dist/workflows/self-prompting-workflow/index.js +11 -0
- package/dist/workflows/self-prompting-workflow/index.js.map +1 -0
- package/dist/workflows/self-prompting-workflow/modules/integration.d.ts +11 -0
- package/dist/workflows/self-prompting-workflow/modules/integration.d.ts.map +1 -0
- package/dist/workflows/self-prompting-workflow/modules/integration.js +82 -0
- package/dist/workflows/self-prompting-workflow/modules/integration.js.map +1 -0
- package/dist/workflows/self-prompting-workflow/modules/planning.d.ts +11 -0
- package/dist/workflows/self-prompting-workflow/modules/planning.d.ts.map +1 -0
- package/dist/workflows/self-prompting-workflow/modules/planning.js +108 -0
- package/dist/workflows/self-prompting-workflow/modules/planning.js.map +1 -0
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.d.ts +14 -0
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.d.ts.map +1 -0
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.js +250 -0
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.js.map +1 -0
- package/dist/workflows/self-prompting-workflow/types.d.ts +56 -0
- package/dist/workflows/self-prompting-workflow/types.d.ts.map +1 -0
- package/dist/workflows/self-prompting-workflow/types.js +2 -0
- package/dist/workflows/self-prompting-workflow/types.js.map +1 -0
- package/dist/workflows/stream-workflow.d.ts +17 -0
- package/dist/workflows/stream-workflow.d.ts.map +1 -0
- package/dist/workflows/stream-workflow.js +119 -0
- package/dist/workflows/stream-workflow.js.map +1 -0
- package/dist/workflows/summarize-workflow.d.ts +39 -0
- package/dist/workflows/summarize-workflow.d.ts.map +1 -0
- package/dist/workflows/summarize-workflow.js +152 -0
- package/dist/workflows/summarize-workflow.js.map +1 -0
- package/dist/workflows/types.d.ts +37 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/types.js +25 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { compile, merge } from '@modular-prompt/core';
|
|
2
|
+
import { WorkflowExecutionError } from '../types.js';
|
|
3
|
+
import { agentic } from './modules/agentic.js';
|
|
4
|
+
import { planning } from './modules/planning.js';
|
|
5
|
+
import { execution } from './modules/execution.js';
|
|
6
|
+
import { executionFreeform } from './modules/execution-freeform.js';
|
|
7
|
+
import { integration } from './modules/integration.js';
|
|
8
|
+
/**
|
|
9
|
+
* Execute planning phase
|
|
10
|
+
*/
|
|
11
|
+
async function executePlanningPhase(driver, module, context, maxSteps, logger) {
|
|
12
|
+
const planningModule = merge(agentic, planning, module);
|
|
13
|
+
const prompt = compile(planningModule, context);
|
|
14
|
+
try {
|
|
15
|
+
const planResult = await driver.query(prompt);
|
|
16
|
+
logger?.debug('Planning phase - AI generated:', planResult.content);
|
|
17
|
+
// Check finish reason
|
|
18
|
+
if (planResult.finishReason && planResult.finishReason !== 'stop') {
|
|
19
|
+
throw new WorkflowExecutionError(`Planning failed with reason: ${planResult.finishReason}`, context, {
|
|
20
|
+
phase: 'planning',
|
|
21
|
+
finishReason: planResult.finishReason
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// Get plan from structured output
|
|
25
|
+
if (!planResult.structuredOutput) {
|
|
26
|
+
throw new WorkflowExecutionError('Planning did not return structured output', context, {
|
|
27
|
+
phase: 'planning',
|
|
28
|
+
partialResult: planResult.content
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const plan = planResult.structuredOutput;
|
|
32
|
+
// Validate and limit steps
|
|
33
|
+
if (!plan.steps || !Array.isArray(plan.steps)) {
|
|
34
|
+
throw new WorkflowExecutionError('Invalid plan structure: steps is not an array', context, {
|
|
35
|
+
phase: 'planning',
|
|
36
|
+
partialResult: JSON.stringify(planResult.structuredOutput)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// Limit number of steps
|
|
40
|
+
if (plan.steps.length > maxSteps) {
|
|
41
|
+
plan.steps = plan.steps.slice(0, maxSteps);
|
|
42
|
+
}
|
|
43
|
+
return plan;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error instanceof WorkflowExecutionError) {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
throw new WorkflowExecutionError(error, context, {
|
|
50
|
+
phase: 'planning'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Execute a single step
|
|
56
|
+
*/
|
|
57
|
+
async function executeStep(driver, module, context, step, actions, executionLog, useFreeform, logger) {
|
|
58
|
+
// Execute actions if specified
|
|
59
|
+
let actionResult;
|
|
60
|
+
if (step.actions && step.actions.length > 0) {
|
|
61
|
+
for (const action of step.actions) {
|
|
62
|
+
if (actions[action.tool]) {
|
|
63
|
+
try {
|
|
64
|
+
actionResult = await actions[action.tool](action.params, context);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw new WorkflowExecutionError(`Tool '${action.tool}' failed: ${error.message}`, {
|
|
68
|
+
...context,
|
|
69
|
+
executionLog,
|
|
70
|
+
currentStep: step
|
|
71
|
+
}, {
|
|
72
|
+
phase: 'execution',
|
|
73
|
+
partialResult: executionLog.map(log => log.result).join('\n\n')
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Execute step with AI
|
|
80
|
+
const executionPhaseModule = useFreeform ? executionFreeform : execution;
|
|
81
|
+
// For freeform mode, omit user's instructions to use plan-based guidelines/constraints instead
|
|
82
|
+
// For structured mode, use user's instructions as-is
|
|
83
|
+
const userModule = useFreeform
|
|
84
|
+
? { ...module, instructions: undefined }
|
|
85
|
+
: module;
|
|
86
|
+
const executionModule = merge(agentic, executionPhaseModule, userModule);
|
|
87
|
+
const stepContext = {
|
|
88
|
+
...context,
|
|
89
|
+
currentStep: step,
|
|
90
|
+
actionResult,
|
|
91
|
+
executionLog
|
|
92
|
+
};
|
|
93
|
+
const prompt = compile(executionModule, stepContext);
|
|
94
|
+
try {
|
|
95
|
+
const stepResult = await driver.query(prompt);
|
|
96
|
+
logger?.debug(`Execution step ${step.id} - AI generated:`, stepResult.content);
|
|
97
|
+
// Check finish reason
|
|
98
|
+
if (stepResult.finishReason && stepResult.finishReason !== 'stop') {
|
|
99
|
+
throw new WorkflowExecutionError(`Step execution failed with reason: ${stepResult.finishReason}`, stepContext, {
|
|
100
|
+
phase: 'execution',
|
|
101
|
+
partialResult: executionLog.map(log => log.result).join('\n\n'),
|
|
102
|
+
finishReason: stepResult.finishReason
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Get reasoning, result and nextState from structured output
|
|
106
|
+
let reasoning;
|
|
107
|
+
let result;
|
|
108
|
+
let nextState;
|
|
109
|
+
if (stepResult.structuredOutput) {
|
|
110
|
+
const output = stepResult.structuredOutput;
|
|
111
|
+
reasoning = output.reasoning || '';
|
|
112
|
+
result = output.result || stepResult.content;
|
|
113
|
+
nextState = output.nextState || '';
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// Fallback if structured output is not available
|
|
117
|
+
reasoning = '';
|
|
118
|
+
result = stepResult.content;
|
|
119
|
+
nextState = '';
|
|
120
|
+
}
|
|
121
|
+
// Update context state with nextState for the next step
|
|
122
|
+
context.state = {
|
|
123
|
+
content: nextState,
|
|
124
|
+
usage: stepResult.usage?.totalTokens
|
|
125
|
+
};
|
|
126
|
+
// Create execution log entry (without nextState - it's in context.state now)
|
|
127
|
+
return {
|
|
128
|
+
stepId: step.id,
|
|
129
|
+
reasoning,
|
|
130
|
+
result,
|
|
131
|
+
actionResult,
|
|
132
|
+
metadata: {
|
|
133
|
+
usage: stepResult.usage
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof WorkflowExecutionError) {
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
throw new WorkflowExecutionError(error, stepContext, {
|
|
142
|
+
phase: 'execution',
|
|
143
|
+
partialResult: executionLog.map(log => log.result).join('\n\n')
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Execute execution phase
|
|
149
|
+
*/
|
|
150
|
+
async function executeExecutionPhase(driver, module, context, plan, actions, useFreeform, logger) {
|
|
151
|
+
const executionLog = context.executionLog || [];
|
|
152
|
+
// Determine starting position (for resumption)
|
|
153
|
+
const startIndex = executionLog.length;
|
|
154
|
+
// Execute each step
|
|
155
|
+
for (let i = startIndex; i < plan.steps.length; i++) {
|
|
156
|
+
const step = plan.steps[i];
|
|
157
|
+
const logEntry = await executeStep(driver, module, context, step, actions, executionLog, useFreeform, logger);
|
|
158
|
+
executionLog.push(logEntry);
|
|
159
|
+
}
|
|
160
|
+
return executionLog;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Execute integration phase
|
|
164
|
+
*/
|
|
165
|
+
async function executeIntegrationPhase(driver, module, context, executionLog, logger) {
|
|
166
|
+
const integrationModule = merge(agentic, integration, module);
|
|
167
|
+
const finalPrompt = compile(integrationModule, context);
|
|
168
|
+
try {
|
|
169
|
+
const integrationResult = await driver.query(finalPrompt);
|
|
170
|
+
logger?.debug('Integration phase - AI generated:', integrationResult.content);
|
|
171
|
+
// Check finish reason
|
|
172
|
+
if (integrationResult.finishReason && integrationResult.finishReason !== 'stop') {
|
|
173
|
+
throw new WorkflowExecutionError(`Integration failed with reason: ${integrationResult.finishReason}`, context, {
|
|
174
|
+
phase: 'integration',
|
|
175
|
+
partialResult: executionLog.map(log => log.result).join('\n\n'),
|
|
176
|
+
finishReason: integrationResult.finishReason
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return integrationResult.content;
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error instanceof WorkflowExecutionError) {
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
throw new WorkflowExecutionError(error, context, {
|
|
186
|
+
phase: 'integration',
|
|
187
|
+
partialResult: executionLog.map(log => log.result).join('\n\n')
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Agentic workflow - autonomous multi-step processing with planning
|
|
193
|
+
*
|
|
194
|
+
* Flow:
|
|
195
|
+
* 1. Planning phase: Generate execution plan using structured outputs
|
|
196
|
+
* 2. Execution phase: Execute each step (with optional actions)
|
|
197
|
+
* 3. Integration phase: Integrate results and generate final output
|
|
198
|
+
*/
|
|
199
|
+
export async function agenticProcess(driver, module, context, options = {}) {
|
|
200
|
+
const { maxSteps = 5, actions = {}, enablePlanning = true, useFreeformExecution = false, logger } = options;
|
|
201
|
+
let currentContext = { ...context };
|
|
202
|
+
let plan;
|
|
203
|
+
// Phase 1: Planning
|
|
204
|
+
if (enablePlanning && !currentContext.plan) {
|
|
205
|
+
currentContext.phase = 'planning';
|
|
206
|
+
plan = await executePlanningPhase(driver, module, currentContext, maxSteps, logger);
|
|
207
|
+
currentContext.plan = plan;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// Use existing plan
|
|
211
|
+
plan = currentContext.plan;
|
|
212
|
+
}
|
|
213
|
+
// Phase 2: Execution
|
|
214
|
+
currentContext.phase = 'execution';
|
|
215
|
+
const executionLog = await executeExecutionPhase(driver, module, currentContext, plan, actions, useFreeformExecution, logger);
|
|
216
|
+
currentContext.executionLog = executionLog;
|
|
217
|
+
// Phase 3: Integration
|
|
218
|
+
currentContext.phase = 'integration';
|
|
219
|
+
const finalOutput = await executeIntegrationPhase(driver, module, currentContext, executionLog, logger);
|
|
220
|
+
// Complete
|
|
221
|
+
const finalContext = {
|
|
222
|
+
...currentContext,
|
|
223
|
+
phase: 'complete'
|
|
224
|
+
};
|
|
225
|
+
return {
|
|
226
|
+
output: finalOutput,
|
|
227
|
+
context: finalContext,
|
|
228
|
+
metadata: {
|
|
229
|
+
planSteps: plan.steps.length,
|
|
230
|
+
executedSteps: executionLog.length,
|
|
231
|
+
actionsUsed: executionLog.filter(log => log.actionResult !== undefined).length
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=agentic-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentic-workflow.js","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/agentic-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;GAEG;AACH,KAAK,UAAU,oBAAoB,CACjC,MAAgB,EAChB,MAA4C,EAC5C,OAA+B,EAC/B,QAAgB,EAChB,MAAY;IAEZ,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE9C,MA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cAAc,CAAC,YAAY,GAAG,YAAY,CAAC;IAE3C,uBAAuB;IACvB,cAAc,CAAC,KAAK,GAAG,aAAa,CAAC;IACrC,MAAM,WAAW,GAAG,MAAM,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAExG,WAAW;IACX,MAAM,YAAY,GAA2B;QAC3C,GAAG,cAAc;QACjB,KAAK,EAAE,UAAU;KAClB,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,YAAY;QACrB,QAAQ,EAAE;YACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YAC5B,aAAa,EAAE,YAAY,CAAC,MAAM;YAClC,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,MAAM;SAC/E;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { agenticProcess } from './agentic-workflow.js';
|
|
2
|
+
export type { AgenticWorkflowContext, AgenticWorkflowOptions, ActionHandler } from './types.js';
|
|
3
|
+
export { agentic, planning, execution, executionFreeform, integration } from './modules/index.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,WAAW,EACZ,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AASvD,UAAU;AACV,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,WAAW,EACZ,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PromptModule } from '@modular-prompt/core';
|
|
2
|
+
import type { AgenticWorkflowContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Agentic module - Common definitions for agent workflow
|
|
5
|
+
* Defines the basic behavior and terminology for agentic processing
|
|
6
|
+
* This module is shared across all phases (planning, execution, integration)
|
|
7
|
+
*
|
|
8
|
+
* This module should be merged with user's module:
|
|
9
|
+
* agentProcess(driver, merge(agenticModule, userModule), context)
|
|
10
|
+
*/
|
|
11
|
+
export declare const agentic: PromptModule<AgenticWorkflowContext>;
|
|
12
|
+
//# sourceMappingURL=agentic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentic.d.ts","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/modules/agentic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAAE,YAAY,CAAC,sBAAsB,CAaxD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic module - Common definitions for agent workflow
|
|
3
|
+
* Defines the basic behavior and terminology for agentic processing
|
|
4
|
+
* This module is shared across all phases (planning, execution, integration)
|
|
5
|
+
*
|
|
6
|
+
* This module should be merged with user's module:
|
|
7
|
+
* agentProcess(driver, merge(agenticModule, userModule), context)
|
|
8
|
+
*/
|
|
9
|
+
export const agentic = {
|
|
10
|
+
terms: [
|
|
11
|
+
'- Execution Plan: Objective and Instructions broken down into executable steps',
|
|
12
|
+
'- Action: External tool/API to use during execution (e.g., data retrieval, calculations)'
|
|
13
|
+
],
|
|
14
|
+
methodology: [
|
|
15
|
+
'- Agentic workflow executes complex tasks through multi-step processing.',
|
|
16
|
+
'- This workflow has three phases: Planning → Execution → Integration.',
|
|
17
|
+
' - Planning: analyzes the objective to create an execution plan.',
|
|
18
|
+
' - Execution: processes each step sequentially, recording results.',
|
|
19
|
+
' - Integration: combines all results into the final output.'
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=agentic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentic.js","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/modules/agentic.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAyC;IAC3D,KAAK,EAAE;QACL,gFAAgF;QAChF,0FAA0F;KAC3F;IAED,WAAW,EAAE;QACX,0EAA0E;QAC1E,uEAAuE;QACvE,mEAAmE;QACnE,qEAAqE;QACrE,8DAA8D;KAC/D;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PromptModule } from '@modular-prompt/core';
|
|
2
|
+
import type { AgenticWorkflowContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Execution phase module (freeform version) for agent workflow
|
|
5
|
+
*
|
|
6
|
+
* This version differs from the standard execution module:
|
|
7
|
+
* - Uses planned dos/donts as instructions (not fixed process steps)
|
|
8
|
+
* - Outputs freeform text (not structured JSON)
|
|
9
|
+
* - Accumulates all previous step decisions
|
|
10
|
+
*
|
|
11
|
+
* Should be merged with agentic and user's module:
|
|
12
|
+
* merge(agentic, executionFreeform, userModule)
|
|
13
|
+
*/
|
|
14
|
+
export declare const executionFreeform: PromptModule<AgenticWorkflowContext>;
|
|
15
|
+
//# sourceMappingURL=execution-freeform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-freeform.d.ts","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/modules/execution-freeform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,sBAAsB,CAmJlE,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution phase module (freeform version) for agent workflow
|
|
3
|
+
*
|
|
4
|
+
* This version differs from the standard execution module:
|
|
5
|
+
* - Uses planned dos/donts as instructions (not fixed process steps)
|
|
6
|
+
* - Outputs freeform text (not structured JSON)
|
|
7
|
+
* - Accumulates all previous step decisions
|
|
8
|
+
*
|
|
9
|
+
* Should be merged with agentic and user's module:
|
|
10
|
+
* merge(agentic, executionFreeform, userModule)
|
|
11
|
+
*/
|
|
12
|
+
export const executionFreeform = {
|
|
13
|
+
methodology: [
|
|
14
|
+
(ctx) => {
|
|
15
|
+
const currentStepIndex = (ctx.executionLog?.length || 0) + 1;
|
|
16
|
+
const totalSteps = ctx.plan?.steps.length || 0;
|
|
17
|
+
return [
|
|
18
|
+
`- **Current Phase: Execution (Step ${currentStepIndex}/${totalSteps})**`,
|
|
19
|
+
' - Execute only the current step of the execution plan.',
|
|
20
|
+
' - Follow the dos/don\'ts specified in the plan.',
|
|
21
|
+
' - Output the reasoning process and results as natural text.',
|
|
22
|
+
''
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
// Replace user's instructions with plan-based dos/donts
|
|
27
|
+
// Note: User's original instructions are omitted in agentic-workflow.ts
|
|
28
|
+
instructions: [
|
|
29
|
+
(ctx) => {
|
|
30
|
+
const items = [];
|
|
31
|
+
// Add current step description first
|
|
32
|
+
if (ctx.currentStep?.description) {
|
|
33
|
+
items.push(ctx.currentStep.description);
|
|
34
|
+
items.push('');
|
|
35
|
+
}
|
|
36
|
+
// Add general execution guidelines
|
|
37
|
+
items.push('');
|
|
38
|
+
items.push('**Requirements:**');
|
|
39
|
+
if (ctx.executionLog && ctx.executionLog.length > 0) {
|
|
40
|
+
items.push('- Read and understand the previous step\'s decisions (shown in Data section below)');
|
|
41
|
+
items.push('- Use that understanding to complete THIS step\'s task');
|
|
42
|
+
items.push('- Produce only NEW content for this step');
|
|
43
|
+
items.push('- Do NOT copy or reproduce the previous outputs');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
items.push('- Focus on the current step instructions only');
|
|
47
|
+
}
|
|
48
|
+
items.push('- Concise output is acceptable');
|
|
49
|
+
// Add guidelines
|
|
50
|
+
if (ctx.currentStep?.guidelines && ctx.currentStep.guidelines.length > 0) {
|
|
51
|
+
items.push('');
|
|
52
|
+
items.push('**Guidelines:**');
|
|
53
|
+
ctx.currentStep.guidelines.forEach((item) => items.push(`- ${item}`));
|
|
54
|
+
}
|
|
55
|
+
// Add constraints
|
|
56
|
+
if (ctx.currentStep?.constraints && ctx.currentStep.constraints.length > 0) {
|
|
57
|
+
items.push('');
|
|
58
|
+
items.push('**Constraints:**');
|
|
59
|
+
ctx.currentStep.constraints.forEach((item) => items.push(`- ${item}`));
|
|
60
|
+
}
|
|
61
|
+
return items;
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
state: [
|
|
65
|
+
(ctx) => {
|
|
66
|
+
const completed = ctx.executionLog?.length || 0;
|
|
67
|
+
const total = ctx.plan?.steps.length || 0;
|
|
68
|
+
return `Progress: ${completed}/${total} steps completed`;
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
inputs: [
|
|
72
|
+
(ctx) => ctx.inputs ? JSON.stringify(ctx.inputs, null, 2) : null
|
|
73
|
+
],
|
|
74
|
+
materials: [
|
|
75
|
+
(ctx) => {
|
|
76
|
+
if (ctx.actionResult === undefined) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
type: 'material',
|
|
81
|
+
id: 'action-result',
|
|
82
|
+
title: 'Action execution result for current step',
|
|
83
|
+
content: typeof ctx.actionResult === 'string'
|
|
84
|
+
? ctx.actionResult
|
|
85
|
+
: JSON.stringify(ctx.actionResult, null, 2)
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
(ctx) => {
|
|
89
|
+
if (!ctx.executionLog || ctx.executionLog.length === 0) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return ctx.executionLog.map((log, index) => {
|
|
93
|
+
const parts = [];
|
|
94
|
+
// Add the step's instructions first
|
|
95
|
+
const stepIndex = index;
|
|
96
|
+
if (ctx.plan?.steps[stepIndex]) {
|
|
97
|
+
const step = ctx.plan.steps[stepIndex];
|
|
98
|
+
const instructionsParts = [];
|
|
99
|
+
if (step.description) {
|
|
100
|
+
instructionsParts.push(step.description);
|
|
101
|
+
}
|
|
102
|
+
if (step.guidelines && step.guidelines.length > 0) {
|
|
103
|
+
instructionsParts.push('');
|
|
104
|
+
instructionsParts.push('**Guidelines:**');
|
|
105
|
+
step.guidelines.forEach((item) => instructionsParts.push(`- ${item}`));
|
|
106
|
+
}
|
|
107
|
+
if (step.constraints && step.constraints.length > 0) {
|
|
108
|
+
instructionsParts.push('');
|
|
109
|
+
instructionsParts.push('**Constraints:**');
|
|
110
|
+
step.constraints.forEach((item) => instructionsParts.push(`- ${item}`));
|
|
111
|
+
}
|
|
112
|
+
if (instructionsParts.length > 0) {
|
|
113
|
+
parts.push(`[Instructions]\n${instructionsParts.join('\n')}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (log.reasoning) {
|
|
117
|
+
parts.push(`[Reasoning]\n${log.reasoning}`);
|
|
118
|
+
}
|
|
119
|
+
parts.push(`[Result]\n${log.result}`);
|
|
120
|
+
if (log.actionResult !== undefined) {
|
|
121
|
+
const actionResultStr = typeof log.actionResult === 'string'
|
|
122
|
+
? log.actionResult
|
|
123
|
+
: JSON.stringify(log.actionResult, null, 2);
|
|
124
|
+
parts.push(`[Action Result]\n${actionResultStr}`);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
type: 'material',
|
|
128
|
+
id: `execution-decision-${log.stepId}`,
|
|
129
|
+
title: `Previous step decision: ${log.stepId}`,
|
|
130
|
+
content: parts.join('\n\n')
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
cue: [
|
|
136
|
+
'IMPORTANT: Follow the Instructions above carefully.',
|
|
137
|
+
'Output only what is required for THIS step based on the Requirements.'
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=execution-freeform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-freeform.js","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/modules/execution-freeform.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAyC;IACrE,WAAW,EAAE;QACX,CAAC,GAA2B,EAAE,EAAE;YAC9B,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;YAC/C,OAAO;gBACL,sCAAsC,gBAAgB,IAAI,UAAU,KAAK;gBACzE,0DAA0D;gBAC1D,mDAAmD;gBACnD,+DAA+D;gBAC/D,EAAE;aACH,CAAC;QACJ,CAAC;KACF;IAED,wDAAwD;IACxD,wEAAwE;IACxE,YAAY,EAAE;QACZ,CAAC,GAA2B,EAAE,EAAE;YAC9B,MAAM,KAAK,GAAa,EAAE,CAAC;YAE3B,qCAAqC;YACrC,IAAI,GAAG,CAAC,WAAW,EAAE,WAA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,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;oBAClF,CAAC;oBAED,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACjC,KAAK,CAAC,IAAI,CAAC,mBAAmB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAChE,CAAC;gBACH,CAAC;gBAED,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;oBAClB,KAAK,CAAC,IAAI,CAAC,gBAAgB,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;gBAC9C,CAAC;gBAED,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;gBAEtC,IAAI,GAAG,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;oBACnC,MAAM,eAAe,GAAG,OAAO,GAAG,CAAC,YAAY,KAAK,QAAQ;wBAC1D,CAAC,CAAC,GAAG,CAAC,YAAY;wBAClB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;oBAC9C,KAAK,CAAC,IAAI,CAAC,oBAAoB,eAAe,EAAE,CAAC,CAAC;gBACpD,CAAC;gBAED,OAAO;oBACL,IAAI,EAAE,UAAmB;oBACzB,EAAE,EAAE,sBAAsB,GAAG,CAAC,MAAM,EAAE;oBACtC,KAAK,EAAE,2BAA2B,GAAG,CAAC,MAAM,EAAE;oBAC9C,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;iBAC5B,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF;IAED,GAAG,EAAE;QACH,qDAAqD;QACrD,uEAAuE;KACxE;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PromptModule } from '@modular-prompt/core';
|
|
2
|
+
import type { AgenticWorkflowContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Execution phase module for agent workflow
|
|
5
|
+
* Phase-specific definitions for executing a single step
|
|
6
|
+
*
|
|
7
|
+
* Should be merged with agentic and user's module:
|
|
8
|
+
* merge(agentic, execution, userModule)
|
|
9
|
+
*/
|
|
10
|
+
export declare const execution: PromptModule<AgenticWorkflowContext>;
|
|
11
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/modules/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAe,MAAM,aAAa,CAAC;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,YAAY,CAAC,sBAAsB,CAsM1D,CAAC"}
|