agentic-api 2.0.26 β†’ 2.0.31

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 (2) hide show
  1. package/README.md +224 -60
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,33 +1,59 @@
1
1
  # @agentic-api
2
2
 
3
- Super simple API for intelligent agent orchestration with automatic sequences and escalations. (inspirΓ© du projet [OpenAI Swarm](https://github.com/openai/openai-realtime-agents))
3
+ Comprehensive framework for intelligent agent orchestration, document processing, and enterprise workflow management. (inspired from [OpenAI Swarm](https://github.com/openai/openai-realtime-agents)) (01/2025)
4
4
 
5
- > **Personal Note**:
6
- > This project is not meant to be better than Vercel or LangChain. It's simply less generic and optimized for a specific set of problems.
5
+ > **Design Philosophy**:
6
+ > This project is not meant to be better than Vercel or LangChain. It's simply less generic and optimized for a specific set of enterprise problems.
7
7
  > It focuses on specific features that required too many dependencies with other frameworks.
8
8
 
9
+ ## πŸš€ Core Capabilities
9
10
 
10
- ## πŸš€ Key Features
11
+ ### πŸ€– Agent Orchestration
12
+ - Multi-agent conversations with automatic transfers
13
+ - State machine-driven workflows for complex processes
14
+ - Confidence-based escalation between specialized agents
15
+ - **StateGraph Architecture**: Modern conversation state management with automatic persistence
11
16
 
12
- - Agent orchestration in predefined sequences
13
- - Automatic model escalation to more intelligent instructions and models.
14
- - Smart transfer between specialized agents with confidence threshold
15
- - Prompting models to follow a state machine, for example to accurately collect things like names and phone numbers.
16
- - **βœ… StateGraph Architecture**: Modern conversation state management with automatic persistence
17
+ ### πŸ“„ Document Processing
18
+ - **MapLLM**: Advanced map-reduce pattern for large document analysis
19
+ - **Structured Outputs**: OpenAI JSON schema validation support
20
+ - **Flexible Loaders**: File and string content processing with chunking strategies
21
+ - **Callback-Driven**: User-defined logic for accumulation and flow control
17
22
 
23
+ ### πŸ§ͺ Testing & Validation
24
+ - **Agent Simulator**: Comprehensive testing framework with scenario-based simulations
25
+ - **Realistic Personas**: Authentic user behavior simulation for thorough testing
26
+ - **Automatic Validation**: Built-in success/failure detection and reporting
18
27
 
19
- ### Key Advantages
28
+ ### πŸ“‹ Enterprise Workflow
29
+ - **Rules Management**: Git-based workflow for business rules and procedures
30
+ - **Pull Request Validation**: Structured review and approval processes
31
+ - **Multi-File Operations**: Atomic operations across related documents
32
+ - **Search Integration**: Full-text search with RAG embeddings
20
33
 
21
- 1. **Simplicity**
22
- - Minimal configuration
23
- - Few dependencies
24
- - Fast
25
- - **Modern StateGraph**: Clean separation of concerns with automatic session management
34
+ ## 🎯 Key Advantages
35
+
36
+ 1. **Enterprise-Ready**
37
+ - Production-grade document workflows
38
+ - Comprehensive testing capabilities
39
+ - Git-based version control integration
40
+
41
+ 2. **Developer-Friendly**
42
+ - Minimal configuration required
43
+ - TypeScript-first with full type safety
44
+ - Modular architecture for easy extension
45
+
46
+ 3. **Performance-Optimized**
47
+ - Efficient chunking strategies
48
+ - Intelligent caching systems
49
+ - Parallel processing support
26
50
 
27
51
  ### Recommended Use Cases
28
52
 
29
- - Applications requiring specialized agent orchestration
30
- - Projects needing reliable content extraction
53
+ - **Enterprise Document Management**: Rules, procedures, and knowledge base management
54
+ - **Agent Development & Testing**: Comprehensive agent behavior validation
55
+ - **Large Document Processing**: Analysis and synthesis of complex documents
56
+ - **Conversational AI Systems**: Multi-agent workflows with state management
31
57
 
32
58
 
33
59
  [![](https://mermaid.ink/img/pako:eNpVkcluwjAQhl_FGgmJSoDIQoAcKhEQ7aGXNkiVmqDKTYYkUmJHxu5GeZaq575cH6EmC8sc7PnG_4xn7B1EPEZwYZPztyilQpLVImREmy81dYNqW1_VsVlwIxAlinXNi24Qwt_37w-5VQVlIbTCet2ql0TQMiU-itcswudZgkxuSdAwqbkpdrA4ExjJjDNy93CKekbg0xzPhZ4ZzNVW8gIF8VVZct3k2akV3CsujxnI4pDV7jx4XC3XLVXTkX7_msyaCSvwjAsyL8hqkzsdsuQi0h3QPEsYFnoYknKRfXImaV6LPIP0B2dFPLNhq2Gr5kVbtUn4WtIsVwK_yLxp_HD7KXrUQw_0IxQ0i_U37g6xEGSqmwnB1W6MG6pyGULI9lpKleT-B4vAlUJhDwRXSQruhuZbTaqMqcRFRvW3Fa2kpOyJ8yMm4nBTk60fFsWcKybBHVVScHfwrmFiDgzTGJvToWFY2nrwAe54OBg5pu1Yjj21Dcd29j34rGoPB5OxPT23_T90g8Qf?type=png)](https://mermaid.live/edit#pako:eNpVkcluwjAQhl_FGgmJSoDIQoAcKhEQ7aGXNkiVmqDKTYYkUmJHxu5GeZaq575cH6EmC8sc7PnG_4xn7B1EPEZwYZPztyilQpLVImREmy81dYNqW1_VsVlwIxAlinXNi24Qwt_37w-5VQVlIbTCet2ql0TQMiU-itcswudZgkxuSdAwqbkpdrA4ExjJjDNy93CKekbg0xzPhZ4ZzNVW8gIF8VVZct3k2akV3CsujxnI4pDV7jx4XC3XLVXTkX7_msyaCSvwjAsyL8hqkzsdsuQi0h3QPEsYFnoYknKRfXImaV6LPIP0B2dFPLNhq2Gr5kVbtUn4WtIsVwK_yLxp_HD7KXrUQw_0IxQ0i_U37g6xEGSqmwnB1W6MG6pyGULI9lpKleT-B4vAlUJhDwRXSQruhuZbTaqMqcRFRvW3Fa2kpOyJ8yMm4nBTk60fFsWcKybBHVVScHfwrmFiDgzTGJvToWFY2nrwAe54OBg5pu1Yjj21Dcd29j34rGoPB5OxPT23_T90g8Qf)
@@ -42,9 +68,9 @@ npm install @agentic-api
42
68
 
43
69
  ```typescript
44
70
  import OpenAI from "openai";
45
- import { executeAgentSet } from '@agentic-api/execute';
46
- import { AgenticContext } from '@agentic-api/types';
47
- import { AgentStateGraph } from '@agentic-api/stategraph';
71
+ import { executeAgentSet } from '@agentic-api';
72
+ import { AgenticContext } from '@agentic-api';
73
+ import { AgentStateGraph } from '@agentic-api';
48
74
 
49
75
  const openai = new OpenAI({
50
76
  apiKey: process.env.OPENAI_API_KEY,
@@ -74,8 +100,7 @@ const stream = await executeAgentSet(agents, context, {
74
100
  ## πŸ€– Custom Agent Creation
75
101
 
76
102
  ```typescript
77
- import { AgentConfig } from '@agentic-api/types';
78
- import { modelConfig } from '@agentic-api/execute';
103
+ import { AgentConfig, modelConfig } from '@agentic-api';
79
104
 
80
105
  // Example specialized agent with thinking tool
81
106
  const haiku: AgentConfig = {
@@ -98,7 +123,7 @@ const welcome: AgentConfig = {
98
123
  };
99
124
 
100
125
  // Inject transfer and thinking tools
101
- import { injectTransferTools } from '@agentic-api/utils';
126
+ import { injectTransferTools } from '@agentic-api';
102
127
  const myAgents = injectTransferTools([welcome, haiku]);
103
128
  ```
104
129
 
@@ -107,7 +132,7 @@ const myAgents = injectTransferTools([welcome, haiku]);
107
132
  The new StateGraph architecture provides automatic conversation state management:
108
133
 
109
134
  ```typescript
110
- import { AgentStateGraph, sessionStateGraphGet, sessionStateGraphSet } from '@agentic-api/stategraph';
135
+ import { AgentStateGraph, sessionStateGraphGet, sessionStateGraphSet } from '@agentic-api';
111
136
 
112
137
  // StateGraph is automatically managed during executeAgentSet
113
138
  // But you can also work with it directly:
@@ -234,7 +259,7 @@ stateGraph.clearDiscussion("agentName");
234
259
  ### **Utility Functions**
235
260
  ```typescript
236
261
  // Get specialized (starting) agent for discussion
237
- import { getSpecializedAgent } from '@agentic-api/stategraph';
262
+ import { getSpecializedAgent } from '@agentic-api';
238
263
  const specializedAgent = getSpecializedAgent(discussion);
239
264
 
240
265
  // Find discussion by ID
@@ -247,49 +272,188 @@ stateGraph.renameDiscussion("agentName", "New Name", "Description");
247
272
  stateGraph.deleteDiscussion("agentName");
248
273
  ```
249
274
 
250
- ## πŸ’Ύ Pull-based Data Digestion
275
+ ## πŸ—‚οΈ MapLLM Document Processing
276
+
277
+ Modern map-reduce pattern for processing large documents with flexible content handling and OpenAI structured outputs.
278
+
279
+ - **Flexible Loaders**: `FileNativeLoader` and `StringNativeLoader` with configurable chunking strategies
280
+ - **Callback-Driven**: User-defined logic for accumulation, termination, and flow control
281
+ - **Structured Outputs**: Optional JSON schema validation via OpenAI structured outputs
282
+ - **Robust EOF Handling**: Proper chunk boundary detection and clean termination
283
+
284
+ πŸ“– **[Complete MapLLM Documentation β†’](./docs/README-AGENT-REDUCE.md)**
285
+
286
+ ```typescript
287
+ import { MapLLM, FileNativeLoader, modelConfig } from '@agentic-api';
288
+
289
+ // Basic text processing
290
+ const config = {
291
+ digestPrompt: "Analyze this chunk for key information.",
292
+ reducePrompt: "Merge analysis with previous results."
293
+ };
294
+
295
+ const loader = new FileNativeLoader('document.pdf', { type: 'pages', size: 1 });
296
+ const mapper = new MapLLM(loader);
297
+
298
+ const callback = (result, currentValue) => {
299
+ result.acc = result.acc + `\n${currentValue}\n`;
300
+
301
+ // Stop conditions
302
+ if (result.acc.length > 5000) {
303
+ result.continue = true;
304
+ }
305
+ if (result.metadata.iterations > 20) {
306
+ result.maxIterations = true;
307
+ }
308
+
309
+ return result;
310
+ };
311
+
312
+ const init = {
313
+ acc: "",
314
+ model: modelConfig("LOW-fast"),
315
+ verbose: true
316
+ };
317
+
318
+ const result = await mapper.reduce(config, callback, init);
319
+ console.log('Final result:', result.acc);
320
+
321
+ // Structured output processing with JSON schema
322
+ const myJsonSchema = {
323
+ type: "object",
324
+ properties: {
325
+ summary: { type: "string" },
326
+ key_points: { type: "array", items: { type: "string" } }
327
+ },
328
+ required: ["summary", "key_points"]
329
+ };
330
+
331
+ const structuredCallback = (result, currentValue) => {
332
+ // Set structured output format
333
+ result.format = {
334
+ name: "analysis",
335
+ schema: myJsonSchema,
336
+ strict: true
337
+ };
338
+
339
+ // For structured output, accumulate as object or merged object
340
+ result.acc = { ...result.acc, ...currentValue };
341
+
342
+ if (result.metadata.iterations > 5) {
343
+ result.maxIterations = true;
344
+ }
345
+
346
+ return result;
347
+ };
348
+
349
+ const structuredResult = await mapper.reduce(config, structuredCallback, {
350
+ acc: {},
351
+ verbose: true
352
+ });
353
+ // structuredResult.acc is validated JSON matching the schema
354
+ ```
355
+
356
+ ## πŸ€– Agent Simulator
251
357
 
252
- This feature enables agents to process large documents chunk by chunk. It's designed for scenarios where the entire document cannot fit into the agent's context window.
358
+ Advanced testing framework for agent behavior validation with scenario-based simulations.
253
359
 
254
- - **Chunked Processing**: The `pullContentDigestor` tool allows an agent to request and process content in manageable chunks.
255
- - **Stateful Digestion**: The agent receives the current chunk and relevant instructions, including the previous processing results, to maintain context throughout the digestion of the entire document.
256
- - **Flexible Templates**: Different processing templates (e.g., "facts", "compress", "semantic", "minutes") can be applied to each chunk, guiding the agent on how to digest the information.
257
- - **EOF Handling**: The tool signals the end of the document with an "EOF" message, allowing the agent to finalize its processing.
360
+ - **Scenario-Based Testing**: Define complex test scenarios with goals, personas, and expected outcomes
361
+ - **Conversational Simulation**: Simulate realistic user interactions with agents
362
+ - **Automatic Validation**: Built-in success/failure detection and error reporting
363
+ - **Exchange Limiting**: Control simulation length with configurable exchange limits
364
+
365
+ πŸ“– **[Complete Agent Simulator Documentation β†’](./docs/README-AGENT-SIMULATOR.md)**
258
366
 
259
367
  ```typescript
260
- // Example of how an agent might use the pullContentDigestor tool
261
-
262
- // Agent receives a call to process a large document
263
- // Initial call to the tool
264
- const initialChunkData = await pullContentDigestor({
265
- path: "path/to/large/document.pdf",
266
- template: "facts", // or any other relevant template
267
- position: 0 // Initial position
368
+ import { AgentSimulator, SimulationScenario } from '@agentic-api';
369
+
370
+ // Define test scenario
371
+ const scenario: SimulationScenario = {
372
+ testGoals: "Verify that the agent can help with haiku creation",
373
+ testEnd: "Agent provides a complete haiku poem",
374
+ testPersona: "A poetry enthusiast seeking creative assistance",
375
+ testQuery: "I want to write a haiku about nature. Can you help me?",
376
+ testResult: "Agent successfully guides haiku creation process",
377
+ testError: "Agent refuses to help or provides incorrect format"
378
+ };
379
+
380
+ // Configure simulator
381
+ const simulator = new AgentSimulator({
382
+ agents: [haikuAgent, welcomeAgent],
383
+ start: "welcome",
384
+ verbose: true,
385
+ instructionEx: "Focus on creative writing assistance"
268
386
  });
269
387
 
270
- let currentChunk = initialChunkData.content;
271
- let nextPosition = initialChunkData.nextPosition;
272
- let accumulatedResults = ""; // Agent will accumulate results here
273
-
274
- while (!currentChunk.includes("EOF")) {
275
- // Process the currentChunk based on instructions and template
276
- // The agent would use its LLM capabilities here,
277
- // using the provided instructions, previous results, and the new chunk.
278
- const processingResult = await processMyChunk(currentChunk, initialChunkData.instructions, accumulatedResults);
279
- accumulatedResults += processingResult; // Append to overall result
280
-
281
- // Request the next chunk
282
- const nextChunkData = await pullContentDigestor({
283
- path: "path/to/large/document.pdf",
284
- template: "facts",
285
- position: nextPosition
286
- });
287
- currentChunk = nextChunkData.content;
288
- nextPosition = nextChunkData.nextPosition;
388
+ // Run simulation
389
+ const result = await simulator.executeSimulation({
390
+ scenario,
391
+ maxExchanges: 10,
392
+ onMessage: (message) => {
393
+ console.log(`${message.role}: ${message.content}`);
394
+ }
395
+ });
396
+
397
+ // Validate results
398
+ console.log('Success:', result.success);
399
+ console.log('Summary:', result.message);
400
+ console.log('Exchanges:', result.exchangeCount);
401
+
402
+ if (!result.success) {
403
+ console.error('Error:', result.error);
289
404
  }
405
+ ```
406
+
407
+ ### Simulation Features
408
+
409
+ - **Structured Scenarios**: Define test goals, end conditions, and expected behaviors
410
+ - **Persona Simulation**: Simulator adopts specific user personas for realistic testing
411
+ - **Error Detection**: Automatic detection of unwanted content or behaviors
412
+ - **Exchange Tracking**: Monitor conversation flow and agent performance
413
+ - **Execution Metadata**: Access to token usage, actions, and performance metrics
414
+
415
+ ## πŸ“‹ Rules Management System
416
+
417
+ Enterprise-grade Git-based workflow for managing business rules, procedures, and documentation.
418
+
419
+ - **Git-Based Workflow**: Complete version control with branch-based status management
420
+ - **Pull Request Validation**: Structured validation process with reviewer assignment
421
+ - **Multi-File Operations**: Atomic operations across multiple related documents
422
+ - **Content Management**: Rich metadata support with front-matter parsing
423
+ - **Search Integration**: Full-text search with RAG embeddings support
424
+
425
+ πŸ“– **[Complete Rules System Documentation β†’](./docs/README-RULES-SYSTEM.md)**
426
+
427
+ ```typescript
428
+ import { RulesWorkflow, gitLoad, RuleStatus } from '@agentic-api';
429
+
430
+ // Initialize workflow
431
+ const config = gitLoad(); // Loads from environment variables
432
+ const workflow = new RulesWorkflow(config);
433
+
434
+ // Create a new rule
435
+ const newRule = await workflow.createRule('procedures/finance/budget.md', {
436
+ title: 'Budget Validation Process',
437
+ slugs: ['budget-validation'],
438
+ tags: ['finance', 'validation'],
439
+ role: 'rule'
440
+ }, 'Initial budget validation procedure');
441
+
442
+ // Create validation request (PR)
443
+ const prBranch = await workflow.createPullRequest(
444
+ ['procedure-a.md', 'procedure-b.md'],
445
+ 'Update financial procedures'
446
+ );
447
+
448
+ // Search rules by content
449
+ const searchResults = await workflow.searchRules('budget validation', {
450
+ branch: 'main',
451
+ tags: ['finance'],
452
+ limit: 10
453
+ });
290
454
 
291
- // Final processing of accumulatedResults
292
- const finalDigestedDocument = finalizeProcessing(accumulatedResults);
455
+ // Get rules by status
456
+ const draftRules = await workflow.getRulesByStatus(RuleStatus.EDITING);
293
457
  ```
294
458
 
295
459
  ## πŸ§ͺ Testing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-api",
3
- "version": "2.0.26",
3
+ "version": "2.0.31",
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",