@modular-prompt/process 0.1.28 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -58
- package/dist/workflows/agentic-workflow/agentic-workflow.d.ts +12 -8
- package/dist/workflows/agentic-workflow/agentic-workflow.d.ts.map +1 -1
- package/dist/workflows/agentic-workflow/agentic-workflow.js +186 -205
- package/dist/workflows/agentic-workflow/agentic-workflow.js.map +1 -1
- package/dist/workflows/agentic-workflow/index.d.ts +5 -2
- package/dist/workflows/agentic-workflow/index.d.ts.map +1 -1
- package/dist/workflows/agentic-workflow/index.js +5 -2
- package/dist/workflows/agentic-workflow/index.js.map +1 -1
- package/dist/workflows/agentic-workflow/process/builtin-tools.d.ts +31 -0
- package/dist/workflows/agentic-workflow/process/builtin-tools.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/process/builtin-tools.js +158 -0
- package/dist/workflows/agentic-workflow/process/builtin-tools.js.map +1 -0
- package/dist/workflows/agentic-workflow/process/format-helpers.d.ts +11 -0
- package/dist/workflows/agentic-workflow/process/format-helpers.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/process/format-helpers.js +18 -0
- package/dist/workflows/agentic-workflow/process/format-helpers.js.map +1 -0
- package/dist/workflows/agentic-workflow/process/index.d.ts +7 -0
- package/dist/workflows/agentic-workflow/process/index.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/process/index.js +7 -0
- package/dist/workflows/agentic-workflow/process/index.js.map +1 -0
- package/dist/workflows/agentic-workflow/process/query-with-tools.d.ts +37 -0
- package/dist/workflows/agentic-workflow/process/query-with-tools.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/process/query-with-tools.js +118 -0
- package/dist/workflows/agentic-workflow/process/query-with-tools.js.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/execution-tasks.d.ts +35 -0
- package/dist/workflows/agentic-workflow/task-types/execution-tasks.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/execution-tasks.js +155 -0
- package/dist/workflows/agentic-workflow/task-types/execution-tasks.js.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/index.d.ts +37 -0
- package/dist/workflows/agentic-workflow/task-types/index.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/index.js +103 -0
- package/dist/workflows/agentic-workflow/task-types/index.js.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/output.d.ts +16 -0
- package/dist/workflows/agentic-workflow/task-types/output.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/output.js +32 -0
- package/dist/workflows/agentic-workflow/task-types/output.js.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/planning.d.ts +19 -0
- package/dist/workflows/agentic-workflow/task-types/planning.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/task-types/planning.js +77 -0
- package/dist/workflows/agentic-workflow/task-types/planning.js.map +1 -0
- package/dist/workflows/agentic-workflow/types.d.ts +83 -37
- package/dist/workflows/agentic-workflow/types.d.ts.map +1 -1
- package/dist/workflows/agentic-workflow/types.js +27 -1
- package/dist/workflows/agentic-workflow/types.js.map +1 -1
- package/dist/workflows/concat-process-workflow.d.ts +3 -2
- package/dist/workflows/concat-process-workflow.d.ts.map +1 -1
- package/dist/workflows/concat-process-workflow.js +41 -5
- package/dist/workflows/concat-process-workflow.js.map +1 -1
- package/dist/workflows/default-workflow.d.ts +3 -2
- package/dist/workflows/default-workflow.d.ts.map +1 -1
- package/dist/workflows/default-workflow.js +14 -1
- package/dist/workflows/default-workflow.js.map +1 -1
- package/dist/workflows/dialogue-workflow.d.ts +3 -2
- package/dist/workflows/dialogue-workflow.d.ts.map +1 -1
- package/dist/workflows/dialogue-workflow.js +15 -3
- package/dist/workflows/dialogue-workflow.js.map +1 -1
- package/dist/workflows/driver-input.d.ts +16 -0
- package/dist/workflows/driver-input.d.ts.map +1 -0
- package/dist/workflows/driver-input.js +18 -0
- package/dist/workflows/driver-input.js.map +1 -0
- package/dist/workflows/index.d.ts +6 -3
- package/dist/workflows/index.d.ts.map +1 -1
- package/dist/workflows/index.js +5 -2
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.d.ts +3 -2
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.d.ts.map +1 -1
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.js +4 -3
- package/dist/workflows/self-prompting-workflow/self-prompting-workflow.js.map +1 -1
- package/dist/workflows/stream-workflow.d.ts +3 -2
- package/dist/workflows/stream-workflow.d.ts.map +1 -1
- package/dist/workflows/stream-workflow.js +11 -3
- package/dist/workflows/stream-workflow.js.map +1 -1
- package/dist/workflows/summarize-workflow.d.ts +3 -2
- package/dist/workflows/summarize-workflow.d.ts.map +1 -1
- package/dist/workflows/summarize-workflow.js +11 -2
- package/dist/workflows/summarize-workflow.js.map +1 -1
- package/package.json +4 -3
- package/dist/workflows/agent-workflow.d.ts +0 -55
- package/dist/workflows/agent-workflow.d.ts.map +0 -1
- package/dist/workflows/agent-workflow.js +0 -337
- package/dist/workflows/agent-workflow.js.map +0 -1
- package/dist/workflows/agentic-workflow/modules/agentic.d.ts +0 -12
- package/dist/workflows/agentic-workflow/modules/agentic.d.ts.map +0 -1
- package/dist/workflows/agentic-workflow/modules/agentic.js +0 -22
- package/dist/workflows/agentic-workflow/modules/agentic.js.map +0 -1
- package/dist/workflows/agentic-workflow/modules/execution-freeform.d.ts +0 -15
- package/dist/workflows/agentic-workflow/modules/execution-freeform.d.ts.map +0 -1
- package/dist/workflows/agentic-workflow/modules/execution-freeform.js +0 -140
- package/dist/workflows/agentic-workflow/modules/execution-freeform.js.map +0 -1
- package/dist/workflows/agentic-workflow/modules/execution.d.ts +0 -11
- package/dist/workflows/agentic-workflow/modules/execution.d.ts.map +0 -1
- package/dist/workflows/agentic-workflow/modules/execution.js +0 -180
- package/dist/workflows/agentic-workflow/modules/execution.js.map +0 -1
- package/dist/workflows/agentic-workflow/modules/index.d.ts +0 -6
- package/dist/workflows/agentic-workflow/modules/index.d.ts.map +0 -1
- package/dist/workflows/agentic-workflow/modules/index.js +0 -7
- package/dist/workflows/agentic-workflow/modules/index.js.map +0 -1
- package/dist/workflows/agentic-workflow/modules/integration.d.ts +0 -11
- package/dist/workflows/agentic-workflow/modules/integration.d.ts.map +0 -1
- package/dist/workflows/agentic-workflow/modules/integration.js +0 -85
- package/dist/workflows/agentic-workflow/modules/integration.js.map +0 -1
- package/dist/workflows/agentic-workflow/modules/planning.d.ts +0 -11
- package/dist/workflows/agentic-workflow/modules/planning.d.ts.map +0 -1
- package/dist/workflows/agentic-workflow/modules/planning.js +0 -103
- package/dist/workflows/agentic-workflow/modules/planning.js.map +0 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution task type factory
|
|
3
|
+
*
|
|
4
|
+
* planning と output 以外のタスクタイプは共通構造を持つ。
|
|
5
|
+
* 差分(instruction テキスト、デフォルトオプション)を設定で定義し、
|
|
6
|
+
* ファクトリで PromptModule + TaskTypeConfig を生成する。
|
|
7
|
+
*
|
|
8
|
+
* 新しいタスクタイプの追加:
|
|
9
|
+
* 1. EXECUTION_TASK_DEFS に定義を追加
|
|
10
|
+
* 2. types.ts の TaskType union に追加
|
|
11
|
+
* → レジストリ登録・ツール定義は自動的に反映される
|
|
12
|
+
*/
|
|
13
|
+
import { buildPreviousResultsMaterials } from './index.js';
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Task definitions
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
export const EXECUTION_TASK_DEFS = {
|
|
18
|
+
think: {
|
|
19
|
+
objective: '- Perform reasoning, analysis, or processing as described in the Focus.',
|
|
20
|
+
instructions: [
|
|
21
|
+
'- You will perform reasoning, analysis, or processing as instructed.',
|
|
22
|
+
'- You may call external tools if needed to gather information or perform actions.',
|
|
23
|
+
'- If additional tasks are needed to complete the objective, use `__insert_tasks` to register them.',
|
|
24
|
+
],
|
|
25
|
+
driverRole: 'thinking',
|
|
26
|
+
defaults: { withInputs: false, withMessages: false, withMaterials: false },
|
|
27
|
+
toolDescription: 'general reasoning/analysis',
|
|
28
|
+
},
|
|
29
|
+
toolCall: {
|
|
30
|
+
objective: '- Call external tools as described in the Focus and report the results.',
|
|
31
|
+
instructions: [
|
|
32
|
+
'- You will call external tools as instructed to gather information or perform actions.',
|
|
33
|
+
'- Report the tool results clearly for subsequent Tasks.',
|
|
34
|
+
],
|
|
35
|
+
driverRole: 'instruct',
|
|
36
|
+
defaults: { withInputs: false, withMessages: false, withMaterials: false },
|
|
37
|
+
toolDescription: 'call external tools',
|
|
38
|
+
},
|
|
39
|
+
verify: {
|
|
40
|
+
objective: '- Verify or validate results from previous Tasks as described in the Focus.',
|
|
41
|
+
instructions: [
|
|
42
|
+
'- You will verify or validate results from previous Tasks as instructed.',
|
|
43
|
+
'- Report any issues, inconsistencies, or confirmations clearly.',
|
|
44
|
+
'- If verification fails or results are insufficient, use `__insert_tasks` to register corrective tasks as needed.',
|
|
45
|
+
],
|
|
46
|
+
driverRole: 'thinking',
|
|
47
|
+
defaults: { withInputs: false, withMessages: false, withMaterials: false },
|
|
48
|
+
toolDescription: 'validate previous results',
|
|
49
|
+
},
|
|
50
|
+
extractContext: {
|
|
51
|
+
objective: '- Extract relevant information from the provided data according to the Focus.',
|
|
52
|
+
instructions: [
|
|
53
|
+
'- Extract information from the provided inputs, messages, and materials as specified in the Focus.',
|
|
54
|
+
'- Be exhaustive — do not omit any relevant information.',
|
|
55
|
+
'- Combine direct quoting and summarization: quote key phrases or data verbatim, and summarize surrounding context.',
|
|
56
|
+
'- This is an extraction task: gather and organize what is present in the data. Do not interpret, infer, or add your own reasoning.',
|
|
57
|
+
'- Structure the extracted information clearly so that subsequent Tasks can use it directly.',
|
|
58
|
+
],
|
|
59
|
+
driverRole: 'thinking',
|
|
60
|
+
defaults: { withInputs: true, withMessages: true, withMaterials: true },
|
|
61
|
+
toolDescription: 'extract from inputs/materials',
|
|
62
|
+
},
|
|
63
|
+
recall: {
|
|
64
|
+
objective: '- Retrieve information relevant to the Focus using search tools or training knowledge.',
|
|
65
|
+
instructions: [
|
|
66
|
+
'- You will retrieve information relevant to the Focus.',
|
|
67
|
+
'- If search tools are available, formulate appropriate search queries and use them.',
|
|
68
|
+
'- If the information is already known from your training data and no search is needed, return it directly.',
|
|
69
|
+
'- Do not fabricate information. If uncertain, state what you know and what is unverified.',
|
|
70
|
+
],
|
|
71
|
+
driverRole: 'instruct',
|
|
72
|
+
defaults: { withInputs: false, withMessages: false, withMaterials: false },
|
|
73
|
+
toolDescription: 'retrieve information via search tools or training knowledge',
|
|
74
|
+
},
|
|
75
|
+
determine: {
|
|
76
|
+
objective: '- Make a decision or judgment based on the available information as described in the Focus.',
|
|
77
|
+
instructions: [
|
|
78
|
+
'- You will make a decision or judgment based on the available information.',
|
|
79
|
+
'- You MUST reach a definitive conclusion. Do not defer, leave open, or suggest further investigation.',
|
|
80
|
+
'- State your conclusion clearly with supporting reasoning.',
|
|
81
|
+
],
|
|
82
|
+
driverRole: 'thinking',
|
|
83
|
+
defaults: { withInputs: true, withMessages: true, withMaterials: true },
|
|
84
|
+
toolDescription: 'make a decision or judgment',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Factory
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
function buildModule(def) {
|
|
91
|
+
const module = {
|
|
92
|
+
objective: [
|
|
93
|
+
'',
|
|
94
|
+
def.objective ?? '- You will execute the Task described in "Focus" below.',
|
|
95
|
+
],
|
|
96
|
+
instructions: [
|
|
97
|
+
...def.instructions,
|
|
98
|
+
{
|
|
99
|
+
type: 'subsection',
|
|
100
|
+
title: 'Focus',
|
|
101
|
+
items: [
|
|
102
|
+
(ctx) => {
|
|
103
|
+
const task = ctx.taskList?.[ctx.currentTaskIndex ?? 0];
|
|
104
|
+
return task?.instruction ?? '';
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
materials: [
|
|
110
|
+
(ctx) => {
|
|
111
|
+
if (!ctx.executionLog?.length)
|
|
112
|
+
return null;
|
|
113
|
+
return buildPreviousResultsMaterials(ctx.executionLog);
|
|
114
|
+
},
|
|
115
|
+
(ctx) => {
|
|
116
|
+
const task = ctx.taskList?.[ctx.currentTaskIndex ?? 0];
|
|
117
|
+
const withMaterials = task?.withMaterials ?? def.defaults.withMaterials;
|
|
118
|
+
if (!withMaterials || !ctx.userModule?.materials?.length)
|
|
119
|
+
return null;
|
|
120
|
+
return ctx.userModule.materials;
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
inputs: [
|
|
124
|
+
(ctx) => {
|
|
125
|
+
const task = ctx.taskList?.[ctx.currentTaskIndex ?? 0];
|
|
126
|
+
const withInputs = task?.withInputs ?? def.defaults.withInputs;
|
|
127
|
+
if (!withInputs || !ctx.inputs)
|
|
128
|
+
return null;
|
|
129
|
+
return JSON.stringify(ctx.inputs, null, 2);
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
messages: [
|
|
133
|
+
(ctx) => {
|
|
134
|
+
const task = ctx.taskList?.[ctx.currentTaskIndex ?? 0];
|
|
135
|
+
const withMessages = task?.withMessages ?? def.defaults.withMessages;
|
|
136
|
+
if (!withMessages || !ctx.userModule?.messages?.length)
|
|
137
|
+
return null;
|
|
138
|
+
return ctx.userModule.messages;
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
return module;
|
|
143
|
+
}
|
|
144
|
+
function buildConfig(def) {
|
|
145
|
+
return {
|
|
146
|
+
module: buildModule(def),
|
|
147
|
+
builtinToolNames: ['__insert_tasks', '__update_state', '__time'],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
// Exports
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
/** All execution task configs, keyed by task type name */
|
|
154
|
+
export const executionTaskConfigs = Object.fromEntries(Object.entries(EXECUTION_TASK_DEFS).map(([name, def]) => [name, buildConfig(def)]));
|
|
155
|
+
//# sourceMappingURL=execution-tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-tasks.js","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/task-types/execution-tasks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAmB3D,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAqC;IACnE,KAAK,EAAE;QACL,SAAS,EAAE,yEAAyE;QACpF,YAAY,EAAE;YACZ,sEAAsE;YACtE,mFAAmF;YACnF,oGAAoG;SACrG;QACD,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE;QAC1E,eAAe,EAAE,4BAA4B;KAC9C;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,yEAAyE;QACpF,YAAY,EAAE;YACZ,wFAAwF;YACxF,yDAAyD;SAC1D;QACD,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE;QAC1E,eAAe,EAAE,qBAAqB;KACvC;IACD,MAAM,EAAE;QACN,SAAS,EAAE,6EAA6E;QACxF,YAAY,EAAE;YACZ,0EAA0E;YAC1E,iEAAiE;YACjE,mHAAmH;SACpH;QACD,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE;QAC1E,eAAe,EAAE,2BAA2B;KAC7C;IACD,cAAc,EAAE;QACd,SAAS,EAAE,+EAA+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CAAC,CAAC,CAAC;gBACvD,MAAM,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC;gBACrE,IAAI,CAAC,YAAY,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM;oBAAE,OAAO,IAAI,CAAC;gBACpE,OAAO,GAAG,CAAC,UAAU,CAAC,QAA4B,CAAC;YACrD,CAAC;SACF;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,GAAqB;IACxC,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC;QACxB,gBAAgB,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,CAAC;KACjE,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAoB,GAAmC,MAAM,CAAC,WAAW,CACpF,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CACnF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task type registry and shared utilities
|
|
3
|
+
*/
|
|
4
|
+
import type { PromptModule, MaterialElement, SectionContent } from '@modular-prompt/core';
|
|
5
|
+
import type { AgenticWorkflowContext, TaskType, AgenticTaskExecutionLog } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Task type configuration
|
|
8
|
+
*/
|
|
9
|
+
export interface TaskTypeConfig {
|
|
10
|
+
/** Static prompt module for this task type */
|
|
11
|
+
module: PromptModule<AgenticWorkflowContext>;
|
|
12
|
+
/** List of builtin tool names available for this task type */
|
|
13
|
+
builtinToolNames: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get task type configuration
|
|
17
|
+
*/
|
|
18
|
+
export declare function getTaskTypeConfig(taskType: TaskType): TaskTypeConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Convert execution log to MaterialElement array (previous task results)
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildPreviousResultsMaterials(executionLog: AgenticTaskExecutionLog[]): MaterialElement[];
|
|
23
|
+
/**
|
|
24
|
+
* Build task list display for methodology section
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildTaskListDisplay(ctx: AgenticWorkflowContext): string;
|
|
27
|
+
/**
|
|
28
|
+
* Common module shared by all task types.
|
|
29
|
+
* Provides workflow terms, methodology, and state information.
|
|
30
|
+
*/
|
|
31
|
+
export declare const taskCommon: PromptModule<AgenticWorkflowContext>;
|
|
32
|
+
/**
|
|
33
|
+
* Extract static text content from SectionContent.
|
|
34
|
+
* Only extracts strings, ignores DynamicContent and Elements.
|
|
35
|
+
*/
|
|
36
|
+
export declare function extractTextFromSection(section: SectionContent<any> | undefined): string;
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/task-types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAK7F;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,MAAM,EAAE,YAAY,CAAC,sBAAsB,CAAC,CAAC;IAC7C,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAYD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAEpE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,uBAAuB,EAAE,GACtC,eAAe,EAAE,CAOnB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM,CAwBxE;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,sBAAsB,CAuB3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,MAAM,CAUvF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task type registry and shared utilities
|
|
3
|
+
*/
|
|
4
|
+
import { config as planningConfig } from './planning.js';
|
|
5
|
+
import { config as outputConfig } from './output.js';
|
|
6
|
+
import { executionTaskConfigs } from './execution-tasks.js';
|
|
7
|
+
/**
|
|
8
|
+
* Task type registry.
|
|
9
|
+
* planning/output are special; execution tasks are auto-generated from EXECUTION_TASK_DEFS.
|
|
10
|
+
*/
|
|
11
|
+
const TASK_TYPE_REGISTRY = {
|
|
12
|
+
planning: planningConfig,
|
|
13
|
+
...executionTaskConfigs,
|
|
14
|
+
output: outputConfig,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Get task type configuration
|
|
18
|
+
*/
|
|
19
|
+
export function getTaskTypeConfig(taskType) {
|
|
20
|
+
return TASK_TYPE_REGISTRY[taskType];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Convert execution log to MaterialElement array (previous task results)
|
|
24
|
+
*/
|
|
25
|
+
export function buildPreviousResultsMaterials(executionLog) {
|
|
26
|
+
return executionLog.map((log, index) => ({
|
|
27
|
+
type: 'material',
|
|
28
|
+
id: `task-result-${index}`,
|
|
29
|
+
title: `Task ${index + 1} result`,
|
|
30
|
+
content: log.result,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build task list display for methodology section
|
|
35
|
+
*/
|
|
36
|
+
export function buildTaskListDisplay(ctx) {
|
|
37
|
+
if (!ctx.taskList || ctx.taskList.length === 0) {
|
|
38
|
+
return 'No tasks registered yet.';
|
|
39
|
+
}
|
|
40
|
+
const lines = [];
|
|
41
|
+
const currentIndex = ctx.currentTaskIndex ?? -1;
|
|
42
|
+
for (let i = 0; i < ctx.taskList.length; i++) {
|
|
43
|
+
const task = ctx.taskList[i];
|
|
44
|
+
let status;
|
|
45
|
+
if (i < currentIndex) {
|
|
46
|
+
status = '[completed]';
|
|
47
|
+
}
|
|
48
|
+
else if (i === currentIndex) {
|
|
49
|
+
status = '**[current]**';
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
status = '[pending]';
|
|
53
|
+
}
|
|
54
|
+
lines.push(`${i + 1}. (${task.taskType}): ${task.instruction} ${status}`);
|
|
55
|
+
}
|
|
56
|
+
return lines.join('\n');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Common module shared by all task types.
|
|
60
|
+
* Provides workflow terms, methodology, and state information.
|
|
61
|
+
*/
|
|
62
|
+
export const taskCommon = {
|
|
63
|
+
terms: [
|
|
64
|
+
'- **Task**: A unit of work in the workflow. Each Task is executed by a separate AI instance.',
|
|
65
|
+
'- **Task Type**: Defines the role of a Task (e.g. think, toolCall, verify). The prompt is pre-configured for each type.',
|
|
66
|
+
'- **Focus**: The specific directive for the current Task — what to concentrate on and accomplish.',
|
|
67
|
+
'- **State**: Persistent information shared across Tasks. Updated via `__update_state` and visible to all subsequent Tasks in the "Current State" section.',
|
|
68
|
+
],
|
|
69
|
+
state: [
|
|
70
|
+
(ctx) => {
|
|
71
|
+
if (!ctx.state)
|
|
72
|
+
return null;
|
|
73
|
+
return ctx.state;
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
methodology: [
|
|
77
|
+
'- We accomplish the Objective by executing Tasks sequentially.',
|
|
78
|
+
{
|
|
79
|
+
type: 'subsection',
|
|
80
|
+
title: 'Workflow Status / Current Task List',
|
|
81
|
+
items: [
|
|
82
|
+
(ctx) => buildTaskListDisplay(ctx),
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Extract static text content from SectionContent.
|
|
89
|
+
* Only extracts strings, ignores DynamicContent and Elements.
|
|
90
|
+
*/
|
|
91
|
+
export function extractTextFromSection(section) {
|
|
92
|
+
if (!section)
|
|
93
|
+
return '';
|
|
94
|
+
const items = Array.isArray(section) ? section : [section];
|
|
95
|
+
const textParts = [];
|
|
96
|
+
for (const item of items) {
|
|
97
|
+
if (typeof item === 'string') {
|
|
98
|
+
textParts.push(item);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return textParts.join('\n');
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/task-types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAY5D;;;GAGG;AACH,MAAM,kBAAkB,GAAqC;IAC3D,QAAQ,EAAE,cAAc;IACxB,GAAG,oBAAsD;IACzD,MAAM,EAAE,YAAY;CACe,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAkB;IAClD,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,YAAuC;IAEvC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACvC,IAAI,EAAE,UAAmB;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;IACD,KAAK,EAAE;QACL,CAAC,GAA2B,EAAE,EAAE;YAC9B,IAAI,CAAC,GAAG,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC;YAC5B,OAAO,GAAG,CAAC,KAAK,CAAC;QACnB,CAAC;KACF;IACD,WAAW,EAAE;QACX,gEAAgE;QAChE;YACE,IAAI,EAAE,YAAqB;YAC3B,KAAK,EAAE,qCAAqC;YAC5C,KAAK,EAAE;gBACL,CAAC,GAA2B,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC;aAC3D;SACF;KACF;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAwC;IAC7E,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output task type
|
|
3
|
+
*
|
|
4
|
+
* Uses the full userModule (passed via workflowBase) as the prompt.
|
|
5
|
+
* This module only adds:
|
|
6
|
+
* - An instruction to refer to the pre-computed task results in materials
|
|
7
|
+
* - The execution log as materials
|
|
8
|
+
*
|
|
9
|
+
* The model sees the original user prompt with task results injected,
|
|
10
|
+
* so it naturally produces the expected response.
|
|
11
|
+
*
|
|
12
|
+
* Builtin tools: none (external tools are still available if provided)
|
|
13
|
+
*/
|
|
14
|
+
import type { TaskTypeConfig } from './index.js';
|
|
15
|
+
export declare const config: TaskTypeConfig;
|
|
16
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/task-types/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAiBjD,eAAO,MAAM,MAAM,EAAE,cAGpB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output task type
|
|
3
|
+
*
|
|
4
|
+
* Uses the full userModule (passed via workflowBase) as the prompt.
|
|
5
|
+
* This module only adds:
|
|
6
|
+
* - An instruction to refer to the pre-computed task results in materials
|
|
7
|
+
* - The execution log as materials
|
|
8
|
+
*
|
|
9
|
+
* The model sees the original user prompt with task results injected,
|
|
10
|
+
* so it naturally produces the expected response.
|
|
11
|
+
*
|
|
12
|
+
* Builtin tools: none (external tools are still available if provided)
|
|
13
|
+
*/
|
|
14
|
+
import { buildPreviousResultsMaterials } from './index.js';
|
|
15
|
+
const outputModule = {
|
|
16
|
+
instructions: [
|
|
17
|
+
'- Refer to the pre-computed results in materials to compose your response.',
|
|
18
|
+
'- If tools are available, you may call them to gather additional information needed for the response.',
|
|
19
|
+
],
|
|
20
|
+
materials: [
|
|
21
|
+
(ctx) => {
|
|
22
|
+
if (!ctx.executionLog?.length)
|
|
23
|
+
return null;
|
|
24
|
+
return buildPreviousResultsMaterials(ctx.executionLog);
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
export const config = {
|
|
29
|
+
module: outputModule,
|
|
30
|
+
builtinToolNames: [],
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/task-types/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,YAAY,GAAyC;IACzD,YAAY,EAAE;QACZ,4EAA4E;QAC5E,uGAAuG;KACxG;IAED,SAAS,EAAE;QACT,CAAC,GAA2B,EAAE,EAAE;YAC9B,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM;gBAAE,OAAO,IAAI,CAAC;YAC3C,OAAO,6BAA6B,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACzD,CAAC;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAmB;IACpC,MAAM,EAAE,YAAY;IACpB,gBAAgB,EAAE,EAAE;CACrB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning task type
|
|
3
|
+
*
|
|
4
|
+
* Analyzes the user prompt and extracts complexity to design a task sequence.
|
|
5
|
+
* The userModule is converted to a single formatted material ("Prompt to analyze")
|
|
6
|
+
* using distribute() + formatCompletionPrompt().
|
|
7
|
+
*
|
|
8
|
+
* Data side:
|
|
9
|
+
* - userModule compiled as "Prompt to analyze" material
|
|
10
|
+
* - ctx.inputs
|
|
11
|
+
*
|
|
12
|
+
* Output side:
|
|
13
|
+
* - cue: user message instructing to call __insert_tasks tool
|
|
14
|
+
*
|
|
15
|
+
* Tools: __insert_tasks
|
|
16
|
+
*/
|
|
17
|
+
import type { TaskTypeConfig } from './index.js';
|
|
18
|
+
export declare const config: TaskTypeConfig;
|
|
19
|
+
//# sourceMappingURL=planning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/task-types/planning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAyDjD,eAAO,MAAM,MAAM,EAAE,cAGpB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning task type
|
|
3
|
+
*
|
|
4
|
+
* Analyzes the user prompt and extracts complexity to design a task sequence.
|
|
5
|
+
* The userModule is converted to a single formatted material ("Prompt to analyze")
|
|
6
|
+
* using distribute() + formatCompletionPrompt().
|
|
7
|
+
*
|
|
8
|
+
* Data side:
|
|
9
|
+
* - userModule compiled as "Prompt to analyze" material
|
|
10
|
+
* - ctx.inputs
|
|
11
|
+
*
|
|
12
|
+
* Output side:
|
|
13
|
+
* - cue: user message instructing to call __insert_tasks tool
|
|
14
|
+
*
|
|
15
|
+
* Tools: __insert_tasks
|
|
16
|
+
*/
|
|
17
|
+
import { distribute } from '@modular-prompt/core';
|
|
18
|
+
import { formatCompletionPrompt } from '@modular-prompt/driver';
|
|
19
|
+
const planningModule = {
|
|
20
|
+
objective: [
|
|
21
|
+
'- Analyze the given prompt and extract complexity to design a task sequence.',
|
|
22
|
+
],
|
|
23
|
+
instructions: [
|
|
24
|
+
'- Analyze the prompt shown in "Prompt to analyze" and design the Tasks needed for execution.',
|
|
25
|
+
'- Call `__insert_tasks` once with a `tasks` array to register all Tasks.',
|
|
26
|
+
'- Each Task instruction should be concise: describe only what to focus on and what to do.',
|
|
27
|
+
'- Each Task receives all previous task results, so earlier results are available to later Tasks.',
|
|
28
|
+
'- Tools can be called from each Task, but tool results are received by the next Task.',
|
|
29
|
+
{
|
|
30
|
+
type: 'subsection',
|
|
31
|
+
title: 'Analysis Approach',
|
|
32
|
+
items: [
|
|
33
|
+
'1. **Inputs and outputs**: Understand what the final goal requires and what is available.',
|
|
34
|
+
'2. **Identify complexity**: Determine which parts of the prompt are complex and need decomposition. A simple prompt may need only one Task.',
|
|
35
|
+
'3. **Dependencies**: Identify what information is needed first and the correct processing order.',
|
|
36
|
+
'4. **Tool usage**: Identify where tool calls are required.',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
materials: [
|
|
41
|
+
(ctx) => {
|
|
42
|
+
if (!ctx.userModule)
|
|
43
|
+
return null;
|
|
44
|
+
const compiled = distribute(ctx.userModule);
|
|
45
|
+
const text = formatCompletionPrompt(compiled, {
|
|
46
|
+
sectionDescriptions: {},
|
|
47
|
+
});
|
|
48
|
+
if (!text.trim())
|
|
49
|
+
return null;
|
|
50
|
+
return {
|
|
51
|
+
type: 'material',
|
|
52
|
+
id: 'user-prompt',
|
|
53
|
+
title: 'Prompt to analyze',
|
|
54
|
+
content: text,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
inputs: [
|
|
59
|
+
(ctx) => {
|
|
60
|
+
if (!ctx.inputs)
|
|
61
|
+
return null;
|
|
62
|
+
return JSON.stringify(ctx.inputs, null, 2);
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
cue: [
|
|
66
|
+
{
|
|
67
|
+
type: 'message',
|
|
68
|
+
role: 'user',
|
|
69
|
+
content: 'Analyze the prompt and register tasks by calling `__insert_tasks`.',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
export const config = {
|
|
74
|
+
module: planningModule,
|
|
75
|
+
builtinToolNames: ['__insert_tasks'],
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=planning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planning.js","sourceRoot":"","sources":["../../../../src/workflows/agentic-workflow/task-types/planning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,MAAM,cAAc,GAAyC;IAC3D,SAAS,EAAE;QACT,8EAA8E;KAC/E;IACD,YAAY,EAAE;QACZ,8FAA8F;QAC9F,0EAA0E;QAC1E,2FAA2F;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olvedModule } from '@modular-prompt/core';
|
|
3
|
+
import type { ModelRole } from '../driver-input.js';
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
5
|
+
* Tool specification: definition for AI + handler for execution
|
|
3
6
|
*/
|
|
4
|
-
export
|
|
7
|
+
export interface ToolSpec {
|
|
8
|
+
definition: ToolDefinition;
|
|
9
|
+
handler: (args: Record<string, unknown>) => Promise<unknown>;
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
|
-
*
|
|
12
|
+
* Tool call log entry (builtin tool execution record)
|
|
7
13
|
*/
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
constraints?: string[];
|
|
13
|
-
actions?: Array<{
|
|
14
|
-
tool: string;
|
|
15
|
-
params?: any;
|
|
16
|
-
}>;
|
|
14
|
+
export interface ToolCallLog {
|
|
15
|
+
name: string;
|
|
16
|
+
arguments: Record<string, unknown>;
|
|
17
|
+
result: unknown;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Built-in task types.
|
|
21
|
+
*
|
|
22
|
+
* Each type defines its own input contract:
|
|
23
|
+
* - What context data it receives (instructions vs data)
|
|
24
|
+
* - What tools are available
|
|
25
|
+
* - Default driver role
|
|
20
26
|
*/
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
export type TaskType = 'planning' | 'toolCall' | 'think' | 'verify' | 'extractContext' | 'recall' | 'determine' | 'output';
|
|
28
|
+
/**
|
|
29
|
+
* Default driver role for each task type.
|
|
30
|
+
* planning/output are hardcoded; execution tasks are derived from EXECUTION_TASK_DEFS.
|
|
31
|
+
*/
|
|
32
|
+
export declare const DEFAULT_DRIVER_ROLE: Record<TaskType, ModelRole>;
|
|
33
|
+
/**
|
|
34
|
+
* Default withXxx options for each task type
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_DATA_OPTIONS: Record<TaskType, {
|
|
37
|
+
withInputs: boolean;
|
|
38
|
+
withMessages: boolean;
|
|
39
|
+
withMaterials: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Agentic workflow task definition
|
|
43
|
+
*/
|
|
44
|
+
export interface AgenticTask {
|
|
45
|
+
/** What this task should accomplish */
|
|
46
|
+
instruction: string;
|
|
47
|
+
/** Task type determining prompt construction and input contract */
|
|
48
|
+
taskType: TaskType;
|
|
49
|
+
/** Driver role override (defaults per task type) */
|
|
50
|
+
driverRole?: ModelRole;
|
|
51
|
+
/** Include ctx.inputs in data */
|
|
52
|
+
withInputs?: boolean;
|
|
53
|
+
/** Include ctx.messages in data */
|
|
54
|
+
withMessages?: boolean;
|
|
55
|
+
/** Include ctx.materials in data */
|
|
56
|
+
withMaterials?: boolean;
|
|
27
57
|
}
|
|
28
58
|
/**
|
|
29
|
-
*
|
|
59
|
+
* Record of a single task execution
|
|
30
60
|
*/
|
|
31
|
-
export interface
|
|
32
|
-
|
|
61
|
+
export interface AgenticTaskExecutionLog {
|
|
62
|
+
taskType: TaskType;
|
|
63
|
+
result: string;
|
|
64
|
+
pendingToolCalls?: ToolCall[];
|
|
65
|
+
metadata?: {
|
|
66
|
+
usage?: QueryResult['usage'];
|
|
67
|
+
};
|
|
33
68
|
}
|
|
34
69
|
/**
|
|
35
|
-
* Context for agentic workflow
|
|
70
|
+
* Context for agentic workflow.
|
|
71
|
+
*
|
|
72
|
+
* Passed through the entire workflow lifecycle.
|
|
73
|
+
* Each task type selects what it needs from this context.
|
|
36
74
|
*/
|
|
37
75
|
export interface AgenticWorkflowContext {
|
|
76
|
+
/** Primary objective (passed as instruction to all tasks) */
|
|
38
77
|
objective: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
78
|
+
/** Resolved user module (set by agenticProcess via resolve()) */
|
|
79
|
+
userModule?: ResolvedModule;
|
|
80
|
+
/** Structured input data */
|
|
81
|
+
inputs?: Record<string, unknown>;
|
|
82
|
+
/** Current task list */
|
|
83
|
+
taskList?: AgenticTask[];
|
|
84
|
+
/** Execution log of completed tasks */
|
|
85
|
+
executionLog?: AgenticTaskExecutionLog[];
|
|
86
|
+
/** Index of the currently executing task */
|
|
87
|
+
currentTaskIndex?: number;
|
|
88
|
+
/** Persisted state string from previous task execution */
|
|
89
|
+
state?: string;
|
|
49
90
|
}
|
|
50
91
|
/**
|
|
51
92
|
* Options for agentic workflow
|
|
52
93
|
*/
|
|
53
94
|
export interface AgenticWorkflowOptions {
|
|
54
|
-
|
|
55
|
-
|
|
95
|
+
/** Maximum number of tasks (default: 10) */
|
|
96
|
+
maxTasks?: number;
|
|
97
|
+
/** External tools available to tasks */
|
|
98
|
+
tools?: ToolSpec[];
|
|
99
|
+
/** Maximum tool call iterations per task (default: 10) */
|
|
100
|
+
maxToolCalls?: number;
|
|
101
|
+
/** Skip planning and use provided taskList (default: true) */
|
|
56
102
|
enablePlanning?: boolean;
|
|
57
|
-
|
|
58
|
-
|
|
103
|
+
/** Include intermediate task results wrapped in <think> tags before the final output (default: false) */
|
|
104
|
+
includeThinking?: boolean;
|
|
59
105
|
}
|
|
60
106
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,C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