@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.
- package/README.md +17 -2
- 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 +182 -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 +24 -0
- package/dist/workflows/agentic-workflow/process/builtin-tools.d.ts.map +1 -0
- package/dist/workflows/agentic-workflow/process/builtin-tools.js +134 -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 +95 -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 +31 -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
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 -
|
|
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.
|
|
9
|
-
* 2.
|
|
10
|
-
* 3.
|
|
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
|
-
|
|
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":"
|
|
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
|
-
*
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
*
|
|
56
|
+
* Get builtin tools for a task based on its type config.
|
|
149
57
|
*/
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|
72
|
+
return allTools;
|
|
161
73
|
}
|
|
162
74
|
/**
|
|
163
|
-
* Execute
|
|
75
|
+
* Execute a single task.
|
|
164
76
|
*/
|
|
165
|
-
async function
|
|
166
|
-
const
|
|
167
|
-
|
|
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
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return
|
|
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
|
-
|
|
183
|
-
|
|
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
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
211
|
-
plan = currentContext.plan;
|
|
186
|
+
output = finalResult;
|
|
212
187
|
}
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
|
227
|
-
context:
|
|
196
|
+
output,
|
|
197
|
+
context: {
|
|
198
|
+
...context,
|
|
199
|
+
taskList,
|
|
200
|
+
executionLog,
|
|
201
|
+
currentTaskIndex: taskList.length,
|
|
202
|
+
},
|
|
228
203
|
metadata: {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"agentic-workflow.js","sourceRoot":"","sources":["../../../src/workflows/agentic-workflow/agentic-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAU/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAoB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAA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AAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,IAAI,CAAC,CAAC,EAAE,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,
|
|
3
|
-
export {
|
|
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,
|
|
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
|
-
|
|
4
|
-
|
|
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;
|
|
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
|