@nahisaho/katashiro-orchestrator 1.2.0 → 2.0.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/LICENSE +21 -0
- package/dist/agent/AgentStateManager.d.ts +133 -0
- package/dist/agent/AgentStateManager.d.ts.map +1 -0
- package/dist/agent/AgentStateManager.js +243 -0
- package/dist/agent/AgentStateManager.js.map +1 -0
- package/dist/agent/ReActHelper.d.ts +139 -0
- package/dist/agent/ReActHelper.d.ts.map +1 -0
- package/dist/agent/ReActHelper.js +342 -0
- package/dist/agent/ReActHelper.js.map +1 -0
- package/dist/agent/index.d.ts +9 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +20 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/types.d.ts +108 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +9 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/cascading/CascadingAgent.d.ts +156 -0
- package/dist/cascading/CascadingAgent.d.ts.map +1 -0
- package/dist/cascading/CascadingAgent.js +368 -0
- package/dist/cascading/CascadingAgent.js.map +1 -0
- package/dist/cascading/CascadingResearchEngine.d.ts +87 -0
- package/dist/cascading/CascadingResearchEngine.d.ts.map +1 -0
- package/dist/cascading/CascadingResearchEngine.js +329 -0
- package/dist/cascading/CascadingResearchEngine.js.map +1 -0
- package/dist/cascading/StepExecutor.d.ts +94 -0
- package/dist/cascading/StepExecutor.d.ts.map +1 -0
- package/dist/cascading/StepExecutor.js +315 -0
- package/dist/cascading/StepExecutor.js.map +1 -0
- package/dist/cascading/StepResultIntegrator.d.ts +101 -0
- package/dist/cascading/StepResultIntegrator.d.ts.map +1 -0
- package/dist/cascading/StepResultIntegrator.js +343 -0
- package/dist/cascading/StepResultIntegrator.js.map +1 -0
- package/dist/cascading/index.d.ts +16 -0
- package/dist/cascading/index.d.ts.map +1 -0
- package/dist/cascading/index.js +33 -0
- package/dist/cascading/index.js.map +1 -0
- package/dist/cascading/types.d.ts +369 -0
- package/dist/cascading/types.d.ts.map +1 -0
- package/dist/cascading/types.js +172 -0
- package/dist/cascading/types.js.map +1 -0
- package/dist/consensus/AsciiDiagramConverter.d.ts +45 -0
- package/dist/consensus/AsciiDiagramConverter.d.ts.map +1 -0
- package/dist/consensus/AsciiDiagramConverter.js +460 -0
- package/dist/consensus/AsciiDiagramConverter.js.map +1 -0
- package/dist/consensus/ConsensusResearchEngine.d.ts +4 -3
- package/dist/consensus/ConsensusResearchEngine.d.ts.map +1 -1
- package/dist/consensus/ConsensusResearchEngine.js +17 -5
- package/dist/consensus/ConsensusResearchEngine.js.map +1 -1
- package/dist/consensus/ReportPostProcessor.d.ts +51 -0
- package/dist/consensus/ReportPostProcessor.d.ts.map +1 -0
- package/dist/consensus/ReportPostProcessor.js +162 -0
- package/dist/consensus/ReportPostProcessor.js.map +1 -0
- package/dist/consensus/index.d.ts +5 -2
- package/dist/consensus/index.d.ts.map +1 -1
- package/dist/consensus/index.js +8 -1
- package/dist/consensus/index.js.map +1 -1
- package/dist/consensus/types.d.ts +68 -2
- package/dist/consensus/types.d.ts.map +1 -1
- package/dist/consensus/types.js +13 -3
- package/dist/consensus/types.js.map +1 -1
- package/dist/dialogue/index.d.ts +2 -0
- package/dist/dialogue/index.d.ts.map +1 -1
- package/dist/dialogue/index.js +5 -1
- package/dist/dialogue/index.js.map +1 -1
- package/dist/dialogue/llm-dialogue-collector.d.ts +169 -0
- package/dist/dialogue/llm-dialogue-collector.d.ts.map +1 -0
- package/dist/dialogue/llm-dialogue-collector.js +449 -0
- package/dist/dialogue/llm-dialogue-collector.js.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -2
- package/dist/index.js.map +1 -1
- package/dist/tool-registry.d.ts +13 -1
- package/dist/tool-registry.d.ts.map +1 -1
- package/dist/tool-registry.js +18 -0
- package/dist/tool-registry.js.map +1 -1
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +15 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/standard-tools.d.ts +121 -0
- package/dist/tools/standard-tools.d.ts.map +1 -0
- package/dist/tools/standard-tools.js +348 -0
- package/dist/tools/standard-tools.js.map +1 -0
- package/package.json +14 -14
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ReAct Helper
|
|
4
|
+
*
|
|
5
|
+
* ReAct(Reasoning + Acting)パターンの出力をパースするヘルパー
|
|
6
|
+
*
|
|
7
|
+
* @requirement REQ-AGENT-004
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ReActHelper = exports.REACT_SYSTEM_PROMPT = exports.DEFAULT_REACT_FORMAT = void 0;
|
|
11
|
+
exports.parseReActOutput = parseReActOutput;
|
|
12
|
+
exports.extractNextReActAction = extractNextReActAction;
|
|
13
|
+
/**
|
|
14
|
+
* デフォルトのReActフォーマット
|
|
15
|
+
*/
|
|
16
|
+
exports.DEFAULT_REACT_FORMAT = {
|
|
17
|
+
thoughtPrefix: 'Thought:',
|
|
18
|
+
actionPrefix: 'Action:',
|
|
19
|
+
actionInputPrefix: 'Action Input:',
|
|
20
|
+
observationPrefix: 'Observation:',
|
|
21
|
+
finalAnswerPrefix: 'Final Answer:',
|
|
22
|
+
caseInsensitive: true,
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* ReActプロンプトテンプレート
|
|
26
|
+
*/
|
|
27
|
+
exports.REACT_SYSTEM_PROMPT = `You are an AI assistant that uses the ReAct (Reasoning and Acting) pattern.
|
|
28
|
+
|
|
29
|
+
For each step, you should:
|
|
30
|
+
1. **Thought**: Think about what you need to do next
|
|
31
|
+
2. **Action**: Choose a tool to use
|
|
32
|
+
3. **Action Input**: Provide the input for the tool
|
|
33
|
+
4. **Observation**: (This will be filled in with the tool's output)
|
|
34
|
+
|
|
35
|
+
Continue this process until you can provide a final answer.
|
|
36
|
+
|
|
37
|
+
When you have enough information to answer the question, respond with:
|
|
38
|
+
Final Answer: [your answer]
|
|
39
|
+
|
|
40
|
+
Format your response as:
|
|
41
|
+
Thought: [your reasoning]
|
|
42
|
+
Action: [tool name]
|
|
43
|
+
Action Input: [tool input]
|
|
44
|
+
|
|
45
|
+
Available tools:
|
|
46
|
+
{tools}
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* ReActヘルパー
|
|
50
|
+
*/
|
|
51
|
+
class ReActHelper {
|
|
52
|
+
config;
|
|
53
|
+
constructor(config = {}) {
|
|
54
|
+
this.config = { ...exports.DEFAULT_REACT_FORMAT, ...config };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* ReAct形式のテキストをパース
|
|
58
|
+
*/
|
|
59
|
+
parse(text) {
|
|
60
|
+
const errors = [];
|
|
61
|
+
const actions = [];
|
|
62
|
+
let finalAnswer;
|
|
63
|
+
const lines = text.split('\n');
|
|
64
|
+
let currentStep = {};
|
|
65
|
+
let stepNumber = 1;
|
|
66
|
+
let inActionInput = false;
|
|
67
|
+
let actionInputBuffer = '';
|
|
68
|
+
for (let i = 0; i < lines.length; i++) {
|
|
69
|
+
const line = lines[i];
|
|
70
|
+
if (line === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
const trimmedLine = line.trim();
|
|
73
|
+
// 空行はスキップ
|
|
74
|
+
if (!trimmedLine) {
|
|
75
|
+
if (inActionInput) {
|
|
76
|
+
actionInputBuffer += '\n';
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
// 各プレフィックスをチェック
|
|
81
|
+
if (this.matchesPrefix(trimmedLine, this.config.thoughtPrefix)) {
|
|
82
|
+
// 前のステップを保存
|
|
83
|
+
if (Object.keys(currentStep).length > 0) {
|
|
84
|
+
if (inActionInput && currentStep.action) {
|
|
85
|
+
currentStep.action.input = this.parseActionInput(actionInputBuffer.trim());
|
|
86
|
+
inActionInput = false;
|
|
87
|
+
actionInputBuffer = '';
|
|
88
|
+
}
|
|
89
|
+
actions.push({ step: stepNumber++, ...currentStep });
|
|
90
|
+
currentStep = {};
|
|
91
|
+
}
|
|
92
|
+
currentStep.thought = this.extractValue(trimmedLine, this.config.thoughtPrefix);
|
|
93
|
+
}
|
|
94
|
+
else if (this.matchesPrefix(trimmedLine, this.config.actionPrefix)) {
|
|
95
|
+
if (inActionInput && currentStep.action) {
|
|
96
|
+
currentStep.action.input = this.parseActionInput(actionInputBuffer.trim());
|
|
97
|
+
inActionInput = false;
|
|
98
|
+
actionInputBuffer = '';
|
|
99
|
+
}
|
|
100
|
+
const toolName = this.extractValue(trimmedLine, this.config.actionPrefix);
|
|
101
|
+
currentStep.action = { tool: toolName, input: '' };
|
|
102
|
+
}
|
|
103
|
+
else if (this.matchesPrefix(trimmedLine, this.config.actionInputPrefix)) {
|
|
104
|
+
const inputValue = this.extractValue(trimmedLine, this.config.actionInputPrefix);
|
|
105
|
+
if (currentStep.action) {
|
|
106
|
+
// 複数行の入力をサポート
|
|
107
|
+
actionInputBuffer = inputValue;
|
|
108
|
+
inActionInput = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (this.matchesPrefix(trimmedLine, this.config.observationPrefix)) {
|
|
112
|
+
if (inActionInput && currentStep.action) {
|
|
113
|
+
currentStep.action.input = this.parseActionInput(actionInputBuffer.trim());
|
|
114
|
+
inActionInput = false;
|
|
115
|
+
actionInputBuffer = '';
|
|
116
|
+
}
|
|
117
|
+
currentStep.observation = this.extractValue(trimmedLine, this.config.observationPrefix);
|
|
118
|
+
}
|
|
119
|
+
else if (this.matchesPrefix(trimmedLine, this.config.finalAnswerPrefix)) {
|
|
120
|
+
if (inActionInput && currentStep.action) {
|
|
121
|
+
currentStep.action.input = this.parseActionInput(actionInputBuffer.trim());
|
|
122
|
+
inActionInput = false;
|
|
123
|
+
actionInputBuffer = '';
|
|
124
|
+
}
|
|
125
|
+
finalAnswer = this.extractValue(trimmedLine, this.config.finalAnswerPrefix);
|
|
126
|
+
currentStep.finalAnswer = finalAnswer;
|
|
127
|
+
}
|
|
128
|
+
else if (inActionInput) {
|
|
129
|
+
// Action Inputの継続行
|
|
130
|
+
actionInputBuffer += '\n' + line;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// 最後のステップを保存
|
|
134
|
+
if (Object.keys(currentStep).length > 0) {
|
|
135
|
+
if (inActionInput && currentStep.action) {
|
|
136
|
+
currentStep.action.input = this.parseActionInput(actionInputBuffer.trim());
|
|
137
|
+
}
|
|
138
|
+
actions.push({ step: stepNumber, ...currentStep });
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
success: actions.length > 0 || finalAnswer !== undefined,
|
|
142
|
+
actions,
|
|
143
|
+
finalAnswer,
|
|
144
|
+
errors,
|
|
145
|
+
rawText: text,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* ReActステップをAgentActionに変換
|
|
150
|
+
*/
|
|
151
|
+
toAgentActions(steps) {
|
|
152
|
+
const actions = [];
|
|
153
|
+
const now = new Date().toISOString();
|
|
154
|
+
for (const step of steps) {
|
|
155
|
+
// Thoughtアクション
|
|
156
|
+
if (step.thought) {
|
|
157
|
+
actions.push({
|
|
158
|
+
step: step.step,
|
|
159
|
+
timestamp: now,
|
|
160
|
+
type: 'thought',
|
|
161
|
+
content: { thought: step.thought },
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
// ツール呼び出しアクション
|
|
165
|
+
if (step.action) {
|
|
166
|
+
actions.push({
|
|
167
|
+
step: step.step,
|
|
168
|
+
timestamp: now,
|
|
169
|
+
type: 'tool_call',
|
|
170
|
+
content: {
|
|
171
|
+
tool: step.action.tool,
|
|
172
|
+
params: typeof step.action.input === 'object'
|
|
173
|
+
? step.action.input
|
|
174
|
+
: { input: step.action.input },
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
// 観察アクション
|
|
179
|
+
if (step.observation) {
|
|
180
|
+
actions.push({
|
|
181
|
+
step: step.step,
|
|
182
|
+
timestamp: now,
|
|
183
|
+
type: 'observation',
|
|
184
|
+
content: {
|
|
185
|
+
result: {
|
|
186
|
+
toolName: step.action?.tool ?? 'unknown',
|
|
187
|
+
success: true,
|
|
188
|
+
data: step.observation,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// 最終回答
|
|
194
|
+
if (step.finalAnswer) {
|
|
195
|
+
actions.push({
|
|
196
|
+
step: step.step,
|
|
197
|
+
timestamp: now,
|
|
198
|
+
type: 'final_answer',
|
|
199
|
+
content: { answer: step.finalAnswer },
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return actions;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* AgentActionからReAct形式のテキストを生成
|
|
207
|
+
*/
|
|
208
|
+
format(actions) {
|
|
209
|
+
const lines = [];
|
|
210
|
+
for (const action of actions) {
|
|
211
|
+
switch (action.type) {
|
|
212
|
+
case 'thought':
|
|
213
|
+
if (action.content.thought) {
|
|
214
|
+
lines.push(`${this.config.thoughtPrefix} ${action.content.thought}`);
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
case 'tool_call':
|
|
218
|
+
if (action.content.tool) {
|
|
219
|
+
lines.push(`${this.config.actionPrefix} ${action.content.tool}`);
|
|
220
|
+
if (action.content.params) {
|
|
221
|
+
const inputStr = Object.keys(action.content.params).length === 1 &&
|
|
222
|
+
'input' in action.content.params
|
|
223
|
+
? String(action.content.params.input)
|
|
224
|
+
: JSON.stringify(action.content.params);
|
|
225
|
+
lines.push(`${this.config.actionInputPrefix} ${inputStr}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
case 'observation':
|
|
230
|
+
if (action.content.result) {
|
|
231
|
+
const obsValue = typeof action.content.result.data === 'string'
|
|
232
|
+
? action.content.result.data
|
|
233
|
+
: JSON.stringify(action.content.result.data);
|
|
234
|
+
lines.push(`${this.config.observationPrefix} ${obsValue}`);
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
case 'final_answer':
|
|
238
|
+
if (action.content.answer) {
|
|
239
|
+
lines.push(`${this.config.finalAnswerPrefix} ${action.content.answer}`);
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return lines.join('\n');
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* ツール呼び出しを抽出(次のアクションを取得)
|
|
248
|
+
*/
|
|
249
|
+
extractNextAction(text) {
|
|
250
|
+
const result = this.parse(text);
|
|
251
|
+
// 最後のアクションを取得
|
|
252
|
+
for (let i = result.actions.length - 1; i >= 0; i--) {
|
|
253
|
+
const action = result.actions[i];
|
|
254
|
+
if (action?.action) {
|
|
255
|
+
return action.action;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* 最終回答かどうかを判定
|
|
262
|
+
*/
|
|
263
|
+
isFinalAnswer(text) {
|
|
264
|
+
return this.matchesPrefix(text.trim(), this.config.finalAnswerPrefix);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 最終回答を抽出
|
|
268
|
+
*/
|
|
269
|
+
extractFinalAnswer(text) {
|
|
270
|
+
const result = this.parse(text);
|
|
271
|
+
return result.finalAnswer ?? null;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* プロンプトにObservationを追加
|
|
275
|
+
*/
|
|
276
|
+
appendObservation(prompt, observation) {
|
|
277
|
+
return `${prompt}\n${this.config.observationPrefix} ${observation}`;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* システムプロンプトを生成
|
|
281
|
+
*/
|
|
282
|
+
generateSystemPrompt(tools) {
|
|
283
|
+
const toolsDescription = tools
|
|
284
|
+
.map((t) => `- ${t.name}: ${t.description}`)
|
|
285
|
+
.join('\n');
|
|
286
|
+
return exports.REACT_SYSTEM_PROMPT.replace('{tools}', toolsDescription);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* プレフィックスマッチ
|
|
290
|
+
*/
|
|
291
|
+
matchesPrefix(text, prefix) {
|
|
292
|
+
if (this.config.caseInsensitive) {
|
|
293
|
+
return text.toLowerCase().startsWith(prefix.toLowerCase());
|
|
294
|
+
}
|
|
295
|
+
return text.startsWith(prefix);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* プレフィックス後の値を抽出
|
|
299
|
+
*/
|
|
300
|
+
extractValue(text, prefix) {
|
|
301
|
+
const prefixLen = prefix.length;
|
|
302
|
+
return text.slice(prefixLen).trim();
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* アクション入力をパース
|
|
306
|
+
*/
|
|
307
|
+
parseActionInput(input) {
|
|
308
|
+
// JSONとしてパースを試みる
|
|
309
|
+
try {
|
|
310
|
+
const parsed = JSON.parse(input);
|
|
311
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
312
|
+
return parsed;
|
|
313
|
+
}
|
|
314
|
+
return input;
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return input;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* 設定を取得
|
|
322
|
+
*/
|
|
323
|
+
getConfig() {
|
|
324
|
+
return { ...this.config };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.ReActHelper = ReActHelper;
|
|
328
|
+
/**
|
|
329
|
+
* シンプルなパースヘルパー
|
|
330
|
+
*/
|
|
331
|
+
function parseReActOutput(text) {
|
|
332
|
+
const helper = new ReActHelper();
|
|
333
|
+
return helper.parse(text);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* シンプルな次アクション抽出ヘルパー
|
|
337
|
+
*/
|
|
338
|
+
function extractNextReActAction(text) {
|
|
339
|
+
const helper = new ReActHelper();
|
|
340
|
+
return helper.extractNextAction(text);
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=ReActHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReActHelper.js","sourceRoot":"","sources":["../../src/agent/ReActHelper.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAubH,4CAGC;AAKD,wDAKC;AA3YD;;GAEG;AACU,QAAA,oBAAoB,GAAgC;IAC/D,aAAa,EAAE,UAAU;IACzB,YAAY,EAAE,SAAS;IACvB,iBAAiB,EAAE,eAAe;IAClC,iBAAiB,EAAE,cAAc;IACjC,iBAAiB,EAAE,eAAe;IAClC,eAAe,EAAE,IAAI;CACtB,CAAC;AAEF;;GAEG;AACU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;CAoBlC,CAAC;AAEF;;GAEG;AACH,MAAa,WAAW;IACd,MAAM,CAA8B;IAE5C,YAAY,SAA4B,EAAE;QACxC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,4BAAoB,EAAE,GAAG,MAAM,EAAE,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAY;QAChB,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAgB,EAAE,CAAC;QAChC,IAAI,WAA+B,CAAC;QAEpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,WAAW,GAAuB,EAAE,CAAC;QACzC,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,aAAa,GAAG,KAAK,CAAC;QAC1B,IAAI,iBAAiB,GAAG,EAAE,CAAC;QAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CA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,KAAa;QACpC,iBAAiB;QACjB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClD,OAAO,MAAiC,CAAC;YAC3C,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AAjVD,kCAiVC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CACpC,IAAY;IAEZ,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent module exports
|
|
3
|
+
*
|
|
4
|
+
* @module @nahisaho/katashiro-orchestrator/agent
|
|
5
|
+
*/
|
|
6
|
+
export type { AgentActionType, ToolResult, AgentAction, AgentState, AgentStateStatus, CreateAgentStateOptions, AddActionInput, SerializedAgentState, AgentStateManagerConfig, } from './types.js';
|
|
7
|
+
export { AgentStateManager, defaultAgentStateManager, type AgentStateSummary, } from './AgentStateManager.js';
|
|
8
|
+
export { ReActHelper, parseReActOutput, extractNextReActAction, DEFAULT_REACT_FORMAT, REACT_SYSTEM_PROMPT, type ReActParseResult, type ReActStep, type ReActFormatConfig, } from './ReActHelper.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent module exports
|
|
4
|
+
*
|
|
5
|
+
* @module @nahisaho/katashiro-orchestrator/agent
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.REACT_SYSTEM_PROMPT = exports.DEFAULT_REACT_FORMAT = exports.extractNextReActAction = exports.parseReActOutput = exports.ReActHelper = exports.defaultAgentStateManager = exports.AgentStateManager = void 0;
|
|
9
|
+
// Classes
|
|
10
|
+
var AgentStateManager_js_1 = require("./AgentStateManager.js");
|
|
11
|
+
Object.defineProperty(exports, "AgentStateManager", { enumerable: true, get: function () { return AgentStateManager_js_1.AgentStateManager; } });
|
|
12
|
+
Object.defineProperty(exports, "defaultAgentStateManager", { enumerable: true, get: function () { return AgentStateManager_js_1.defaultAgentStateManager; } });
|
|
13
|
+
// ReAct Helper (REQ-AGENT-004)
|
|
14
|
+
var ReActHelper_js_1 = require("./ReActHelper.js");
|
|
15
|
+
Object.defineProperty(exports, "ReActHelper", { enumerable: true, get: function () { return ReActHelper_js_1.ReActHelper; } });
|
|
16
|
+
Object.defineProperty(exports, "parseReActOutput", { enumerable: true, get: function () { return ReActHelper_js_1.parseReActOutput; } });
|
|
17
|
+
Object.defineProperty(exports, "extractNextReActAction", { enumerable: true, get: function () { return ReActHelper_js_1.extractNextReActAction; } });
|
|
18
|
+
Object.defineProperty(exports, "DEFAULT_REACT_FORMAT", { enumerable: true, get: function () { return ReActHelper_js_1.DEFAULT_REACT_FORMAT; } });
|
|
19
|
+
Object.defineProperty(exports, "REACT_SYSTEM_PROMPT", { enumerable: true, get: function () { return ReActHelper_js_1.REACT_SYSTEM_PROMPT; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAeH,UAAU;AACV,+DAIgC;AAH9B,yHAAA,iBAAiB,OAAA;AACjB,gIAAA,wBAAwB,OAAA;AAG1B,+BAA+B;AAC/B,mDAS0B;AARxB,6GAAA,WAAW,OAAA;AACX,kHAAA,gBAAgB,OAAA;AAChB,wHAAA,sBAAsB,OAAA;AACtB,sHAAA,oBAAoB,OAAA;AACpB,qHAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Types - エージェント状態管理の型定義
|
|
3
|
+
*
|
|
4
|
+
* @requirement REQ-AGENT-002
|
|
5
|
+
* @description エージェントの状態管理のための型定義
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* エージェントアクションの種類
|
|
9
|
+
*/
|
|
10
|
+
export type AgentActionType = 'tool_call' | 'thought' | 'observation' | 'final_answer';
|
|
11
|
+
/**
|
|
12
|
+
* ツール実行結果
|
|
13
|
+
*/
|
|
14
|
+
export interface ToolResult {
|
|
15
|
+
/** ツール名 */
|
|
16
|
+
toolName: string;
|
|
17
|
+
/** 成功したか */
|
|
18
|
+
success: boolean;
|
|
19
|
+
/** 結果データ */
|
|
20
|
+
data?: unknown;
|
|
21
|
+
/** エラーメッセージ */
|
|
22
|
+
error?: string;
|
|
23
|
+
/** 実行時間(ミリ秒) */
|
|
24
|
+
executionTimeMs?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* エージェントアクション
|
|
28
|
+
*/
|
|
29
|
+
export interface AgentAction {
|
|
30
|
+
/** ステップ番号 */
|
|
31
|
+
step: number;
|
|
32
|
+
/** タイムスタンプ */
|
|
33
|
+
timestamp: string;
|
|
34
|
+
/** アクション種類 */
|
|
35
|
+
type: AgentActionType;
|
|
36
|
+
/** アクション内容 */
|
|
37
|
+
content: {
|
|
38
|
+
/** ツール名(type=tool_callの場合) */
|
|
39
|
+
tool?: string;
|
|
40
|
+
/** パラメータ(type=tool_callの場合) */
|
|
41
|
+
params?: Record<string, unknown>;
|
|
42
|
+
/** ツール実行結果(type=observationの場合) */
|
|
43
|
+
result?: ToolResult;
|
|
44
|
+
/** 思考内容(type=thoughtの場合) */
|
|
45
|
+
thought?: string;
|
|
46
|
+
/** 最終回答(type=final_answerの場合) */
|
|
47
|
+
answer?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* エージェント状態
|
|
52
|
+
*/
|
|
53
|
+
export interface AgentState {
|
|
54
|
+
/** 会話ID */
|
|
55
|
+
conversationId: string;
|
|
56
|
+
/** 現在のステップ */
|
|
57
|
+
currentStep: number;
|
|
58
|
+
/** 最大ステップ */
|
|
59
|
+
maxSteps: number;
|
|
60
|
+
/** 実行履歴 */
|
|
61
|
+
history: AgentAction[];
|
|
62
|
+
/** コンテキスト(任意のデータ) */
|
|
63
|
+
context: Record<string, unknown>;
|
|
64
|
+
/** 中間結果 */
|
|
65
|
+
intermediateResults: unknown[];
|
|
66
|
+
/** 作成日時 */
|
|
67
|
+
createdAt: string;
|
|
68
|
+
/** 更新日時 */
|
|
69
|
+
updatedAt: string;
|
|
70
|
+
/** 状態 */
|
|
71
|
+
status: AgentStateStatus;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* エージェント状態のステータス
|
|
75
|
+
*/
|
|
76
|
+
export type AgentStateStatus = 'idle' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
77
|
+
/**
|
|
78
|
+
* エージェント状態作成オプション
|
|
79
|
+
*/
|
|
80
|
+
export interface CreateAgentStateOptions {
|
|
81
|
+
/** 会話ID(未指定時は自動生成) */
|
|
82
|
+
conversationId?: string;
|
|
83
|
+
/** 最大ステップ */
|
|
84
|
+
maxSteps?: number;
|
|
85
|
+
/** 初期コンテキスト */
|
|
86
|
+
context?: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* アクション追加オプション
|
|
90
|
+
*/
|
|
91
|
+
export type AddActionInput = Omit<AgentAction, 'step' | 'timestamp'>;
|
|
92
|
+
/**
|
|
93
|
+
* シリアライズされた状態
|
|
94
|
+
*/
|
|
95
|
+
export interface SerializedAgentState {
|
|
96
|
+
version: string;
|
|
97
|
+
data: AgentState;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* エージェント状態マネージャー設定
|
|
101
|
+
*/
|
|
102
|
+
export interface AgentStateManagerConfig {
|
|
103
|
+
/** デフォルト最大ステップ */
|
|
104
|
+
defaultMaxSteps?: number;
|
|
105
|
+
/** ID生成関数 */
|
|
106
|
+
idGenerator?: () => string;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,cAAc,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY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AAC;AAEzF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,kBAAkB;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KATASHIRO v1.4.0 - Cascading Agent
|
|
3
|
+
*
|
|
4
|
+
* カスケード型リサーチのエージェント
|
|
5
|
+
* 各エージェントは特定の役割(official/news/analysis/academic/community)を持ち、
|
|
6
|
+
* 前ステップの結果を参照しながら調査を実行する
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentRole, CascadingAgentReport, CascadingAgentStrategy, StepContext } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* 依存性注入用インターフェース: 検索クライアント
|
|
11
|
+
*/
|
|
12
|
+
export interface ISearchClient {
|
|
13
|
+
search(query: string, options?: {
|
|
14
|
+
maxResults?: number;
|
|
15
|
+
}): Promise<Array<{
|
|
16
|
+
url: string;
|
|
17
|
+
title: string;
|
|
18
|
+
snippet?: string;
|
|
19
|
+
}>>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 依存性注入用インターフェース: Webスクレイパー
|
|
23
|
+
*/
|
|
24
|
+
export interface IScraper {
|
|
25
|
+
scrape(url: string): Promise<{
|
|
26
|
+
ok: true;
|
|
27
|
+
value: {
|
|
28
|
+
content: string;
|
|
29
|
+
title: string;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
error: Error;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 依存性注入用インターフェース: テキスト分析
|
|
38
|
+
*/
|
|
39
|
+
export interface ITextAnalyzer {
|
|
40
|
+
analyze(text: string): Promise<{
|
|
41
|
+
keywords: string[];
|
|
42
|
+
sentiment?: string;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 依存性注入用インターフェース: エンティティ抽出
|
|
47
|
+
*/
|
|
48
|
+
export interface IEntityExtractor {
|
|
49
|
+
extract(text: string): Promise<{
|
|
50
|
+
persons: string[];
|
|
51
|
+
organizations: string[];
|
|
52
|
+
all: Array<{
|
|
53
|
+
text: string;
|
|
54
|
+
type: string;
|
|
55
|
+
}>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* CascadingAgentの依存性
|
|
60
|
+
*/
|
|
61
|
+
export interface CascadingAgentDependencies {
|
|
62
|
+
searchClient: ISearchClient;
|
|
63
|
+
scraper: IScraper;
|
|
64
|
+
textAnalyzer?: ITextAnalyzer;
|
|
65
|
+
entityExtractor?: IEntityExtractor;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* CascadingAgentの設定
|
|
69
|
+
*/
|
|
70
|
+
export interface CascadingAgentConfig {
|
|
71
|
+
/** エージェントID */
|
|
72
|
+
id: string;
|
|
73
|
+
/** エージェントの役割 */
|
|
74
|
+
role: AgentRole;
|
|
75
|
+
/** エージェント戦略 */
|
|
76
|
+
strategy: CascadingAgentStrategy;
|
|
77
|
+
/** タイムアウト (ms) */
|
|
78
|
+
timeoutMs: number;
|
|
79
|
+
/** 最大リトライ回数 */
|
|
80
|
+
maxRetries: number;
|
|
81
|
+
/** 最大検索結果数 */
|
|
82
|
+
maxResults: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* カスケードエージェント
|
|
86
|
+
*/
|
|
87
|
+
export declare class CascadingAgent {
|
|
88
|
+
private readonly config;
|
|
89
|
+
private readonly deps;
|
|
90
|
+
constructor(config: CascadingAgentConfig, deps: CascadingAgentDependencies);
|
|
91
|
+
/**
|
|
92
|
+
* エージェントIDを取得
|
|
93
|
+
*/
|
|
94
|
+
get id(): string;
|
|
95
|
+
/**
|
|
96
|
+
* エージェントの役割を取得
|
|
97
|
+
*/
|
|
98
|
+
get role(): AgentRole;
|
|
99
|
+
/**
|
|
100
|
+
* リサーチを実行
|
|
101
|
+
*/
|
|
102
|
+
research(context: StepContext): Promise<CascadingAgentReport>;
|
|
103
|
+
/**
|
|
104
|
+
* 検索クエリを構築
|
|
105
|
+
*/
|
|
106
|
+
private buildQuery;
|
|
107
|
+
/**
|
|
108
|
+
* 検索を実行
|
|
109
|
+
*/
|
|
110
|
+
private executeSearch;
|
|
111
|
+
/**
|
|
112
|
+
* コンテンツをスクレイピング
|
|
113
|
+
*/
|
|
114
|
+
private scrapeContents;
|
|
115
|
+
/**
|
|
116
|
+
* URLから信頼度を推定
|
|
117
|
+
*/
|
|
118
|
+
private estimateCredibility;
|
|
119
|
+
/**
|
|
120
|
+
* 発見事項を抽出
|
|
121
|
+
*/
|
|
122
|
+
private extractFindings;
|
|
123
|
+
/**
|
|
124
|
+
* コンテンツから発見事項を抽出
|
|
125
|
+
*/
|
|
126
|
+
private extractFindingsFromContent;
|
|
127
|
+
/**
|
|
128
|
+
* コンテンツがトピックに関連しているか判定
|
|
129
|
+
*/
|
|
130
|
+
private isRelevant;
|
|
131
|
+
/**
|
|
132
|
+
* コンテンツをカテゴリ分類
|
|
133
|
+
*/
|
|
134
|
+
private categorizeContent;
|
|
135
|
+
/**
|
|
136
|
+
* URLからドメインを抽出
|
|
137
|
+
*/
|
|
138
|
+
private extractDomain;
|
|
139
|
+
/**
|
|
140
|
+
* ギャップを分析
|
|
141
|
+
*/
|
|
142
|
+
private analyzeGaps;
|
|
143
|
+
/**
|
|
144
|
+
* レポートを生成
|
|
145
|
+
*/
|
|
146
|
+
private generateReport;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* エージェントファクトリー
|
|
150
|
+
*/
|
|
151
|
+
export declare function createCascadingAgents(strategies: CascadingAgentStrategy[], deps: CascadingAgentDependencies, options: {
|
|
152
|
+
timeoutMs: number;
|
|
153
|
+
maxRetries: number;
|
|
154
|
+
maxResults: number;
|
|
155
|
+
}): CascadingAgent[];
|
|
156
|
+
//# sourceMappingURL=CascadingAgent.d.ts.map
|