@modular-prompt/process 0.1.27 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +17 -2
  2. package/dist/workflows/agentic-workflow/agentic-workflow.d.ts +12 -8
  3. package/dist/workflows/agentic-workflow/agentic-workflow.d.ts.map +1 -1
  4. package/dist/workflows/agentic-workflow/agentic-workflow.js +182 -205
  5. package/dist/workflows/agentic-workflow/agentic-workflow.js.map +1 -1
  6. package/dist/workflows/agentic-workflow/index.d.ts +5 -2
  7. package/dist/workflows/agentic-workflow/index.d.ts.map +1 -1
  8. package/dist/workflows/agentic-workflow/index.js +5 -2
  9. package/dist/workflows/agentic-workflow/index.js.map +1 -1
  10. package/dist/workflows/agentic-workflow/process/builtin-tools.d.ts +24 -0
  11. package/dist/workflows/agentic-workflow/process/builtin-tools.d.ts.map +1 -0
  12. package/dist/workflows/agentic-workflow/process/builtin-tools.js +134 -0
  13. package/dist/workflows/agentic-workflow/process/builtin-tools.js.map +1 -0
  14. package/dist/workflows/agentic-workflow/process/format-helpers.d.ts +11 -0
  15. package/dist/workflows/agentic-workflow/process/format-helpers.d.ts.map +1 -0
  16. package/dist/workflows/agentic-workflow/process/format-helpers.js +18 -0
  17. package/dist/workflows/agentic-workflow/process/format-helpers.js.map +1 -0
  18. package/dist/workflows/agentic-workflow/process/index.d.ts +7 -0
  19. package/dist/workflows/agentic-workflow/process/index.d.ts.map +1 -0
  20. package/dist/workflows/agentic-workflow/process/index.js +7 -0
  21. package/dist/workflows/agentic-workflow/process/index.js.map +1 -0
  22. package/dist/workflows/agentic-workflow/process/query-with-tools.d.ts +37 -0
  23. package/dist/workflows/agentic-workflow/process/query-with-tools.d.ts.map +1 -0
  24. package/dist/workflows/agentic-workflow/process/query-with-tools.js +118 -0
  25. package/dist/workflows/agentic-workflow/process/query-with-tools.js.map +1 -0
  26. package/dist/workflows/agentic-workflow/task-types/execution-tasks.d.ts +35 -0
  27. package/dist/workflows/agentic-workflow/task-types/execution-tasks.d.ts.map +1 -0
  28. package/dist/workflows/agentic-workflow/task-types/execution-tasks.js +155 -0
  29. package/dist/workflows/agentic-workflow/task-types/execution-tasks.js.map +1 -0
  30. package/dist/workflows/agentic-workflow/task-types/index.d.ts +37 -0
  31. package/dist/workflows/agentic-workflow/task-types/index.d.ts.map +1 -0
  32. package/dist/workflows/agentic-workflow/task-types/index.js +95 -0
  33. package/dist/workflows/agentic-workflow/task-types/index.js.map +1 -0
  34. package/dist/workflows/agentic-workflow/task-types/output.d.ts +16 -0
  35. package/dist/workflows/agentic-workflow/task-types/output.d.ts.map +1 -0
  36. package/dist/workflows/agentic-workflow/task-types/output.js +31 -0
  37. package/dist/workflows/agentic-workflow/task-types/output.js.map +1 -0
  38. package/dist/workflows/agentic-workflow/task-types/planning.d.ts +19 -0
  39. package/dist/workflows/agentic-workflow/task-types/planning.d.ts.map +1 -0
  40. package/dist/workflows/agentic-workflow/task-types/planning.js +77 -0
  41. package/dist/workflows/agentic-workflow/task-types/planning.js.map +1 -0
  42. package/dist/workflows/agentic-workflow/types.d.ts +83 -37
  43. package/dist/workflows/agentic-workflow/types.d.ts.map +1 -1
  44. package/dist/workflows/agentic-workflow/types.js +27 -1
  45. package/dist/workflows/agentic-workflow/types.js.map +1 -1
  46. package/dist/workflows/concat-process-workflow.d.ts +3 -2
  47. package/dist/workflows/concat-process-workflow.d.ts.map +1 -1
  48. package/dist/workflows/concat-process-workflow.js +41 -5
  49. package/dist/workflows/concat-process-workflow.js.map +1 -1
  50. package/dist/workflows/default-workflow.d.ts +3 -2
  51. package/dist/workflows/default-workflow.d.ts.map +1 -1
  52. package/dist/workflows/default-workflow.js +14 -1
  53. package/dist/workflows/default-workflow.js.map +1 -1
  54. package/dist/workflows/dialogue-workflow.d.ts +3 -2
  55. package/dist/workflows/dialogue-workflow.d.ts.map +1 -1
  56. package/dist/workflows/dialogue-workflow.js +15 -3
  57. package/dist/workflows/dialogue-workflow.js.map +1 -1
  58. package/dist/workflows/driver-input.d.ts +16 -0
  59. package/dist/workflows/driver-input.d.ts.map +1 -0
  60. package/dist/workflows/driver-input.js +18 -0
  61. package/dist/workflows/driver-input.js.map +1 -0
  62. package/dist/workflows/index.d.ts +6 -3
  63. package/dist/workflows/index.d.ts.map +1 -1
  64. package/dist/workflows/index.js +5 -2
  65. package/dist/workflows/index.js.map +1 -1
  66. package/dist/workflows/self-prompting-workflow/self-prompting-workflow.d.ts +3 -2
  67. package/dist/workflows/self-prompting-workflow/self-prompting-workflow.d.ts.map +1 -1
  68. package/dist/workflows/self-prompting-workflow/self-prompting-workflow.js +4 -3
  69. package/dist/workflows/self-prompting-workflow/self-prompting-workflow.js.map +1 -1
  70. package/dist/workflows/stream-workflow.d.ts +3 -2
  71. package/dist/workflows/stream-workflow.d.ts.map +1 -1
  72. package/dist/workflows/stream-workflow.js +11 -3
  73. package/dist/workflows/stream-workflow.js.map +1 -1
  74. package/dist/workflows/summarize-workflow.d.ts +3 -2
  75. package/dist/workflows/summarize-workflow.d.ts.map +1 -1
  76. package/dist/workflows/summarize-workflow.js +11 -2
  77. package/dist/workflows/summarize-workflow.js.map +1 -1
  78. package/package.json +4 -3
  79. package/dist/workflows/agent-workflow.d.ts +0 -55
  80. package/dist/workflows/agent-workflow.d.ts.map +0 -1
  81. package/dist/workflows/agent-workflow.js +0 -337
  82. package/dist/workflows/agent-workflow.js.map +0 -1
  83. package/dist/workflows/agentic-workflow/modules/agentic.d.ts +0 -12
  84. package/dist/workflows/agentic-workflow/modules/agentic.d.ts.map +0 -1
  85. package/dist/workflows/agentic-workflow/modules/agentic.js +0 -22
  86. package/dist/workflows/agentic-workflow/modules/agentic.js.map +0 -1
  87. package/dist/workflows/agentic-workflow/modules/execution-freeform.d.ts +0 -15
  88. package/dist/workflows/agentic-workflow/modules/execution-freeform.d.ts.map +0 -1
  89. package/dist/workflows/agentic-workflow/modules/execution-freeform.js +0 -140
  90. package/dist/workflows/agentic-workflow/modules/execution-freeform.js.map +0 -1
  91. package/dist/workflows/agentic-workflow/modules/execution.d.ts +0 -11
  92. package/dist/workflows/agentic-workflow/modules/execution.d.ts.map +0 -1
  93. package/dist/workflows/agentic-workflow/modules/execution.js +0 -180
  94. package/dist/workflows/agentic-workflow/modules/execution.js.map +0 -1
  95. package/dist/workflows/agentic-workflow/modules/index.d.ts +0 -6
  96. package/dist/workflows/agentic-workflow/modules/index.d.ts.map +0 -1
  97. package/dist/workflows/agentic-workflow/modules/index.js +0 -7
  98. package/dist/workflows/agentic-workflow/modules/index.js.map +0 -1
  99. package/dist/workflows/agentic-workflow/modules/integration.d.ts +0 -11
  100. package/dist/workflows/agentic-workflow/modules/integration.d.ts.map +0 -1
  101. package/dist/workflows/agentic-workflow/modules/integration.js +0 -85
  102. package/dist/workflows/agentic-workflow/modules/integration.js.map +0 -1
  103. package/dist/workflows/agentic-workflow/modules/planning.d.ts +0 -11
  104. package/dist/workflows/agentic-workflow/modules/planning.d.ts.map +0 -1
  105. package/dist/workflows/agentic-workflow/modules/planning.js +0 -103
  106. package/dist/workflows/agentic-workflow/modules/planning.js.map +0 -1
package/README.md CHANGED
@@ -10,6 +10,8 @@ npm install @modular-prompt/process
10
10
 
11
11
  ## ワークフロー
12
12
 
13
+ すべてのワークフロー関数は第1引数として `DriverInput` 型(`AIDriver` または `DriverSet`)を受け入れます。これにより、単一のドライバーまたは役割別の複数ドライバーを柔軟に指定できます。
14
+
13
15
  ### 基本ワークフロー
14
16
 
15
17
  - **`defaultProcess`** - 最小のワークフロー(compile + driver.query)
@@ -19,7 +21,9 @@ npm install @modular-prompt/process
19
21
  ### チャンク処理ワークフロー
20
22
 
21
23
  - **`streamProcess`** - ステートを保持しながらチャンクを逐次処理
24
+ - 内部で `streamProcessing` モジュールを自動的にマージ
22
25
  - **`concatProcess`** - 各チャンクを独立して処理し、結果を結合
26
+ - 内部で `concatProcessing` モジュールを自動的にマージ
23
27
 
24
28
  ### エージェント型ワークフロー
25
29
 
@@ -69,14 +73,20 @@ console.log(result.output); // AIの応答
69
73
 
70
74
  ```typescript
71
75
  import { streamProcess } from '@modular-prompt/process';
72
- import { streamProcessing } from '@modular-prompt/process';
73
76
  import { TestDriver } from '@modular-prompt/driver';
74
77
 
75
78
  const driver = new TestDriver(['response1', 'response2']);
76
79
 
80
+ // streamProcessingモジュールは自動的にマージされるため、
81
+ // ユーザーモジュールのみを渡すことができます
82
+ const userModule = {
83
+ objective: ['チャンクを順次処理して要約を作成'],
84
+ instructions: ['各チャンクの内容を前の状態と統合']
85
+ };
86
+
77
87
  const result = await streamProcess(
78
88
  driver,
79
- streamProcessing,
89
+ userModule, // streamProcessingは内部で自動マージ
80
90
  {
81
91
  chunks: [{ content: 'text1' }, { content: 'text2' }],
82
92
  state: { content: '', usage: 0 }
@@ -195,6 +205,11 @@ const result = await agenticProcess(driver, userModule, context, {
195
205
  // AIが計画フェーズで必要なアクションを判断し、実行フェーズで自動的に呼び出す
196
206
  ```
197
207
 
208
+ ## 開発者向けドキュメント
209
+
210
+ ワークフロー実装者向けのドキュメント:
211
+
212
+ - **[ワークフローログ規約](./docs/WORKFLOW_LOG_CONVENTIONS.md)** - Logger 使用規約とログ出力の標準化
198
213
 
199
214
  ## ライセンス
200
215
 
@@ -1,13 +1,17 @@
1
- import type { PromptModule } from '@modular-prompt/core';
2
- import type { AIDriver, WorkflowResult } from '../types.js';
3
- import type { AgenticWorkflowContext, AgenticWorkflowOptions } from './types.js';
4
1
  /**
5
- * Agentic workflow - autonomous multi-step processing with planning
2
+ * Agentic workflow v2 - task sequence based processing
3
+ *
4
+ * Fixed phases are replaced by a task sequence.
5
+ * Each task type has its own prompt construction and input contract.
6
6
  *
7
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
8
+ * 1. Bootstrap: Generate initial task list [planning, outputXxx]
9
+ * 2. Task loop: Execute each task sequentially
10
+ * 3. Output: Last task (outputMessage/outputStructured) result is the final output
11
11
  */
12
- export declare function agenticProcess(driver: AIDriver, module: PromptModule<AgenticWorkflowContext>, context: AgenticWorkflowContext, options?: AgenticWorkflowOptions): Promise<WorkflowResult<AgenticWorkflowContext>>;
12
+ import type { PromptModule } from '@modular-prompt/core';
13
+ import type { WorkflowResult } from '../types.js';
14
+ import type { AgenticWorkflowContext, AgenticWorkflowOptions } from './types.js';
15
+ import { type DriverInput } from '../driver-input.js';
16
+ export declare function agenticProcess(driver: DriverInput, module: PromptModule<AgenticWorkflowContext>, context: AgenticWorkflowContext, options?: AgenticWorkflowOptions): Promise<WorkflowResult<AgenticWorkflowContext>>;
13
17
  //# sourceMappingURL=agentic-workflow.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"agentic-workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/agentic-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,sBAAsB,CAAC;AAGzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EAKvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,oBAAoB,CAAC;AA0JrE,wBAAsB,cAAc,CAClC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,YAAY,CAAC,sBAAsB,CAAC,EAC5C,OAAO,EAAE,sBAAsB,EAC/B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAqHjD"}
@@ -1,235 +1,212 @@
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
1
  /**
9
- * Execute planning phase
2
+ * Agentic workflow v2 - task sequence based processing
3
+ *
4
+ * Fixed phases are replaced by a task sequence.
5
+ * Each task type has its own prompt construction and input contract.
6
+ *
7
+ * Flow:
8
+ * 1. Bootstrap: Generate initial task list [planning, outputXxx]
9
+ * 2. Task loop: Execute each task sequentially
10
+ * 3. Output: Last task (outputMessage/outputStructured) result is the final output
10
11
  */
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
- }
12
+ import { merge, resolve } from '@modular-prompt/core';
13
+ import { Logger } from '@modular-prompt/utils';
14
+ import { DEFAULT_DRIVER_ROLE } from './types.js';
15
+ import { resolveDriver } from '../driver-input.js';
16
+ import { getTaskTypeConfig, taskCommon } from './task-types/index.js';
17
+ import { createPlanningTools, createExecutionBuiltinTools, } from './process/builtin-tools.js';
18
+ import { queryWithTools, rethrowAsWorkflowError } from './process/query-with-tools.js';
19
+ const logger = new Logger({ prefix: 'process', context: 'agentic' });
20
+ /**
21
+ * Strip <think>...</think> blocks from model output.
22
+ * Thinking traces are internal reasoning and should not be passed to subsequent tasks.
23
+ */
24
+ function stripThinkBlocks(text) {
25
+ return text.replace(/<think>[\s\S]*?<\/think>\s*/g, '').replace(/^[\s\S]*?<\/think>\s*/g, '').trim();
53
26
  }
27
+ // ---------------------------------------------------------------------------
28
+ // Bootstrap
29
+ // ---------------------------------------------------------------------------
54
30
  /**
55
- * Execute a single step
31
+ * Generate the initial task list based on the user module.
32
+ * - Always starts with a planning task.
33
+ * - Ends with outputStructured (if schema) or outputMessage.
56
34
  */
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
- };
35
+ function bootstrap(module, enablePlanning) {
36
+ const tasks = [];
37
+ if (enablePlanning) {
38
+ tasks.push({
39
+ instruction: 'Analyze the prompt and register tasks',
40
+ taskType: 'planning',
41
+ });
136
42
  }
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')
43
+ else {
44
+ // No planning: default to a single output task
45
+ tasks.push({
46
+ instruction: 'Compose the response using the preceding task results.',
47
+ taskType: 'output',
144
48
  });
145
49
  }
50
+ return tasks;
146
51
  }
52
+ // ---------------------------------------------------------------------------
53
+ // Task execution
54
+ // ---------------------------------------------------------------------------
147
55
  /**
148
- * Execute execution phase
56
+ * Get builtin tools for a task based on its type config.
149
57
  */
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);
58
+ function getBuiltinToolsForTask(taskType, taskList, currentIndex) {
59
+ const config = getTaskTypeConfig(taskType);
60
+ const toolNames = new Set(config.builtinToolNames);
61
+ const allTools = [];
62
+ if (toolNames.has('__insert_tasks')) {
63
+ allTools.push(...createPlanningTools(taskList, currentIndex));
64
+ }
65
+ if (toolNames.has('__time')) {
66
+ // createExecutionBuiltinTools returns [__insert_tasks, __time]
67
+ // We only want __time if __insert_tasks is not already added
68
+ const execTools = createExecutionBuiltinTools(taskList, currentIndex);
69
+ const timeOnly = execTools.filter(t => t.definition.name === '__time');
70
+ allTools.push(...timeOnly);
159
71
  }
160
- return executionLog;
72
+ return allTools;
161
73
  }
162
74
  /**
163
- * Execute integration phase
75
+ * Execute a single task.
164
76
  */
165
- async function executeIntegrationPhase(driver, module, context, executionLog, logger) {
166
- const integrationModule = merge(agentic, integration, module);
167
- const finalPrompt = compile(integrationModule, context);
77
+ async function executeTask(driver, userModule, context, task, taskIndex, taskList, externalTools, maxToolCalls) {
78
+ const taskLogger = logger.context(`agentic:task:${taskIndex + 1}:${task.taskType}`);
79
+ taskLogger.info('[start]', task.instruction);
80
+ const taskConfig = getTaskTypeConfig(task.taskType);
81
+ // Build workflowBase from resolved userModule
82
+ // output tasks get the full userModule; other tasks get objective/terms only
83
+ const workflowBase = task.taskType === 'output'
84
+ ? { ...userModule }
85
+ : {
86
+ objective: userModule.objective,
87
+ terms: userModule.terms,
88
+ };
89
+ // Merge and resolve (taskCommon first for objective framing)
90
+ const resolved = resolve(merge(workflowBase, taskCommon, taskConfig.module), context);
91
+ const builtinTools = getBuiltinToolsForTask(task.taskType, taskList, taskIndex);
92
+ const externalToolDefs = externalTools.map(t => t.definition);
93
+ const allToolNames = [...builtinTools.map(t => t.definition.name), ...externalToolDefs.map(t => t.name)];
94
+ taskLogger.verbose('[prompt]', JSON.stringify(resolved), allToolNames.length > 0 ? `tools: [${allToolNames.join(', ')}]` : '');
95
+ const driverRole = task.driverRole || DEFAULT_DRIVER_ROLE[task.taskType];
168
96
  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;
97
+ const isPlanning = task.taskType === 'planning';
98
+ const toolChoice = isPlanning ? 'required' : 'auto';
99
+ const result = await queryWithTools(resolveDriver(driver, driverRole), resolved, builtinTools, {
100
+ externalToolDefs: externalToolDefs.length > 0 ? externalToolDefs : undefined,
101
+ toolChoice,
102
+ maxIterations: maxToolCalls,
103
+ stopAfterToolCall: isPlanning,
104
+ logger: taskLogger,
105
+ });
106
+ taskLogger.info('[end]');
107
+ return {
108
+ taskType: task.taskType,
109
+ result: stripThinkBlocks(result.content),
110
+ pendingToolCalls: result.pendingToolCalls,
111
+ metadata: {
112
+ usage: result.usage,
113
+ },
114
+ };
180
115
  }
181
116
  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')
117
+ rethrowAsWorkflowError(error, context, {
118
+ phase: task.taskType,
119
+ partialResult: context.executionLog?.map(log => log.result).join('\n\n') || '',
188
120
  });
189
121
  }
190
122
  }
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
- */
123
+ // ---------------------------------------------------------------------------
124
+ // Main workflow
125
+ // ---------------------------------------------------------------------------
199
126
  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;
127
+ logger.info('[start] agentic workflow');
128
+ const { maxTasks = 10, tools = [], maxToolCalls = 10, enablePlanning = true, includeThinking = false, } = options;
129
+ // Resolve user module: DynamicContent → static values
130
+ // userModule is available throughout the workflow via context.userModule
131
+ const userModule = resolve(module, context);
132
+ context.userModule = userModule;
133
+ // Bootstrap task list
134
+ const taskList = bootstrap(userModule, enablePlanning);
135
+ const executionLog = context.executionLog
136
+ ? [...context.executionLog]
137
+ : [];
138
+ const startIndex = executionLog.length;
139
+ // Task loop
140
+ for (let i = startIndex; i < taskList.length; i++) {
141
+ // Guard: max tasks
142
+ if (i >= maxTasks) {
143
+ logger.info('[end] Max tasks reached', `(${maxTasks})`);
144
+ break;
145
+ }
146
+ const task = taskList[i];
147
+ const currentContext = {
148
+ ...context,
149
+ taskList,
150
+ executionLog,
151
+ currentTaskIndex: i,
152
+ };
153
+ const logEntry = await executeTask(driver, userModule, currentContext, task, i, taskList, tools, maxToolCalls);
154
+ executionLog.push(logEntry);
155
+ }
156
+ // Auto-append output task if the last executed task was not output
157
+ const lastExecuted = executionLog[executionLog.length - 1];
158
+ if (lastExecuted && lastExecuted.taskType !== 'output') {
159
+ const outputTask = {
160
+ instruction: 'Compose the response using the preceding task results.',
161
+ taskType: 'output',
162
+ };
163
+ taskList.push(outputTask);
164
+ const outputIndex = taskList.length - 1;
165
+ const outputContext = {
166
+ ...context,
167
+ taskList,
168
+ executionLog,
169
+ currentTaskIndex: outputIndex,
170
+ };
171
+ const outputLog = await executeTask(driver, userModule, outputContext, outputTask, outputIndex, taskList, tools, maxToolCalls);
172
+ executionLog.push(outputLog);
173
+ }
174
+ // Final output: last task's result, optionally prefixed with intermediate results as <think>
175
+ const lastLog = executionLog[executionLog.length - 1];
176
+ const finalResult = lastLog?.result || '';
177
+ let output;
178
+ if (includeThinking && executionLog.length > 1) {
179
+ const intermediateLog = executionLog.slice(0, -1);
180
+ const thinkingLines = intermediateLog
181
+ .map(log => `[${log.taskType}]\n${log.result}`)
182
+ .join('\n\n');
183
+ output = `<think>\n${thinkingLines}\n</think>\n\n${finalResult}`;
208
184
  }
209
185
  else {
210
- // Use existing plan
211
- plan = currentContext.plan;
186
+ output = finalResult;
212
187
  }
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
- };
188
+ // Determine finishReason
189
+ const hasPendingToolCalls = executionLog.some(log => log.pendingToolCalls && log.pendingToolCalls.length > 0);
190
+ const finishReason = hasPendingToolCalls
191
+ ? 'tool_calls'
192
+ : 'stop';
193
+ const totalToolCalls = executionLog.reduce((sum, log) => sum + (log.pendingToolCalls?.length || 0), 0);
194
+ logger.info('[end] agentic workflow');
225
195
  return {
226
- output: finalOutput,
227
- context: finalContext,
196
+ output,
197
+ context: {
198
+ ...context,
199
+ taskList,
200
+ executionLog,
201
+ currentTaskIndex: taskList.length,
202
+ },
228
203
  metadata: {
229
- planSteps: plan.steps.length,
230
- executedSteps: executionLog.length,
231
- actionsUsed: executionLog.filter(log => log.actionResult !== undefined).length
232
- }
204
+ planTasks: taskList.length,
205
+ executedTasks: executionLog.length,
206
+ toolCallsUsed: totalToolCalls,
207
+ finishReason,
208
+ usage: lastLog?.metadata?.usage,
209
+ },
233
210
  };
234
211
  }
235
212
  //# sourceMappingURL=agentic-workflow.js.map
@@ -1 +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,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,CAAC,CAC3D,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAEtC,OAAO;QACL,MAAM;QACN,OAAO,EAAE;YACP,GAAG,OAAO;YACV,QAAQ;YACR,YAAY;YACZ,gBAAgB,EAAE,QAAQ,CAAC,MAAM;SAClC;QACD,QAAQ,EAAE;YACR,SAAS,EAAE,QAAQ,CAAC,MAAM;YAC1B,aAAa,EAAE,YAAY,CAAC,MAAM;YAClC,aAAa,EAAE,cAAc;YAC7B,YAAY;YACZ,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK;SAChC;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +1,7 @@
1
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';
2
+ export type { AgenticWorkflowContext, AgenticWorkflowOptions, AgenticTask, AgenticTaskExecutionLog, TaskType, ToolSpec, ToolCallLog, } from './types.js';
3
+ export { DEFAULT_DRIVER_ROLE, DEFAULT_DATA_OPTIONS } from './types.js';
4
+ export { BUILTIN_TOOL_PREFIX, isBuiltinTool } from './process/builtin-tools.js';
5
+ export { getTaskTypeConfig, taskCommon } from './task-types/index.js';
6
+ export type { TaskTypeConfig } from './task-types/index.js';
4
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,WAAW,EACX,uBAAuB,EACvB,QAAQ,EACR,QAAQ,EACR,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGhF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,5 +1,8 @@
1
1
  // Agentic workflow
2
2
  export { agenticProcess } from './agentic-workflow.js';
3
- // Modules
4
- export { agentic, planning, execution, executionFreeform, integration } from './modules/index.js';
3
+ export { DEFAULT_DRIVER_ROLE, DEFAULT_DATA_OPTIONS } from './types.js';
4
+ // Builtin tools
5
+ export { BUILTIN_TOOL_PREFIX, isBuiltinTool } from './process/builtin-tools.js';
6
+ // Task type registry
7
+ export { getTaskTypeConfig, taskCommon } from './task-types/index.js';
5
8
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
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;AAavD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvE,gBAAgB;AAChB,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhF,qBAAqB;AACrB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Agentic workflow 組み込みツール定義 (v2)
3
+ *
4
+ * - __insert_tasks: タスク登録(全タスクから利用可能)
5
+ * - __time: 現在時刻取得
6
+ */
7
+ import type { ToolSpec, AgenticTask } from '../types.js';
8
+ export declare const BUILTIN_TOOL_PREFIX = "__";
9
+ /**
10
+ * 組み込みツールかどうかを判定
11
+ */
12
+ export declare function isBuiltinTool(name: string): boolean;
13
+ /**
14
+ * Planning フェーズ用の組み込みツールを生成
15
+ *
16
+ * __insert_tasks ツールは tasks 配列で複数タスクを一括登録する。
17
+ * 単体の instruction 指定も後方互換として受け付ける。
18
+ */
19
+ export declare function createPlanningTools(taskList: AgenticTask[], currentIndex: number): ToolSpec[];
20
+ /**
21
+ * Execution フェーズ用の組み込みツールを生成
22
+ */
23
+ export declare function createExecutionBuiltinTools(taskList: AgenticTask[], currentIndex: number): ToolSpec[];
24
+ //# sourceMappingURL=builtin-tools.d.ts.map