@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,32 @@
|
|
|
1
|
+
import type { PromptModule } from '@modular-prompt/core';
|
|
2
|
+
/**
|
|
3
|
+
* Context for summarization modules
|
|
4
|
+
*/
|
|
5
|
+
export interface SummarizeContext {
|
|
6
|
+
state?: {
|
|
7
|
+
content: string;
|
|
8
|
+
usage?: number;
|
|
9
|
+
};
|
|
10
|
+
chunks?: Array<{
|
|
11
|
+
content: string;
|
|
12
|
+
partOf?: string;
|
|
13
|
+
usage?: number;
|
|
14
|
+
}>;
|
|
15
|
+
preparationNote?: {
|
|
16
|
+
content: string;
|
|
17
|
+
};
|
|
18
|
+
targetTokens?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Base summarization module
|
|
22
|
+
*/
|
|
23
|
+
export declare const summarizeBase: PromptModule<SummarizeContext>;
|
|
24
|
+
/**
|
|
25
|
+
* Analysis module for summary preparation
|
|
26
|
+
*/
|
|
27
|
+
export declare const analyzeForSummary: PromptModule<SummarizeContext>;
|
|
28
|
+
/**
|
|
29
|
+
* Content summarization module
|
|
30
|
+
*/
|
|
31
|
+
export declare const contentSummarize: PromptModule<SummarizeContext>;
|
|
32
|
+
//# sourceMappingURL=summarize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../src/modules/summarize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,sBAAsB,CAAC;AAEzF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,eAAe,CAAC,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,gBAAgB,CAIxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,gBAAgB,CA+C5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,gBAAgB,CAuC3D,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base summarization module
|
|
3
|
+
*/
|
|
4
|
+
export const summarizeBase = {
|
|
5
|
+
objective: [
|
|
6
|
+
'The streaming process generates a summary. The Current State is the summary up to the previous iteration, which is merged with the summary of the chunks given in this iteration and output as the Next State.'
|
|
7
|
+
]
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Analysis module for summary preparation
|
|
11
|
+
*/
|
|
12
|
+
export const analyzeForSummary = {
|
|
13
|
+
objective: [
|
|
14
|
+
'The purpose of this streaming process is to generate an Analysis Report of the source text. The focus should be on the analysis results, not on preserving the original content of the source text. The process holds the text of the analysis results up to that point as the State, and updates it with each iteration.'
|
|
15
|
+
],
|
|
16
|
+
terms: [
|
|
17
|
+
'Analysis Report: The analysis result of the source text. It consists of the following sections: Purpose of the Text, Document Structure, Overview, and Metadata Insights.'
|
|
18
|
+
],
|
|
19
|
+
instructions: [
|
|
20
|
+
'Please ensure that only the Next State, which should be the updated analysis report considering this iteration\'s results, is outputted. It should not include the original source text of the Input Chunks.',
|
|
21
|
+
{
|
|
22
|
+
type: 'subsection',
|
|
23
|
+
content: '',
|
|
24
|
+
title: 'Algorithm',
|
|
25
|
+
items: [
|
|
26
|
+
'Steps:',
|
|
27
|
+
'1. The Current State is the Analyze Report up to the previous iteration. Please read and understand it carefully.',
|
|
28
|
+
'2. Analyze the content of the chunk given in this iteration.',
|
|
29
|
+
'3. Follow the procedures outlined in the "Section Definitions & Procedures of Analysis Report" to merge and update the analysis result of this iteration into each section, thereby generating a new Analysis Report. If there is no particular information to be incorporated into the report, simply ignore it and the Next State will remain as the unchanged Current State.',
|
|
30
|
+
'4. Output the entire new Analysis Report as the Next State.'
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
guidelines: [
|
|
35
|
+
'Please note that the Analysis Report created in the current iteration does not need to be complete. Perform the analysis based solely on the input data.',
|
|
36
|
+
{
|
|
37
|
+
type: 'subsection',
|
|
38
|
+
content: '',
|
|
39
|
+
title: 'Section Definitions & Procedures of Analysis Report',
|
|
40
|
+
items: [
|
|
41
|
+
'1. Purpose of the Text:',
|
|
42
|
+
' - Definition: You should include one or a few paragraphs that analytically interpret the purpose of the source text and summarize it concisely. This often includes content found in the introduction or summary of the original text.',
|
|
43
|
+
' - Procedure: Read the source text, understand its purpose, and summarize it concisely.',
|
|
44
|
+
'2. Document Structure:',
|
|
45
|
+
' - Definition: You should list the titles of the chapters in bullet point format, including chapter numbers if they exist. If the chapters are not clear, provide a concise list of the text structure.',
|
|
46
|
+
' - Procedure: Given the sequential nature of the chunks, collect all chapter headers in an appending process, ensuring no part of the structure, including nested sections, is missed.',
|
|
47
|
+
'3. Overview:',
|
|
48
|
+
' - Definition: This is a broad summary of the original text. Discard the details and condense the main arguments of the entire text into a few paragraphs.',
|
|
49
|
+
' - Procedure: Merge the information of the given chunk into the already existing text of 3. In other words, update the overall summary while incorporating new information.',
|
|
50
|
+
'4. Metadata Insights:',
|
|
51
|
+
' - Definition: This section is intended to hold aggregated metadata that provides a broader understanding of the source text.',
|
|
52
|
+
' - Procedure: Identify and collect metadata such as the date of text creation, keywords, significant references, and a possible summary of the comment section from the source text.'
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Content summarization module
|
|
59
|
+
*/
|
|
60
|
+
export const contentSummarize = {
|
|
61
|
+
objective: [
|
|
62
|
+
'The assistant is a software engineer who prepares the condensed output text that replaces the source text.',
|
|
63
|
+
'The amount of information should be adjusted to meet that value as much as possible without exceeding the target size. In particular, the max_tokens limit must be observed.'
|
|
64
|
+
],
|
|
65
|
+
terms: [
|
|
66
|
+
'Analysis Report: This represents the analysis results of the input chunks. It may not be perfect and could contain errors or omissions. However, it can be used to grasp an overall understanding that cannot be obtained from individual chunks. Always refer back to the input chunks for the most accurate information.'
|
|
67
|
+
],
|
|
68
|
+
instructions: [
|
|
69
|
+
{
|
|
70
|
+
type: 'subsection',
|
|
71
|
+
content: '',
|
|
72
|
+
title: 'Algorithm',
|
|
73
|
+
items: [
|
|
74
|
+
'1. Start by reviewing the Analysis Report to understand the overall structure and content of the source text.',
|
|
75
|
+
'2. Identify the type of the given Data Chunks (e.g., whether it\'s a descriptive text, a conversation log, etc.), and understand how each chunk is positioned within the overall context.',
|
|
76
|
+
'3. Understand the structure of the Data Chunk texts, such as its chapters, and discern what is being asserted in each part.',
|
|
77
|
+
'4. Summarize the content being asserted in each block of the Data Chunk texts, using the Analysis Report as a guide to ensure the summaries align with the overall understanding of the source text.',
|
|
78
|
+
'5. Merge the summaries from step 4 with the content of the Current Text State, and format it into a continuous, natural text.',
|
|
79
|
+
'6. Output the entire text generated in step 5 without blocking or fragmenting it.'
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
guidelines: [
|
|
84
|
+
'If the Analysis Report includes an overview or summary of the source text, use this as a starting point for the summary, and then add more detail from the Data Chunks as needed.'
|
|
85
|
+
],
|
|
86
|
+
preparationNote: [
|
|
87
|
+
(context) => {
|
|
88
|
+
if (!context.preparationNote?.content)
|
|
89
|
+
return null;
|
|
90
|
+
return {
|
|
91
|
+
type: 'text',
|
|
92
|
+
content: context.preparationNote.content
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=summarize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarize.js","sourceRoot":"","sources":["../../src/modules/summarize.ts"],"names":[],"mappings":"AAqBA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAmC;IAC3D,SAAS,EAAE;QACT,gNAAgN;KACjN;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAC/D,SAAS,EAAE;QACT,2TAA2T;KAC5T;IAED,KAAK,EAAE;QACL,2KAA2K;KAC5K;IAED,YAAY,EAAE;QACZ,8MAA8M;QAC9M;YACE,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE;gBACL,QAAQ;gBACR,mHAAmH;gBACnH,8DAA8D;gBAC9D,iXAAiX;gBACjX,6DAA6D;aAC9D;SACmB;KACvB;IAED,UAAU,EAAE;QACV,0JAA0J;QAC1J;YACE,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,qDAAqD;YAC5D,KAAK,EAAE;gBACL,yBAAyB;gBACzB,0OAA0O;gBAC1O,0FAA0F;gBAC1F,wBAAwB;gBACxB,0MAA0M;gBAC1M,yLAAyL;gBACzL,cAAc;gBACd,6JAA6J;gBAC7J,8KAA8K;gBAC9K,uBAAuB;gBACvB,gIAAgI;gBAChI,uLAAuL;aACxL;SACmB;KACvB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAmC;IAC9D,SAAS,EAAE;QACT,4GAA4G;QAC5G,8KAA8K;KAC/K;IAED,KAAK,EAAE;QACL,4TAA4T;KAC7T;IAED,YAAY,EAAE;QACZ;YACE,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE;gBACL,+GAA+G;gBAC/G,2LAA2L;gBAC3L,6HAA6H;gBAC7H,sMAAsM;gBACtM,+HAA+H;gBAC/H,mFAAmF;aACpF;SACmB;KACvB;IAED,UAAU,EAAE;QACV,mLAAmL;KACpL;IAED,eAAe,EAAE;QACf,CAAC,OAAO,EAAE,EAAE;YACV,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO;gBAAE,OAAO,IAAI,CAAC;YACnD,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,OAAO;aAC1B,CAAC;QACnB,CAAC;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PromptModule } from '@modular-prompt/core';
|
|
2
|
+
import type { AIDriver, WorkflowResult } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Agent workflow plan step definition
|
|
5
|
+
*/
|
|
6
|
+
interface AgentWorkflowStep {
|
|
7
|
+
id: string;
|
|
8
|
+
description: string;
|
|
9
|
+
action?: string;
|
|
10
|
+
params?: any;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Execution log entry
|
|
14
|
+
*/
|
|
15
|
+
interface AgentWorkflowExecutionLog {
|
|
16
|
+
stepId: string;
|
|
17
|
+
result: string;
|
|
18
|
+
metadata?: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Agent workflow plan structure
|
|
22
|
+
*/
|
|
23
|
+
interface AgentWorkflowPlan {
|
|
24
|
+
steps: AgentWorkflowStep[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Action handler signature
|
|
28
|
+
*/
|
|
29
|
+
export type AgentWorkflowActionHandler = (params: any, context: AgentWorkflowContext) => Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Agent workflow context stored between phases
|
|
32
|
+
*/
|
|
33
|
+
export interface AgentWorkflowContext {
|
|
34
|
+
objective: string;
|
|
35
|
+
inputs?: any;
|
|
36
|
+
plan?: AgentWorkflowPlan;
|
|
37
|
+
executionLog?: AgentWorkflowExecutionLog[];
|
|
38
|
+
currentStep?: AgentWorkflowStep;
|
|
39
|
+
actionResult?: any;
|
|
40
|
+
phase?: 'planning' | 'execution' | 'integration' | 'complete';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Options for agent workflow execution
|
|
44
|
+
*/
|
|
45
|
+
export interface AgentWorkflowOptions {
|
|
46
|
+
maxSteps?: number;
|
|
47
|
+
actions?: Record<string, AgentWorkflowActionHandler>;
|
|
48
|
+
enablePlanning?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Agent workflow - simple planning/execution/integration pipeline
|
|
52
|
+
*/
|
|
53
|
+
export declare function agentProcess(driver: AIDriver, module: PromptModule<AgentWorkflowContext>, context: AgentWorkflowContext, options?: AgentWorkflowOptions): Promise<WorkflowResult<AgentWorkflowContext>>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=agent-workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-workflow.d.ts","sourceRoot":"","sources":["../../src/workflows/agent-workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED;;GAEG;AACH,UAAU,yBAAyB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,UAAU,iBAAiB;IACzB,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEtG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC3C,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IACrD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA4XD;;GAEG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,YAAY,CAAC,oBAAoB,CAAC,EAC1C,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,CA6C/C"}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { compile, merge } from '@modular-prompt/core';
|
|
2
|
+
import { WorkflowExecutionError } from './types.js';
|
|
3
|
+
const baseAgentModule = {
|
|
4
|
+
methodology: [
|
|
5
|
+
'- Simple agent workflow executes work through Planning → Execution → Integration.',
|
|
6
|
+
'- Keep reasoning explicit and document what each phase accomplishes.'
|
|
7
|
+
],
|
|
8
|
+
state: [
|
|
9
|
+
(ctx) => ctx.phase ? `Current phase: ${ctx.phase}` : null
|
|
10
|
+
]
|
|
11
|
+
};
|
|
12
|
+
const planningModule = {
|
|
13
|
+
methodology: [
|
|
14
|
+
'- **Planning Phase**',
|
|
15
|
+
' - Break the objective into concrete executable steps.',
|
|
16
|
+
' - Use JSON output so the application can parse the plan.'
|
|
17
|
+
],
|
|
18
|
+
instructions: [
|
|
19
|
+
{
|
|
20
|
+
type: 'subsection',
|
|
21
|
+
title: 'Planning Requirements',
|
|
22
|
+
items: [
|
|
23
|
+
'- Produce 3-5 ordered steps that accomplish the objective.',
|
|
24
|
+
'- Each step needs: id (e.g., "step-1"), description, optional action + params.',
|
|
25
|
+
'- Consider available inputs when proposing the steps.',
|
|
26
|
+
'- Output valid JSON only. No commentary or markdown fences.'
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
inputs: [
|
|
31
|
+
(ctx) => ctx.inputs ? JSON.stringify(ctx.inputs, null, 2) : null
|
|
32
|
+
],
|
|
33
|
+
state: [
|
|
34
|
+
'Phase: planning'
|
|
35
|
+
],
|
|
36
|
+
cue: [
|
|
37
|
+
'Return a JSON object that contains the plan. Respond only with JSON text.',
|
|
38
|
+
'Start the response with { and end with }.'
|
|
39
|
+
],
|
|
40
|
+
schema: [
|
|
41
|
+
{
|
|
42
|
+
type: 'json',
|
|
43
|
+
content: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
steps: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
items: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
id: { type: 'string' },
|
|
52
|
+
description: { type: 'string' },
|
|
53
|
+
action: { type: 'string' },
|
|
54
|
+
params: { type: 'object' }
|
|
55
|
+
},
|
|
56
|
+
required: ['id', 'description']
|
|
57
|
+
},
|
|
58
|
+
minItems: 1
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
required: ['steps']
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
const executionModule = {
|
|
67
|
+
methodology: [
|
|
68
|
+
'- **Execution Phase**',
|
|
69
|
+
'- Complete only the current step from the plan and describe the result clearly.'
|
|
70
|
+
],
|
|
71
|
+
instructions: [
|
|
72
|
+
{
|
|
73
|
+
type: 'subsection',
|
|
74
|
+
title: 'Current Step',
|
|
75
|
+
items: [
|
|
76
|
+
(ctx) => ctx.currentStep
|
|
77
|
+
? `- Execute: ${ctx.currentStep.description}`
|
|
78
|
+
: '- There is no current step.'
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'subsection',
|
|
83
|
+
title: 'Execution Plan Overview',
|
|
84
|
+
items: [
|
|
85
|
+
(ctx) => {
|
|
86
|
+
if (!ctx.plan) {
|
|
87
|
+
return '- Plan not available.';
|
|
88
|
+
}
|
|
89
|
+
const completed = ctx.executionLog?.length || 0;
|
|
90
|
+
return ctx.plan.steps.map((step, index) => {
|
|
91
|
+
const prefix = index < completed
|
|
92
|
+
? '[done]'
|
|
93
|
+
: (ctx.currentStep?.id === step.id ? '[current]' : '[todo]');
|
|
94
|
+
const actionInfo = step.action ? ` (action: ${step.action})` : '';
|
|
95
|
+
return `- ${prefix} ${step.id}: ${step.description}${actionInfo}`;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
state: [
|
|
102
|
+
(ctx) => {
|
|
103
|
+
const completed = ctx.executionLog?.length || 0;
|
|
104
|
+
const total = ctx.plan?.steps.length || 0;
|
|
105
|
+
return `Progress: ${completed}/${total} steps completed`;
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
inputs: [
|
|
109
|
+
(ctx) => ctx.inputs ? JSON.stringify(ctx.inputs, null, 2) : null
|
|
110
|
+
],
|
|
111
|
+
materials: [
|
|
112
|
+
(ctx) => {
|
|
113
|
+
if (ctx.actionResult === undefined) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
type: 'material',
|
|
118
|
+
id: 'action-result',
|
|
119
|
+
title: 'Latest action output',
|
|
120
|
+
content: typeof ctx.actionResult === 'string'
|
|
121
|
+
? ctx.actionResult
|
|
122
|
+
: JSON.stringify(ctx.actionResult, null, 2)
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
(ctx) => {
|
|
126
|
+
if (!ctx.executionLog || ctx.executionLog.length === 0) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return ctx.executionLog.map((log) => ({
|
|
130
|
+
type: 'material',
|
|
131
|
+
id: `execution-log-${log.stepId}`,
|
|
132
|
+
title: `Previous result: ${log.stepId}`,
|
|
133
|
+
content: log.result
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
cue: [
|
|
138
|
+
'Describe the work performed for this step and the resulting findings.',
|
|
139
|
+
'Only focus on the current step.'
|
|
140
|
+
]
|
|
141
|
+
};
|
|
142
|
+
const integrationModule = {
|
|
143
|
+
methodology: [
|
|
144
|
+
'- **Integration Phase**',
|
|
145
|
+
'- Combine the outcomes from all steps and deliver the final answer.'
|
|
146
|
+
],
|
|
147
|
+
instructions: [
|
|
148
|
+
{
|
|
149
|
+
type: 'subsection',
|
|
150
|
+
title: 'Integration Goals',
|
|
151
|
+
items: [
|
|
152
|
+
'- Summarize the outcome of each executed step.',
|
|
153
|
+
'- Confirm that the overall objective has been satisfied.',
|
|
154
|
+
'- Present a cohesive final response.'
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
inputs: [
|
|
159
|
+
(ctx) => ctx.inputs ? JSON.stringify(ctx.inputs, null, 2) : null
|
|
160
|
+
],
|
|
161
|
+
materials: [
|
|
162
|
+
(ctx) => {
|
|
163
|
+
if (!ctx.executionLog || ctx.executionLog.length === 0) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return ctx.executionLog.map((log) => ({
|
|
167
|
+
type: 'material',
|
|
168
|
+
id: `integrated-result-${log.stepId}`,
|
|
169
|
+
title: `Result from ${log.stepId}`,
|
|
170
|
+
content: log.result
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
state: [
|
|
175
|
+
(ctx) => {
|
|
176
|
+
const total = ctx.plan?.steps.length || 0;
|
|
177
|
+
return `All ${total} steps complete. Generate the final answer.`;
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
cue: [
|
|
181
|
+
'Integrate every step result and provide the final deliverable.'
|
|
182
|
+
]
|
|
183
|
+
};
|
|
184
|
+
async function executePlanningPhase(driver, module, context, maxSteps) {
|
|
185
|
+
const planningPrompt = compile(merge(baseAgentModule, planningModule, module), context);
|
|
186
|
+
try {
|
|
187
|
+
const planResult = await driver.query(planningPrompt);
|
|
188
|
+
if (planResult.finishReason && planResult.finishReason !== 'stop') {
|
|
189
|
+
throw new WorkflowExecutionError(`Planning failed with reason: ${planResult.finishReason}`, context, {
|
|
190
|
+
phase: 'planning',
|
|
191
|
+
finishReason: planResult.finishReason
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (!planResult.structuredOutput) {
|
|
195
|
+
throw new WorkflowExecutionError('Planning did not return structured output', context, {
|
|
196
|
+
phase: 'planning',
|
|
197
|
+
partialResult: planResult.content
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const plan = planResult.structuredOutput;
|
|
201
|
+
if (!plan.steps || !Array.isArray(plan.steps)) {
|
|
202
|
+
throw new WorkflowExecutionError('Plan must contain steps array', context, {
|
|
203
|
+
phase: 'planning'
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (plan.steps.length > maxSteps) {
|
|
207
|
+
plan.steps = plan.steps.slice(0, maxSteps);
|
|
208
|
+
}
|
|
209
|
+
return plan;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (error instanceof WorkflowExecutionError) {
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
throw new WorkflowExecutionError(error, context, {
|
|
216
|
+
phase: 'planning'
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async function executeStep(driver, module, context, step, actions) {
|
|
221
|
+
let actionResult;
|
|
222
|
+
if (step.action) {
|
|
223
|
+
const handler = actions[step.action];
|
|
224
|
+
if (!handler) {
|
|
225
|
+
throw new WorkflowExecutionError(`Action "${step.action}" is not available`, context, { phase: 'execution' });
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
actionResult = await handler(step.params ?? {}, context);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
throw new WorkflowExecutionError(error, context, {
|
|
232
|
+
phase: 'execution',
|
|
233
|
+
partialResult: `Action ${step.action} failed`
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const executionPrompt = compile(merge(baseAgentModule, executionModule, module), {
|
|
238
|
+
...context,
|
|
239
|
+
currentStep: step,
|
|
240
|
+
actionResult
|
|
241
|
+
});
|
|
242
|
+
try {
|
|
243
|
+
const result = await driver.query(executionPrompt);
|
|
244
|
+
if (result.finishReason && result.finishReason !== 'stop') {
|
|
245
|
+
throw new WorkflowExecutionError(`Execution failed with reason: ${result.finishReason}`, context, {
|
|
246
|
+
phase: 'execution',
|
|
247
|
+
partialResult: result.content,
|
|
248
|
+
finishReason: result.finishReason
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
stepId: step.id,
|
|
253
|
+
result: result.content,
|
|
254
|
+
metadata: {
|
|
255
|
+
usage: result.usage,
|
|
256
|
+
action: step.action,
|
|
257
|
+
actionResult
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
if (error instanceof WorkflowExecutionError) {
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
throw new WorkflowExecutionError(error, context, {
|
|
266
|
+
phase: 'execution'
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function executeExecutionPhase(driver, module, context, plan, actions) {
|
|
271
|
+
const executionLog = context.executionLog ? [...context.executionLog] : [];
|
|
272
|
+
const startIndex = executionLog.length;
|
|
273
|
+
for (let i = startIndex; i < plan.steps.length; i++) {
|
|
274
|
+
const currentStep = plan.steps[i];
|
|
275
|
+
const logEntry = await executeStep(driver, module, context, currentStep, actions);
|
|
276
|
+
executionLog.push(logEntry);
|
|
277
|
+
context.executionLog = executionLog;
|
|
278
|
+
}
|
|
279
|
+
return executionLog;
|
|
280
|
+
}
|
|
281
|
+
async function executeIntegrationPhase(driver, module, context) {
|
|
282
|
+
const integrationPrompt = compile(merge(baseAgentModule, integrationModule, module), context);
|
|
283
|
+
try {
|
|
284
|
+
const result = await driver.query(integrationPrompt);
|
|
285
|
+
if (result.finishReason && result.finishReason !== 'stop') {
|
|
286
|
+
throw new WorkflowExecutionError(`Integration failed with reason: ${result.finishReason}`, context, {
|
|
287
|
+
phase: 'integration',
|
|
288
|
+
partialResult: result.content,
|
|
289
|
+
finishReason: result.finishReason
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return result.content;
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
if (error instanceof WorkflowExecutionError) {
|
|
296
|
+
throw error;
|
|
297
|
+
}
|
|
298
|
+
throw new WorkflowExecutionError(error, context, {
|
|
299
|
+
phase: 'integration'
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Agent workflow - simple planning/execution/integration pipeline
|
|
305
|
+
*/
|
|
306
|
+
export async function agentProcess(driver, module, context, options = {}) {
|
|
307
|
+
const { maxSteps = 5, actions = {}, enablePlanning = true } = options;
|
|
308
|
+
let currentContext = { ...context };
|
|
309
|
+
let plan = currentContext.plan;
|
|
310
|
+
if (enablePlanning || !plan) {
|
|
311
|
+
currentContext.phase = 'planning';
|
|
312
|
+
plan = await executePlanningPhase(driver, module, currentContext, maxSteps);
|
|
313
|
+
currentContext.plan = plan;
|
|
314
|
+
}
|
|
315
|
+
if (!plan) {
|
|
316
|
+
throw new WorkflowExecutionError('Agent workflow requires a plan to execute', currentContext, { phase: 'planning' });
|
|
317
|
+
}
|
|
318
|
+
currentContext.phase = 'execution';
|
|
319
|
+
const executionLog = await executeExecutionPhase(driver, module, currentContext, plan, actions);
|
|
320
|
+
currentContext.executionLog = executionLog;
|
|
321
|
+
currentContext.phase = 'integration';
|
|
322
|
+
const finalOutput = await executeIntegrationPhase(driver, module, currentContext);
|
|
323
|
+
const finalContext = {
|
|
324
|
+
...currentContext,
|
|
325
|
+
phase: 'complete'
|
|
326
|
+
};
|
|
327
|
+
return {
|
|
328
|
+
output: finalOutput,
|
|
329
|
+
context: finalContext,
|
|
330
|
+
metadata: {
|
|
331
|
+
planSteps: plan.steps.length,
|
|
332
|
+
executedSteps: executionLog.length,
|
|
333
|
+
actionsUsed: executionLog.filter(log => log.metadata?.actionResult !== undefined).length
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=agent-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-workflow.js","sourceRoot":"","sources":["../../src/workflows/agent-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAwDpD,MAAM,eAAe,GAAuC;IAC1D,WAAW,EAAE;QACX,mFAAmF;QACnF,sEAAsE;KACvE;IACD,KAAK,EAAE;QACL,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,K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ptModule } from '@modular-prompt/core';
|
|
2
|
+
import type { AIDriver, WorkflowResult } from '../types.js';
|
|
3
|
+
import type { AgenticWorkflowContext, AgenticWorkflowOptions } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Agentic workflow - autonomous multi-step processing with planning
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. Planning phase: Generate execution plan using structured outputs
|
|
9
|
+
* 2. Execution phase: Execute each step (with optional actions)
|
|
10
|
+
* 3. Integration phase: Integrate results and generate final output
|
|
11
|
+
*/
|
|
12
|
+
export declare function agenticProcess(driver: AIDriver, module: PromptModule<AgenticWorkflowContext>, context: AgenticWorkflowContext, options?: AgenticWorkflowOptions): Promise<WorkflowResult<AgenticWorkflowContext>>;
|
|
13
|
+
//# sourceMappingURL=agentic-workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentic-workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/agentic-workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAmD,MAAM,YAAY,CAAC;AA+QlI;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,YAAY,CAAC,sBAAsB,CAAC,EAC5C,OAAO,EAAE,sBAAsB,EAC/B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CA+CjD"}
|