agentic-api 2.0.314 → 2.0.585
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 +37 -34
- package/dist/src/agents/prompts.d.ts +1 -1
- package/dist/src/agents/prompts.js +9 -7
- package/dist/src/agents/reducer.core.js +2 -2
- package/dist/src/agents/simulator.d.ts +33 -4
- package/dist/src/agents/simulator.dashboard.d.ts +140 -0
- package/dist/src/agents/simulator.dashboard.js +344 -0
- package/dist/src/agents/simulator.executor.d.ts +9 -3
- package/dist/src/agents/simulator.executor.js +43 -17
- package/dist/src/agents/simulator.js +103 -19
- package/dist/src/agents/simulator.prompts.d.ts +9 -8
- package/dist/src/agents/simulator.prompts.js +68 -62
- package/dist/src/agents/simulator.types.d.ts +39 -4
- package/dist/src/agents/simulator.utils.d.ts +22 -1
- package/dist/src/agents/simulator.utils.js +27 -2
- package/dist/src/execute/helpers.d.ts +75 -0
- package/dist/src/execute/helpers.js +139 -0
- package/dist/src/execute/index.d.ts +11 -0
- package/dist/src/execute/index.js +44 -0
- package/dist/src/execute/legacy.d.ts +46 -0
- package/dist/src/{execute.js → execute/legacy.js} +130 -232
- package/dist/src/execute/modelconfig.d.ts +29 -0
- package/dist/src/execute/modelconfig.js +72 -0
- package/dist/src/execute/responses.d.ts +55 -0
- package/dist/src/execute/responses.js +595 -0
- package/dist/src/execute/shared.d.ts +83 -0
- package/dist/src/execute/shared.js +188 -0
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.js +21 -2
- package/dist/src/llm/config.d.ts +25 -0
- package/dist/src/llm/config.js +38 -0
- package/dist/src/llm/index.d.ts +48 -0
- package/dist/src/llm/index.js +115 -0
- package/dist/src/llm/openai.d.ts +6 -0
- package/dist/src/llm/openai.js +154 -0
- package/dist/src/llm/pricing.d.ts +26 -0
- package/dist/src/llm/pricing.js +129 -0
- package/dist/src/llm/xai.d.ts +17 -0
- package/dist/src/llm/xai.js +90 -0
- package/dist/src/pricing.llm.d.ts +3 -15
- package/dist/src/pricing.llm.js +10 -230
- package/dist/src/prompts.d.ts +0 -1
- package/dist/src/prompts.js +51 -118
- package/dist/src/rag/embeddings.d.ts +5 -1
- package/dist/src/rag/embeddings.js +23 -7
- package/dist/src/rag/parser.js +1 -1
- package/dist/src/rag/rag.manager.d.ts +33 -2
- package/dist/src/rag/rag.manager.js +159 -61
- package/dist/src/rag/types.d.ts +2 -0
- package/dist/src/rag/usecase.js +8 -11
- package/dist/src/rules/git/git.e2e.helper.js +21 -2
- package/dist/src/rules/git/git.health.d.ts +4 -2
- package/dist/src/rules/git/git.health.js +113 -16
- package/dist/src/rules/git/index.d.ts +1 -1
- package/dist/src/rules/git/index.js +3 -2
- package/dist/src/rules/git/repo.d.ts +57 -7
- package/dist/src/rules/git/repo.js +326 -39
- package/dist/src/rules/git/repo.pr.d.ts +8 -0
- package/dist/src/rules/git/repo.pr.js +161 -13
- package/dist/src/rules/git/repo.tools.d.ts +5 -1
- package/dist/src/rules/git/repo.tools.js +54 -7
- package/dist/src/rules/types.d.ts +25 -0
- package/dist/src/rules/utils.matter.d.ts +0 -20
- package/dist/src/rules/utils.matter.js +58 -81
- package/dist/src/scrapper.js +3 -2
- package/dist/src/stategraph/stategraph.d.ts +26 -1
- package/dist/src/stategraph/stategraph.js +43 -2
- package/dist/src/stategraph/stategraph.storage.js +4 -0
- package/dist/src/stategraph/types.d.ts +5 -0
- package/dist/src/types.d.ts +42 -7
- package/dist/src/types.js +8 -7
- package/dist/src/usecase.js +1 -1
- package/dist/src/utils.d.ts +0 -8
- package/dist/src/utils.js +26 -29
- package/package.json +9 -7
- package/dist/src/execute.d.ts +0 -63
|
@@ -41,6 +41,14 @@ class AgentStateGraph {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Ajoute un message à la discussion d'un agent
|
|
44
|
+
* Gère tous types de messages : user, assistant, system, tool, function_call_output, etc.
|
|
45
|
+
*
|
|
46
|
+
* Utilisée par:
|
|
47
|
+
* - readCompletionsStream (responses.ts) : messages assistant avec tool_calls, content
|
|
48
|
+
* - batchProcessToolCalls (helpers.ts) : messages function_call_output
|
|
49
|
+
* - executeAgentSet (responses.ts) : messages user
|
|
50
|
+
* - stategraph.storage.ts : migration ancien format
|
|
51
|
+
*
|
|
44
52
|
* @param agentName Nom de l'agent
|
|
45
53
|
* @param message Message sans ID ni timestamp (auto-générés)
|
|
46
54
|
*/
|
|
@@ -83,8 +91,14 @@ class AgentStateGraph {
|
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* Ajoute une étape au CONTEXT TRAIL et met à jour le message system
|
|
94
|
+
* Injecte automatiquement le trail dans le system message via updateSystemMessage()
|
|
95
|
+
*
|
|
96
|
+
* Utilisée par:
|
|
97
|
+
* - readCompletionsStream (responses.ts) : après chaque tool call exécuté
|
|
98
|
+
* - Tests d'intégration pour validation du context trail
|
|
99
|
+
*
|
|
86
100
|
* @param agentName Nom de l'agent
|
|
87
|
-
* @param step Étape à ajouter au trail
|
|
101
|
+
* @param step Étape à ajouter au trail (tool, context, reason, id optionnel)
|
|
88
102
|
*/
|
|
89
103
|
addStep(agentName, step) {
|
|
90
104
|
const discussion = this.discussions.find(d => d.startAgent === agentName);
|
|
@@ -158,6 +172,17 @@ class AgentStateGraph {
|
|
|
158
172
|
/**
|
|
159
173
|
* Retourne une vue filtrée pour le client
|
|
160
174
|
* Supprime les messages system et les métadonnées d'outils
|
|
175
|
+
*
|
|
176
|
+
* Filtre appliqué:
|
|
177
|
+
* - Exclut: system, tool, messages avec name (Chat Completions function results)
|
|
178
|
+
* - Exclut: function_call_output (Responses API)
|
|
179
|
+
* - Exclut: messages assistant avec tool_calls mais sans content
|
|
180
|
+
* - Nettoie: <memories> tags dans le content
|
|
181
|
+
*
|
|
182
|
+
* Utilisée par:
|
|
183
|
+
* - ctrl/agent.ts (agentic-server) : ctrlGetHistory, ctrlExecuteAgent
|
|
184
|
+
* - Tests d'intégration pour validation
|
|
185
|
+
*
|
|
161
186
|
* @param agentName Nom de l'agent
|
|
162
187
|
* @returns Discussion filtrée pour l'affichage client
|
|
163
188
|
*/
|
|
@@ -170,8 +195,23 @@ class AgentStateGraph {
|
|
|
170
195
|
return content;
|
|
171
196
|
};
|
|
172
197
|
// Filtrer les messages pour le client - exclure system, tool et messages avec name
|
|
198
|
+
// ✅ Exclure aussi les messages Responses API (type: "function_call_output") et tool_calls sans content
|
|
173
199
|
const clientMessages = discussion.messages
|
|
174
|
-
.filter(msg =>
|
|
200
|
+
.filter((msg) => {
|
|
201
|
+
// Exclure system et tool
|
|
202
|
+
if (msg.role === 'system' || msg.role === 'tool')
|
|
203
|
+
return false;
|
|
204
|
+
// Exclure messages avec name (Chat Completions function results)
|
|
205
|
+
if (msg.name)
|
|
206
|
+
return false;
|
|
207
|
+
// Exclure messages Responses API: function_call_output
|
|
208
|
+
if (msg.type === 'function_call_output')
|
|
209
|
+
return false;
|
|
210
|
+
// Exclure messages assistant avec tool_calls mais sans content (métadonnées de tools)
|
|
211
|
+
if (msg.tool_calls && msg.tool_calls.length > 0 && !msg.content)
|
|
212
|
+
return false;
|
|
213
|
+
return true;
|
|
214
|
+
})
|
|
175
215
|
.map(msg => ({
|
|
176
216
|
id: msg.id,
|
|
177
217
|
role: msg.role,
|
|
@@ -184,6 +224,7 @@ class AgentStateGraph {
|
|
|
184
224
|
description: discussion.description,
|
|
185
225
|
agent: agentName,
|
|
186
226
|
messages: clientMessages,
|
|
227
|
+
steps: [...discussion.trailSteps],
|
|
187
228
|
usage: discussion.usage,
|
|
188
229
|
createdAt: discussion.createdAt,
|
|
189
230
|
updatedAt: discussion.updatedAt
|
|
@@ -22,6 +22,10 @@ const SESSION_STATEGRAPH_KEY = 'agentStateGraph';
|
|
|
22
22
|
* @returns StateGraph existant ou nouveau
|
|
23
23
|
*/
|
|
24
24
|
function sessionStateGraphGet(context) {
|
|
25
|
+
// ✅ Si un stateGraph est passé directement dans le contexte (mode sans session)
|
|
26
|
+
if (context.stateGraph && context.stateGraph instanceof stategraph_1.AgentStateGraph) {
|
|
27
|
+
return context.stateGraph;
|
|
28
|
+
}
|
|
25
29
|
const session = context.session;
|
|
26
30
|
if (!session) {
|
|
27
31
|
// Pour les tests, retourner un nouveau StateGraph si pas de session
|
|
@@ -19,6 +19,9 @@ export interface AgentMessage {
|
|
|
19
19
|
agent?: string;
|
|
20
20
|
/** Timestamp de création */
|
|
21
21
|
timestamp: Date;
|
|
22
|
+
type?: string;
|
|
23
|
+
tool_call_id?: string;
|
|
24
|
+
output?: string;
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* Usage des tokens et coût
|
|
@@ -146,6 +149,8 @@ export interface ClientDiscussion {
|
|
|
146
149
|
content: string;
|
|
147
150
|
timestamp: Date;
|
|
148
151
|
}>;
|
|
152
|
+
/** Context trail steps (actions effectuées) */
|
|
153
|
+
steps: StepTrail[];
|
|
149
154
|
/** Usage des tokens */
|
|
150
155
|
usage: TokenUsage;
|
|
151
156
|
/** Dates */
|
package/dist/src/types.d.ts
CHANGED
|
@@ -9,12 +9,20 @@ export interface ToolParameterProperty {
|
|
|
9
9
|
required?: string[];
|
|
10
10
|
additionalProperties?: boolean;
|
|
11
11
|
items?: ToolParameterProperty;
|
|
12
|
+
minLength?: number;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
format?: string;
|
|
15
|
+
minimum?: number;
|
|
16
|
+
maximum?: number;
|
|
17
|
+
default?: any;
|
|
18
|
+
[key: string]: any;
|
|
12
19
|
}
|
|
13
20
|
export interface ToolParameters {
|
|
14
21
|
type: string;
|
|
15
22
|
properties: Record<string, ToolParameterProperty>;
|
|
16
23
|
required?: string[];
|
|
17
24
|
additionalProperties?: boolean;
|
|
25
|
+
[key: string]: any;
|
|
18
26
|
}
|
|
19
27
|
export interface Tool {
|
|
20
28
|
type: "function";
|
|
@@ -25,6 +33,17 @@ export interface Tool {
|
|
|
25
33
|
strict: boolean;
|
|
26
34
|
};
|
|
27
35
|
}
|
|
36
|
+
export type ToolContractOutput<T> = {
|
|
37
|
+
status: "ok" | "success" | "empty" | "error" | "transfer_required" | "multiple_results";
|
|
38
|
+
items?: T[];
|
|
39
|
+
meta?: Record<string, any>;
|
|
40
|
+
control?: {
|
|
41
|
+
next_hint?: string;
|
|
42
|
+
can_retry: boolean;
|
|
43
|
+
error_code?: string;
|
|
44
|
+
transfer_message?: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
28
47
|
export interface AgentModelMapping {
|
|
29
48
|
[key: string]: string;
|
|
30
49
|
}
|
|
@@ -35,16 +54,30 @@ export interface AgentModel {
|
|
|
35
54
|
topP?: number;
|
|
36
55
|
stream?: boolean;
|
|
37
56
|
parallel_tool_calls: boolean;
|
|
38
|
-
frequencyPenalty?: number;
|
|
39
|
-
presencePenalty?: number;
|
|
40
57
|
stop?: string[] | string;
|
|
41
58
|
tool_choice?: "auto" | "none" | "required";
|
|
42
59
|
/**
|
|
43
60
|
* Timeout in milliseconds for a query.
|
|
44
|
-
* If not specified, the default
|
|
61
|
+
* If not specified, the default (10 minutes).
|
|
45
62
|
* https://platform.openai.com/docs/guides/flex-processing#api-request-timeouts
|
|
46
63
|
*/
|
|
47
64
|
timeout?: number;
|
|
65
|
+
verbosity?: string;
|
|
66
|
+
reasoning_effort?: string;
|
|
67
|
+
frequencyPenalty?: number;
|
|
68
|
+
presencePenalty?: number;
|
|
69
|
+
text?: {
|
|
70
|
+
verbosity?: string;
|
|
71
|
+
format?: {
|
|
72
|
+
type: string;
|
|
73
|
+
name?: string;
|
|
74
|
+
schema?: any;
|
|
75
|
+
strict?: boolean;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
reasoning?: {
|
|
79
|
+
effort: string;
|
|
80
|
+
};
|
|
48
81
|
}
|
|
49
82
|
export interface AgentConfig {
|
|
50
83
|
name: string;
|
|
@@ -85,6 +118,7 @@ export interface AgenticContext {
|
|
|
85
118
|
session: any;
|
|
86
119
|
[key: string]: any;
|
|
87
120
|
currentAgent?: AgentConfig;
|
|
121
|
+
discussionRootAgent?: string;
|
|
88
122
|
}
|
|
89
123
|
export type AllAgentConfigsType = Record<string, AgentConfig[]>;
|
|
90
124
|
export interface Usage {
|
|
@@ -130,7 +164,8 @@ export interface ExecutionAction {
|
|
|
130
164
|
* - `lastMessage`: The final assistant message content after execution.
|
|
131
165
|
* - `usage`: Token usage/cost snapshot for the whole execution.
|
|
132
166
|
* - `error`: Optional error message if something went wrong (non-fatal).
|
|
133
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* NOTE: `moreThinkin` was removed (obsolete) - reasoning_effort in modelConfig handles this natively
|
|
134
169
|
*/
|
|
135
170
|
export interface ExecutionResult {
|
|
136
171
|
runId: string;
|
|
@@ -140,7 +175,6 @@ export interface ExecutionResult {
|
|
|
140
175
|
lastMessage: string;
|
|
141
176
|
usage: Usage;
|
|
142
177
|
error?: string;
|
|
143
|
-
moreThinkin: boolean;
|
|
144
178
|
/**
|
|
145
179
|
* Human-readable summary formatter. Optional to preserve backward compatibility.
|
|
146
180
|
*/
|
|
@@ -152,10 +186,11 @@ export interface ExecutionResult {
|
|
|
152
186
|
* Merge strategy:
|
|
153
187
|
* - `runId`: preserved from the primary accumulator `a`.
|
|
154
188
|
* - `actions`: appended in order (a.actions then b.actions).
|
|
155
|
-
* - `lastMessage`:
|
|
189
|
+
* - `lastMessage`: prioritize more recent (b) over older (a).
|
|
156
190
|
* - `usage`: summed field-by-field to accumulate totals across steps.
|
|
157
191
|
* - `error`: keep the latest non-undefined error (prefer `b`).
|
|
158
|
-
*
|
|
192
|
+
*
|
|
193
|
+
* NOTE: moreThinkin removed (obsolete) - always returns false
|
|
159
194
|
*/
|
|
160
195
|
export declare function enrichExecutionResult(result: ExecutionResult): ExecutionResult;
|
|
161
196
|
export declare function executionResultMerge(a: ExecutionResult, b: ExecutionResult): ExecutionResult;
|
package/dist/src/types.js
CHANGED
|
@@ -8,10 +8,11 @@ exports.executionResultMerge = executionResultMerge;
|
|
|
8
8
|
* Merge strategy:
|
|
9
9
|
* - `runId`: preserved from the primary accumulator `a`.
|
|
10
10
|
* - `actions`: appended in order (a.actions then b.actions).
|
|
11
|
-
* - `lastMessage`:
|
|
11
|
+
* - `lastMessage`: prioritize more recent (b) over older (a).
|
|
12
12
|
* - `usage`: summed field-by-field to accumulate totals across steps.
|
|
13
13
|
* - `error`: keep the latest non-undefined error (prefer `b`).
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* NOTE: moreThinkin removed (obsolete) - always returns false
|
|
15
16
|
*/
|
|
16
17
|
function enrichExecutionResult(result) {
|
|
17
18
|
const formatAction = (action, index) => {
|
|
@@ -29,7 +30,7 @@ function enrichExecutionResult(result) {
|
|
|
29
30
|
if (result.error) {
|
|
30
31
|
lines.push(`error: ${result.error}`);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
// moreThinkin removed (obsolete) - reasoning_effort fait le job
|
|
33
34
|
const actions = result.actions || [];
|
|
34
35
|
lines.push(`actions (${actions.length}):`);
|
|
35
36
|
actions.forEach((a, i) => lines.push(` - ${formatAction(a, i)}`));
|
|
@@ -42,16 +43,16 @@ function executionResultMerge(a, b) {
|
|
|
42
43
|
const merged = {
|
|
43
44
|
runId: a.runId && a.runId.length > 0 ? a.runId : b.runId,
|
|
44
45
|
startQuery: a.startQuery || b.startQuery || '',
|
|
45
|
-
actions: [],
|
|
46
|
-
lastMessage: a.lastMessage || '',
|
|
46
|
+
actions: [...(a.actions || []), ...(b.actions || [])], // ✅ BUG FIX: Fusionner les actions
|
|
47
|
+
lastMessage: b.lastMessage || a.lastMessage || '', // ✅ BUG FIX: Prioriser le plus récent (b)
|
|
47
48
|
usage: {
|
|
48
49
|
prompt: (a.usage?.prompt || 0) + (b.usage?.prompt || 0),
|
|
49
50
|
completion: (a.usage?.completion || 0) + (b.usage?.completion || 0),
|
|
50
51
|
total: (a.usage?.total || 0) + (b.usage?.total || 0),
|
|
51
52
|
cost: (a.usage?.cost || 0) + (b.usage?.cost || 0),
|
|
52
53
|
},
|
|
53
|
-
error: b.error ?? a.error
|
|
54
|
-
moreThinkin
|
|
54
|
+
error: b.error ?? a.error
|
|
55
|
+
// moreThinkin removed (obsolete) - reasoning_effort fait le job
|
|
55
56
|
};
|
|
56
57
|
return enrichExecutionResult(merged);
|
|
57
58
|
}
|
package/dist/src/usecase.js
CHANGED
|
@@ -24,7 +24,7 @@ async function llmExtractUserQueries(inputsection, file, options = { model: "LOW
|
|
|
24
24
|
// response_format: { type: "json_object" }
|
|
25
25
|
const result = await (0, execute_1.executeQuery)({
|
|
26
26
|
query,
|
|
27
|
-
|
|
27
|
+
model: options.model,
|
|
28
28
|
stdout: execute_1.DummyWritable,
|
|
29
29
|
verbose: false,
|
|
30
30
|
json: true
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { ParsedFunctionToolCall } from "openai/resources/beta/chat/completions";
|
|
2
2
|
import { AgentConfig, AgenticContext } from "./types";
|
|
3
|
-
import OpenAI from "openai";
|
|
4
|
-
/**
|
|
5
|
-
* global openai instance
|
|
6
|
-
*/
|
|
7
|
-
declare global {
|
|
8
|
-
var _openaiInstance_: OpenAI | undefined;
|
|
9
|
-
}
|
|
10
|
-
export declare const openaiInstance: (envKey?: string, baseUrl?: string) => OpenAI;
|
|
11
3
|
/**
|
|
12
4
|
* Converts a string to a URL-friendly slug
|
|
13
5
|
* @param text The text to convert to a slug
|
package/dist/src/utils.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.toSlug =
|
|
3
|
+
exports.toSlug = void 0;
|
|
7
4
|
exports.injectTransferTools = injectTransferTools;
|
|
8
5
|
exports.handleTransferCall = handleTransferCall;
|
|
9
6
|
const prompts_1 = require("./prompts");
|
|
10
|
-
const openai_1 = __importDefault(require("openai"));
|
|
11
|
-
const openaiInstance = function (envKey, baseUrl) {
|
|
12
|
-
if (globalThis._openaiInstance_) {
|
|
13
|
-
return globalThis._openaiInstance_;
|
|
14
|
-
}
|
|
15
|
-
if (!envKey) {
|
|
16
|
-
throw new Error('AI API key is missing');
|
|
17
|
-
}
|
|
18
|
-
const options = {
|
|
19
|
-
apiKey: process.env[envKey],
|
|
20
|
-
timeout: 60000 * 15
|
|
21
|
-
};
|
|
22
|
-
if (baseUrl) {
|
|
23
|
-
options.baseURL = baseUrl;
|
|
24
|
-
}
|
|
25
|
-
globalThis._openaiInstance_ = new openai_1.default(options);
|
|
26
|
-
if (!globalThis._openaiInstance_) {
|
|
27
|
-
throw new Error('OpenAI instance has not been initialized');
|
|
28
|
-
}
|
|
29
|
-
return globalThis._openaiInstance_;
|
|
30
|
-
};
|
|
31
|
-
exports.openaiInstance = openaiInstance;
|
|
32
7
|
/**
|
|
33
8
|
* Converts a string to a URL-friendly slug
|
|
34
9
|
* @param text The text to convert to a slug
|
|
@@ -152,6 +127,14 @@ ${availableAgentsList}
|
|
|
152
127
|
//
|
|
153
128
|
// Fonction pour gérer un appel de fonction retourné par OpenAI
|
|
154
129
|
// le contexte est un objet qui contient des informations supplémentaires de session
|
|
130
|
+
//
|
|
131
|
+
// TODO [Phase 2 - openai-agents-js]:
|
|
132
|
+
// Cette logique de handleTransferCall sera remplacée par le handoff natif
|
|
133
|
+
// de openai-agents-js (https://openai.github.io/openai-agents-js/)
|
|
134
|
+
// qui gère les transferts via policies et router intégrés.
|
|
135
|
+
// Les concepts de downstreamAgents et confidence seront mappés
|
|
136
|
+
// vers les primitives de l'Agent SDK (swarm.run, handoff strategies).
|
|
137
|
+
// Le stateGraph restera compatible car il utilise AgentMessage générique.
|
|
155
138
|
async function handleTransferCall(discussion, currentAgentRef, agents, functionCallParams, context) {
|
|
156
139
|
const currentAgentName = currentAgentRef.name;
|
|
157
140
|
const args = JSON.parse(functionCallParams?.function?.arguments || '{}');
|
|
@@ -199,6 +182,7 @@ async function handleTransferCall(discussion, currentAgentRef, agents, functionC
|
|
|
199
182
|
return {
|
|
200
183
|
feedback: `❌ L'agent destination "${destinationAgentName}" n'a pas été trouvé.`,
|
|
201
184
|
content: `❌L'agent destination "${destinationAgentName}" n'a pas été trouvé.`,
|
|
185
|
+
context: `❌L'agent destination "${destinationAgentName}" n'a pas été trouvé.`,
|
|
202
186
|
did_transfer: false,
|
|
203
187
|
name: functionCallParams.function.name
|
|
204
188
|
};
|
|
@@ -219,11 +203,24 @@ async function handleTransferCall(discussion, currentAgentRef, agents, functionC
|
|
|
219
203
|
// ⚠️ ALWAYS inject context in tool logic, ALWAYS!
|
|
220
204
|
const agent = agents.find(a => a.name === currentAgentRef.name);
|
|
221
205
|
if (agent?.toolLogic && agent.toolLogic[functionCallParams.function.name]) {
|
|
222
|
-
const
|
|
206
|
+
const rawResult = await agent.toolLogic[functionCallParams.function.name](args, context);
|
|
207
|
+
//
|
|
208
|
+
// ✅ Le tool peut retourner { content, context, id, usage? } OU ToolContractOutput
|
|
209
|
+
// - Si content existe → utiliser le texte formaté
|
|
210
|
+
// - Sinon → préserver rawResult pour sérialisation (ToolContractOutput)
|
|
211
|
+
// - context: identifiant sémantique unique pour le trail (ex: "intention_123", "daily-events")
|
|
212
|
+
// - id: slug unique pour détection de boucles (généralement dérivé du context)
|
|
213
|
+
// Si le tool ne fournit pas context/id, on utilise le nom du tool comme fallback
|
|
214
|
+
const toolContext = rawResult.context || 'Null';
|
|
215
|
+
const toolId = rawResult.id || args.justification || JSON.stringify(args);
|
|
223
216
|
return {
|
|
224
|
-
content,
|
|
217
|
+
content: rawResult.content, // ✅ Peut être undefined pour ToolContractOutput
|
|
225
218
|
name: functionCallParams.function.name,
|
|
226
|
-
|
|
219
|
+
context: toolContext,
|
|
220
|
+
id: toolId,
|
|
221
|
+
usage: rawResult.usage,
|
|
222
|
+
feedback: rawResult.feedback,
|
|
223
|
+
rawResult: rawResult // ✅ Préserver le résultat brut pour sérialisation
|
|
227
224
|
};
|
|
228
225
|
}
|
|
229
226
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.585",
|
|
4
4
|
"description": "API pour l'orchestration d'agents intelligents avec séquences et escalades automatiques",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prebuild": "npm version patch --no-git-tag-version",
|
|
12
12
|
"build": "tsc",
|
|
13
|
-
"test": "jest --
|
|
14
|
-
"test:quiet": "jest --
|
|
15
|
-
"test:verbose": "jest --
|
|
16
|
-
"test:simulator": "jest --
|
|
17
|
-
"test:simulator:quiet": "jest --
|
|
13
|
+
"test": "jest --silent",
|
|
14
|
+
"test:quiet": "jest --testPathIgnorePatterns=agent* --silent tests",
|
|
15
|
+
"test:verbose": "jest --testPathIgnorePatterns=agent* --verbose tests",
|
|
16
|
+
"test:simulator": "jest --testNamePattern=simulator.* --silent tests",
|
|
17
|
+
"test:simulator:quiet": "jest --testNamePattern=simulator.* --silent tests",
|
|
18
|
+
"test:merge-recovery": "jest --testPathPattern=merge-recovery --verbose",
|
|
19
|
+
"test:merge-recovery:single": "jest --testPathPattern=merge-recovery --testNamePattern=corrupted-index-from-previous-pr --verbose",
|
|
18
20
|
"lint": "eslint 'src/**/*.ts'",
|
|
19
21
|
"prepublishOnly": "npm run build",
|
|
20
22
|
"extract:pdf": "texttopdf ",
|
|
@@ -31,7 +33,7 @@
|
|
|
31
33
|
"jsdom": "^26.0.0",
|
|
32
34
|
"minisearch": "^7.1.0",
|
|
33
35
|
"natural": "^8.1.0",
|
|
34
|
-
"openai": "^
|
|
36
|
+
"openai": "^5.23.2",
|
|
35
37
|
"simple-git": "^3.27.0",
|
|
36
38
|
"stopwords-fr": "^0.3.0"
|
|
37
39
|
},
|
package/dist/src/execute.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { AgentConfig, AgenticContext, AgentModel, ExecuteAgentResult, Feedback, ExecutionResult } from "./types";
|
|
2
|
-
import { Writable } from "stream";
|
|
3
|
-
import { AgentStateGraph } from "./stategraph";
|
|
4
|
-
export declare const DummyWritable: any;
|
|
5
|
-
export declare function modelConfig(model: string, custom?: any): AgentModel;
|
|
6
|
-
export declare function sendFeedback(params: Feedback): void;
|
|
7
|
-
export interface ReadCompletionsStreamOptions {
|
|
8
|
-
stateGraph: AgentStateGraph;
|
|
9
|
-
discussion: any;
|
|
10
|
-
agentConfig: AgentConfig;
|
|
11
|
-
agents: AgentConfig[];
|
|
12
|
-
discussionRootAgent: string;
|
|
13
|
-
stdout: Writable;
|
|
14
|
-
session: AgenticContext;
|
|
15
|
-
final: any;
|
|
16
|
-
verbose?: boolean;
|
|
17
|
-
enrichWithMemory?: (role: string, agent: AgentConfig, context: AgenticContext) => Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
export declare function readCompletionsStream(params: ReadCompletionsStreamOptions): Promise<ExecutionResult>;
|
|
20
|
-
/**
|
|
21
|
-
* Parameters for executing an agent set
|
|
22
|
-
* @interface ExecuteAgentSetParams
|
|
23
|
-
* @property {string} query - User query to process
|
|
24
|
-
* @property {string} home - Name of the agent to start with
|
|
25
|
-
* @property {Writable} stdout - Stream to write output to
|
|
26
|
-
* @property {any[]} [messages] - Messages to add to the conversation
|
|
27
|
-
* @property {boolean} [verbose] - Whether to log verbose debug information
|
|
28
|
-
*/
|
|
29
|
-
export interface ExecuteAgentSetParams {
|
|
30
|
-
enrichWithMemory?: (role: string, agent: AgentConfig, context: AgenticContext) => Promise<string>;
|
|
31
|
-
query: string;
|
|
32
|
-
home?: string;
|
|
33
|
-
model?: string;
|
|
34
|
-
stdout: Writable;
|
|
35
|
-
messages?: any[];
|
|
36
|
-
verbose?: boolean;
|
|
37
|
-
json?: boolean;
|
|
38
|
-
schema?: any;
|
|
39
|
-
debug?: boolean;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Executes a set of agents to process a user query
|
|
43
|
-
*
|
|
44
|
-
* This function initializes the agent memory, processes the user query through the appropriate
|
|
45
|
-
* agent, and handles any agent transfers or tool calls that occur during execution.
|
|
46
|
-
*
|
|
47
|
-
* @param {AgentConfig[]} agentSet - Array of agent configurations
|
|
48
|
-
* @param {AgenticContext} session - {memory, user, ...} - Session object to store/read conversation state
|
|
49
|
-
* @param {ExecuteAgentSetParams} params - Execution parameters
|
|
50
|
-
* @returns {Promise<void>}
|
|
51
|
-
*/
|
|
52
|
-
export declare function executeAgentSet(agentSet: AgentConfig[], context: AgenticContext, params: ExecuteAgentSetParams): Promise<ExecutionResult>;
|
|
53
|
-
export declare function executeAgent(agentSet: AgentConfig[], params: ExecuteAgentSetParams): Promise<ExecuteAgentResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Executes a simple query without agent orchestration or tool handling
|
|
56
|
-
*
|
|
57
|
-
* This is the simplest level of execution - just sends a query to the LLM
|
|
58
|
-
* and returns the response. No tools, no agent transfers, no complex logic.
|
|
59
|
-
*
|
|
60
|
-
* @param params - Execution parameters including query and model config
|
|
61
|
-
* @returns Promise<ExecuteAgentResult> - Simple result with usage and content
|
|
62
|
-
*/
|
|
63
|
-
export declare function executeQuery(params: ExecuteAgentSetParams): Promise<ExecuteAgentResult>;
|