@igniter-js/agents 0.1.13 → 0.1.14
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/AGENTS.md +115 -54
- package/README.md +72 -42
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{index-CX4IgrRt.d.mts → index-CqUbHeyY.d.mts} +78 -2
- package/dist/{index-CX4IgrRt.d.ts → index-CqUbHeyY.d.ts} +78 -2
- package/dist/index.d.mts +446 -53
- package/dist/index.d.ts +446 -53
- package/dist/index.js +717 -340
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +717 -341
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/AGENTS.md
CHANGED
|
@@ -293,7 +293,7 @@ All events include contextual attributes and error details when applicable.
|
|
|
293
293
|
|
|
294
294
|
| Package | Purpose | Version |
|
|
295
295
|
| ----------------------- | ---------------------------------------- | --------- |
|
|
296
|
-
| `@igniter-js/
|
|
296
|
+
| `@igniter-js/common` | Base error classes and logger interfaces | `^0.1.0` |
|
|
297
297
|
| `@igniter-js/telemetry` | Telemetry manager integration | `^0.1.0` |
|
|
298
298
|
| `ai` | Vercel AI SDK for agent runtime | `^6.0.0` |
|
|
299
299
|
| `zod` | Schema validation and type inference | `^4.0.0` |
|
|
@@ -449,7 +449,10 @@ const agent = IgniterAgent.create("weather-assistant")
|
|
|
449
449
|
.build();
|
|
450
450
|
|
|
451
451
|
const response = await agent.generate({
|
|
452
|
-
|
|
452
|
+
chatId: 'chat_123',
|
|
453
|
+
userId: 'user_123',
|
|
454
|
+
context: {},
|
|
455
|
+
message: { role: 'user', content: 'What is the weather in New York?' }
|
|
453
456
|
});
|
|
454
457
|
console.log(response);
|
|
455
458
|
```
|
|
@@ -552,7 +555,10 @@ const agent = IgniterAgent.create("my-agent")
|
|
|
552
555
|
|
|
553
556
|
// Generate conversation (auto-saves to JSON files)
|
|
554
557
|
await agent.generate({
|
|
555
|
-
|
|
558
|
+
chatId: 'chat_123',
|
|
559
|
+
userId: 'user_123',
|
|
560
|
+
context: {},
|
|
561
|
+
message: { role: 'user', content: 'Hello!' }
|
|
556
562
|
});
|
|
557
563
|
|
|
558
564
|
// Disconnect when done (syncs remaining data)
|
|
@@ -700,8 +706,10 @@ const supportAgent = IgniterAgent.create("customer-support")
|
|
|
700
706
|
// Handle customer message
|
|
701
707
|
async function handleCustomerMessage(message: string, customerId: string) {
|
|
702
708
|
const response = await supportAgent.generate({
|
|
703
|
-
|
|
704
|
-
|
|
709
|
+
chatId: `chat_${customerId}`,
|
|
710
|
+
userId: customerId,
|
|
711
|
+
context: {},
|
|
712
|
+
message: { role: 'user', content: message }
|
|
705
713
|
});
|
|
706
714
|
return response;
|
|
707
715
|
}
|
|
@@ -812,12 +820,10 @@ async function reviewPR(repo: string, prNumber: number) {
|
|
|
812
820
|
`;
|
|
813
821
|
|
|
814
822
|
const review = await reviewAgent.generate({
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
context: { type: "pr_review" },
|
|
820
|
-
}
|
|
823
|
+
chatId: `pr_${prNumber}`,
|
|
824
|
+
userId: repo,
|
|
825
|
+
context: { repo, prNumber, type: "pr_review" },
|
|
826
|
+
message: { role: 'user', content: prompt }
|
|
821
827
|
});
|
|
822
828
|
|
|
823
829
|
return review;
|
|
@@ -967,10 +973,10 @@ async function analyzeSalesData(query: string) {
|
|
|
967
973
|
`;
|
|
968
974
|
|
|
969
975
|
const analysis = await analysisAgent.generate({
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}
|
|
976
|
+
chatId: 'analysis_1',
|
|
977
|
+
userId: 'user_123',
|
|
978
|
+
context: { type: "data_analysis", query },
|
|
979
|
+
message: { role: 'user', content: prompt }
|
|
974
980
|
});
|
|
975
981
|
|
|
976
982
|
return analysis;
|
|
@@ -1047,11 +1053,10 @@ async function handleIntegrationRequest(request: IntegrationRequest) {
|
|
|
1047
1053
|
}
|
|
1048
1054
|
|
|
1049
1055
|
const result = await agent.generate({
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
}
|
|
1056
|
+
chatId: `integration_${request.id}`,
|
|
1057
|
+
userId: request.userId,
|
|
1058
|
+
context: request.metadata,
|
|
1059
|
+
message: { role: 'user', content: request.description }
|
|
1055
1060
|
});
|
|
1056
1061
|
|
|
1057
1062
|
// Store integration result
|
|
@@ -1231,11 +1236,10 @@ async function conductTutoringSession(studentId: string, topic: string) {
|
|
|
1231
1236
|
`;
|
|
1232
1237
|
|
|
1233
1238
|
const session = await tutorAgent.generate({
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
}
|
|
1239
|
+
chatId: `tutor_${studentId}`,
|
|
1240
|
+
userId: studentId,
|
|
1241
|
+
context: { type: "tutoring_session", topic },
|
|
1242
|
+
message: { role: 'user', content: sessionPrompt }
|
|
1239
1243
|
});
|
|
1240
1244
|
|
|
1241
1245
|
return session;
|
|
@@ -1418,7 +1422,7 @@ The `@igniter-js/agents` package provides a comprehensive error hierarchy for pr
|
|
|
1418
1422
|
|
|
1419
1423
|
**`IgniterAgentError`**
|
|
1420
1424
|
|
|
1421
|
-
Base error class that extends `IgniterError` from `@igniter-js/
|
|
1425
|
+
Base error class that extends `IgniterError` from `@igniter-js/common`. All agent-related errors inherit from this class.
|
|
1422
1426
|
|
|
1423
1427
|
```typescript
|
|
1424
1428
|
import { IgniterAgentError, IgniterAgentErrorCode } from '@igniter-js/agents';
|
|
@@ -1549,7 +1553,12 @@ import {
|
|
|
1549
1553
|
} from '@igniter-js/agents';
|
|
1550
1554
|
|
|
1551
1555
|
try {
|
|
1552
|
-
await agent.generate({
|
|
1556
|
+
await agent.generate({
|
|
1557
|
+
chatId: 'chat_123',
|
|
1558
|
+
userId: 'user_123',
|
|
1559
|
+
context: {},
|
|
1560
|
+
message: { role: 'user', content: 'Hello' }
|
|
1561
|
+
});
|
|
1553
1562
|
} catch (error) {
|
|
1554
1563
|
// Safe type narrowing
|
|
1555
1564
|
if (isIgniterAgentMCPError(error)) {
|
|
@@ -1599,7 +1608,12 @@ All errors use standardized error codes from `IgniterAgentErrorCode` enum:
|
|
|
1599
1608
|
- **Example:**
|
|
1600
1609
|
```typescript
|
|
1601
1610
|
try {
|
|
1602
|
-
await agent.generate({
|
|
1611
|
+
await agent.generate({
|
|
1612
|
+
chatId: 'chat_123',
|
|
1613
|
+
userId: 'user_123',
|
|
1614
|
+
context: {},
|
|
1615
|
+
messages: []
|
|
1616
|
+
});
|
|
1603
1617
|
} catch (error) {
|
|
1604
1618
|
if (error.code === IgniterAgentErrorCode.UNKNOWN) {
|
|
1605
1619
|
logger.error('Unexpected error:', error.cause);
|
|
@@ -1656,7 +1670,12 @@ All errors use standardized error codes from `IgniterAgentErrorCode` enum:
|
|
|
1656
1670
|
.build();
|
|
1657
1671
|
|
|
1658
1672
|
await agent.start(); // Required before generate()
|
|
1659
|
-
const result = await agent.generate({
|
|
1673
|
+
const result = await agent.generate({
|
|
1674
|
+
chatId: 'chat_123',
|
|
1675
|
+
userId: 'user_123',
|
|
1676
|
+
context: {},
|
|
1677
|
+
message: { role: 'user', content: 'Hello' }
|
|
1678
|
+
});
|
|
1660
1679
|
```
|
|
1661
1680
|
|
|
1662
1681
|
##### `IGNITER_AGENT_MODEL_MISSING`
|
|
@@ -1708,14 +1727,18 @@ All errors use standardized error codes from `IgniterAgentErrorCode` enum:
|
|
|
1708
1727
|
|
|
1709
1728
|
// ✅ WORKS
|
|
1710
1729
|
await agent.generate({
|
|
1711
|
-
|
|
1712
|
-
|
|
1730
|
+
chatId: 'chat_456',
|
|
1731
|
+
userId: 'user_123',
|
|
1732
|
+
context: { userId: 'user_123', chatId: 'chat_456' },
|
|
1733
|
+
message: { role: 'user', content: 'Hello' }
|
|
1713
1734
|
});
|
|
1714
1735
|
|
|
1715
1736
|
// ❌ FAILS - Missing chatId
|
|
1716
1737
|
await agent.generate({
|
|
1717
|
-
|
|
1718
|
-
|
|
1738
|
+
chatId: 'chat_456',
|
|
1739
|
+
userId: 'user_123',
|
|
1740
|
+
context: { userId: 'user_123' },
|
|
1741
|
+
message: { role: 'user', content: 'Hello' }
|
|
1719
1742
|
});
|
|
1720
1743
|
```
|
|
1721
1744
|
|
|
@@ -1779,10 +1802,13 @@ All errors use standardized error codes from `IgniterAgentErrorCode` enum:
|
|
|
1779
1802
|
- **Example:**
|
|
1780
1803
|
```typescript
|
|
1781
1804
|
const result = await agent.generate({
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1805
|
+
chatId: 'chat_123',
|
|
1806
|
+
userId: 'user_123',
|
|
1807
|
+
context: {},
|
|
1808
|
+
message: {
|
|
1809
|
+
role: 'user',
|
|
1810
|
+
content: 'Use filesystem tool to read /invalid/path'
|
|
1811
|
+
}
|
|
1786
1812
|
});
|
|
1787
1813
|
// May throw MCP_TOOL_ERROR if filesystem server fails
|
|
1788
1814
|
```
|
|
@@ -2033,7 +2059,12 @@ import {
|
|
|
2033
2059
|
} from '@igniter-js/agents';
|
|
2034
2060
|
|
|
2035
2061
|
try {
|
|
2036
|
-
await agent.generate({
|
|
2062
|
+
await agent.generate({
|
|
2063
|
+
chatId: 'chat_123',
|
|
2064
|
+
userId: 'user_123',
|
|
2065
|
+
context: {},
|
|
2066
|
+
message: { role: 'user', content: 'Hello' }
|
|
2067
|
+
});
|
|
2037
2068
|
} catch (error) {
|
|
2038
2069
|
if (isIgniterAgentMCPError(error)) {
|
|
2039
2070
|
console.error(`MCP error in ${error.mcpName}:`, error.message);
|
|
@@ -2146,7 +2177,12 @@ function logAgentError(error: unknown, context: Record<string, unknown>) {
|
|
|
2146
2177
|
|
|
2147
2178
|
// Usage
|
|
2148
2179
|
try {
|
|
2149
|
-
await agent.generate({
|
|
2180
|
+
await agent.generate({
|
|
2181
|
+
chatId: 'chat_123',
|
|
2182
|
+
userId: 'user_123',
|
|
2183
|
+
context: {},
|
|
2184
|
+
message: { role: 'user', content: 'Hello' }
|
|
2185
|
+
});
|
|
2150
2186
|
} catch (error) {
|
|
2151
2187
|
logAgentError(error, { operation: 'generate', agentName: 'assistant' });
|
|
2152
2188
|
}
|
|
@@ -2209,14 +2245,15 @@ const agent = IgniterAgent.create("advanced-agent")
|
|
|
2209
2245
|
|
|
2210
2246
|
// Usage with typed context
|
|
2211
2247
|
const result = await agent.generate({
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2248
|
+
chatId: 'admin_cleanup',
|
|
2249
|
+
userId: "user123",
|
|
2250
|
+
context: {
|
|
2215
2251
|
tenantId: "tenant456",
|
|
2216
2252
|
permissions: ["admin", "write"],
|
|
2217
2253
|
database: prismaClient,
|
|
2218
2254
|
cache: redisClient,
|
|
2219
|
-
}
|
|
2255
|
+
},
|
|
2256
|
+
message: { role: 'user', content: "perform admin cleanup" }
|
|
2220
2257
|
});
|
|
2221
2258
|
```
|
|
2222
2259
|
|
|
@@ -2386,12 +2423,18 @@ const manager = IgniterAgentManager.create()
|
|
|
2386
2423
|
|
|
2387
2424
|
// Agents can now communicate with each other
|
|
2388
2425
|
await manager.get("agent-a").generate({
|
|
2389
|
-
|
|
2426
|
+
chatId: 'chat_a',
|
|
2427
|
+
userId: 'agent-a',
|
|
2428
|
+
context: {},
|
|
2429
|
+
message: { role: 'user', content: 'send message to Bob: hello!' }
|
|
2390
2430
|
});
|
|
2391
2431
|
const response = await manager
|
|
2392
2432
|
.get("agent-b")
|
|
2393
2433
|
.generate({
|
|
2394
|
-
|
|
2434
|
+
chatId: 'chat_b',
|
|
2435
|
+
userId: 'agent-b',
|
|
2436
|
+
context: {},
|
|
2437
|
+
message: { role: 'user', content: 'check for new messages' }
|
|
2395
2438
|
});
|
|
2396
2439
|
```
|
|
2397
2440
|
|
|
@@ -2480,8 +2523,10 @@ class AgentPool {
|
|
|
2480
2523
|
this.currentIndex = (this.currentIndex + 1) % this.agents.length;
|
|
2481
2524
|
|
|
2482
2525
|
return agent.generate({
|
|
2483
|
-
|
|
2484
|
-
|
|
2526
|
+
chatId: `pool_${this.currentIndex}`,
|
|
2527
|
+
userId: 'pool',
|
|
2528
|
+
context: context ?? {},
|
|
2529
|
+
message: { role: 'user', content: input }
|
|
2485
2530
|
});
|
|
2486
2531
|
}
|
|
2487
2532
|
|
|
@@ -2591,7 +2636,10 @@ const secureAgent = IgniterAgent.create("secure-agent")
|
|
|
2591
2636
|
// Require authentication for all interactions
|
|
2592
2637
|
if (!context.authenticated) {
|
|
2593
2638
|
await context.agent.generate({
|
|
2594
|
-
|
|
2639
|
+
chatId: 'auth_prompt',
|
|
2640
|
+
userId: context.userId ?? 'unknown',
|
|
2641
|
+
context: {},
|
|
2642
|
+
message: { role: 'user', content: 'authenticate with provided token first' }
|
|
2595
2643
|
});
|
|
2596
2644
|
throw new Error("Authentication required");
|
|
2597
2645
|
}
|
|
@@ -2858,12 +2906,22 @@ await agentManager.startAll();
|
|
|
2858
2906
|
const customerQuery = "I want to check the status of my order #12345";
|
|
2859
2907
|
const response = await agentManager
|
|
2860
2908
|
.get("customer-service")
|
|
2861
|
-
.generate({
|
|
2909
|
+
.generate({
|
|
2910
|
+
chatId: 'chat_customer',
|
|
2911
|
+
userId: 'user_123',
|
|
2912
|
+
context: {},
|
|
2913
|
+
message: { role: 'user', content: customerQuery }
|
|
2914
|
+
});
|
|
2862
2915
|
|
|
2863
2916
|
const inventoryQuery = "How many units of product ABC123 are in stock?";
|
|
2864
2917
|
const inventoryResponse = await agentManager
|
|
2865
2918
|
.get("inventory")
|
|
2866
|
-
.generate({
|
|
2919
|
+
.generate({
|
|
2920
|
+
chatId: 'chat_inventory',
|
|
2921
|
+
userId: 'user_123',
|
|
2922
|
+
context: {},
|
|
2923
|
+
message: { role: 'user', content: inventoryQuery }
|
|
2924
|
+
});
|
|
2867
2925
|
```
|
|
2868
2926
|
|
|
2869
2927
|
#### Advanced MCP Integration
|
|
@@ -2897,10 +2955,13 @@ const mcpAgent = IgniterAgent.create("mcp-integrated")
|
|
|
2897
2955
|
|
|
2898
2956
|
// The agent can now use MCP tools automatically
|
|
2899
2957
|
const result = await mcpAgent.generate({
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2958
|
+
chatId: 'chat_123',
|
|
2959
|
+
userId: 'user_123',
|
|
2960
|
+
context: {},
|
|
2961
|
+
message: {
|
|
2962
|
+
role: 'user',
|
|
2963
|
+
content: 'Check the current git status and show me any uncommitted changes'
|
|
2964
|
+
}
|
|
2904
2965
|
});
|
|
2905
2966
|
```
|
|
2906
2967
|
|
package/README.md
CHANGED
|
@@ -217,12 +217,13 @@ await agent.start()
|
|
|
217
217
|
|
|
218
218
|
// Generate a response (agent chooses to use tools as needed)
|
|
219
219
|
const result = await agent.generate({
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
220
|
+
chatId: 'chat_123',
|
|
221
|
+
userId: 'user_123',
|
|
222
|
+
context: {},
|
|
223
|
+
message: {
|
|
224
|
+
role: 'user',
|
|
225
|
+
content: 'What is the weather like in London right now?',
|
|
226
|
+
},
|
|
226
227
|
})
|
|
227
228
|
|
|
228
229
|
console.log(result.content)
|
|
@@ -257,15 +258,19 @@ await agent.start()
|
|
|
257
258
|
|
|
258
259
|
// First turn
|
|
259
260
|
let response = await agent.generate({
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
chatId: 'chat_123',
|
|
262
|
+
userId: 'user_123',
|
|
263
|
+
context: {},
|
|
264
|
+
message: { role: 'user', content: 'My name is Alice and I live in Paris' },
|
|
263
265
|
})
|
|
264
266
|
console.log(response.content)
|
|
265
267
|
|
|
266
268
|
// Second turn - agent remembers context from first turn
|
|
267
269
|
response = await agent.generate({
|
|
268
|
-
|
|
270
|
+
chatId: 'chat_123',
|
|
271
|
+
userId: 'user_123',
|
|
272
|
+
context: {},
|
|
273
|
+
message: { role: 'user', content: "What's my name and where do I live?" },
|
|
269
274
|
})
|
|
270
275
|
console.log(response.content) // Will reference Alice and Paris
|
|
271
276
|
```
|
|
@@ -293,13 +298,13 @@ await agent.start()
|
|
|
293
298
|
|
|
294
299
|
// Use template with dynamic values
|
|
295
300
|
const response = await agent.generate({
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
options: {
|
|
301
|
+
chatId: 'chat_123',
|
|
302
|
+
userId: 'user_123',
|
|
303
|
+
context: {
|
|
300
304
|
company: 'TechCorp',
|
|
301
305
|
tone: 'friendly and professional',
|
|
302
306
|
},
|
|
307
|
+
message: { role: 'user', content: 'I need help with my order' },
|
|
303
308
|
})
|
|
304
309
|
|
|
305
310
|
console.log(response.content)
|
|
@@ -427,12 +432,13 @@ await productivityAgent.start()
|
|
|
427
432
|
|
|
428
433
|
// Step 5: Use the agent
|
|
429
434
|
const response = await productivityAgent.generate({
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
435
|
+
chatId: 'chat_123',
|
|
436
|
+
userId: 'user_123',
|
|
437
|
+
context: {},
|
|
438
|
+
message: {
|
|
439
|
+
role: 'user',
|
|
440
|
+
content: 'What are my high-priority tasks today? And add a meeting reminder.',
|
|
441
|
+
},
|
|
436
442
|
})
|
|
437
443
|
|
|
438
444
|
console.log(response.content)
|
|
@@ -675,7 +681,10 @@ await memory.disconnect() // Flush remaining data before exit
|
|
|
675
681
|
.build()
|
|
676
682
|
|
|
677
683
|
await agent.generate({
|
|
678
|
-
|
|
684
|
+
chatId: 'chat_123',
|
|
685
|
+
userId: 'user_123',
|
|
686
|
+
context: {},
|
|
687
|
+
message: { role: 'user', content: 'I like TypeScript' },
|
|
679
688
|
})
|
|
680
689
|
|
|
681
690
|
await memory.disconnect()
|
|
@@ -694,7 +703,10 @@ await memory.disconnect() // Flush remaining data before exit
|
|
|
694
703
|
|
|
695
704
|
// Agent remembers "user likes TypeScript"
|
|
696
705
|
const response = await agent.generate({
|
|
697
|
-
|
|
706
|
+
chatId: 'chat_123',
|
|
707
|
+
userId: 'user_123',
|
|
708
|
+
context: {},
|
|
709
|
+
message: { role: 'user', content: 'Recommend a library for me' },
|
|
698
710
|
})
|
|
699
711
|
}
|
|
700
712
|
```
|
|
@@ -802,9 +814,10 @@ await agent.start()
|
|
|
802
814
|
|
|
803
815
|
// Agent can now list files, read content, etc. via MCP
|
|
804
816
|
const response = await agent.generate({
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
817
|
+
chatId: 'chat_123',
|
|
818
|
+
userId: 'user_123',
|
|
819
|
+
context: {},
|
|
820
|
+
message: { role: 'user', content: 'List all JSON files in /tmp' },
|
|
808
821
|
})
|
|
809
822
|
|
|
810
823
|
console.log(response.content)
|
|
@@ -943,7 +956,10 @@ async function routeRequest(request: CustomerRequest) {
|
|
|
943
956
|
const agent = manager.getAgent(agentId)
|
|
944
957
|
|
|
945
958
|
return agent.generate({
|
|
946
|
-
|
|
959
|
+
chatId: `chat_${request.id}`,
|
|
960
|
+
userId: request.userId,
|
|
961
|
+
context: {},
|
|
962
|
+
message: { role: 'user', content: request.message },
|
|
947
963
|
})
|
|
948
964
|
}
|
|
949
965
|
```
|
|
@@ -980,12 +996,18 @@ await sharedMemory.updateWorkingMemory({
|
|
|
980
996
|
|
|
981
997
|
// Support agent uses this context
|
|
982
998
|
const supportResponse = await manager.getAgent('support').generate({
|
|
983
|
-
|
|
999
|
+
chatId: 'chat_support',
|
|
1000
|
+
userId: 'user-123',
|
|
1001
|
+
context: {},
|
|
1002
|
+
message: { role: 'user', content: 'I have a problem' },
|
|
984
1003
|
})
|
|
985
1004
|
|
|
986
1005
|
// Sales agent also uses this context
|
|
987
1006
|
const salesResponse = await manager.getAgent('sales').generate({
|
|
988
|
-
|
|
1007
|
+
chatId: 'chat_sales',
|
|
1008
|
+
userId: 'user-123',
|
|
1009
|
+
context: {},
|
|
1010
|
+
message: { role: 'user', content: 'Show me upgrades' },
|
|
989
1011
|
})
|
|
990
1012
|
```
|
|
991
1013
|
|
|
@@ -1089,12 +1111,13 @@ await supportAgent.start()
|
|
|
1089
1111
|
|
|
1090
1112
|
// Use it
|
|
1091
1113
|
const response = await supportAgent.generate({
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1114
|
+
chatId: 'chat_support_1',
|
|
1115
|
+
userId: 'user_123',
|
|
1116
|
+
context: {},
|
|
1117
|
+
message: {
|
|
1118
|
+
role: 'user',
|
|
1119
|
+
content: 'I\\'ve been charged twice for my subscription!',
|
|
1120
|
+
},
|
|
1098
1121
|
})
|
|
1099
1122
|
|
|
1100
1123
|
console.log(response.content)
|
|
@@ -1157,12 +1180,13 @@ const analyticsAgent = IgniterAgent
|
|
|
1157
1180
|
await analyticsAgent.start()
|
|
1158
1181
|
|
|
1159
1182
|
const response = await analyticsAgent.generate({
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1183
|
+
chatId: 'chat_analytics_1',
|
|
1184
|
+
userId: 'user_123',
|
|
1185
|
+
context: {},
|
|
1186
|
+
message: {
|
|
1187
|
+
role: 'user',
|
|
1188
|
+
content: 'Show me revenue trends for the last 30 days with a chart',
|
|
1189
|
+
},
|
|
1166
1190
|
})
|
|
1167
1191
|
|
|
1168
1192
|
console.log(response.content)
|
|
@@ -1225,7 +1249,10 @@ await memory.updateWorkingMemory({
|
|
|
1225
1249
|
// ✅ Always handle agent generation errors
|
|
1226
1250
|
try {
|
|
1227
1251
|
const response = await agent.generate({
|
|
1228
|
-
|
|
1252
|
+
chatId: 'chat_123',
|
|
1253
|
+
userId: 'user_123',
|
|
1254
|
+
context: {},
|
|
1255
|
+
message: { role: 'user', content: 'Hello' },
|
|
1229
1256
|
})
|
|
1230
1257
|
} catch (error) {
|
|
1231
1258
|
if (error instanceof IgniterAgentError) {
|
|
@@ -1567,7 +1594,10 @@ const analysisToolForSalesAgent = IgniterAgentTool
|
|
|
1567
1594
|
// Delegate to analytics agent
|
|
1568
1595
|
const analyticsAgent = manager.getAgent('analytics')
|
|
1569
1596
|
const result = await analyticsAgent.generate({
|
|
1570
|
-
|
|
1597
|
+
chatId: 'chat_analytics_1',
|
|
1598
|
+
userId: 'user_123',
|
|
1599
|
+
context: {},
|
|
1600
|
+
message: { role: 'user', content: query },
|
|
1571
1601
|
})
|
|
1572
1602
|
return { analysis: result.content }
|
|
1573
1603
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { j as IgniterAgentInMemoryAdapter, l as IgniterAgentJSONFileAdapter, k as IgniterAgentJSONFileAdapterOptions } from '../index-
|
|
1
|
+
export { j as IgniterAgentInMemoryAdapter, l as IgniterAgentJSONFileAdapter, k as IgniterAgentJSONFileAdapterOptions } from '../index-CqUbHeyY.mjs';
|
|
2
2
|
import 'ai';
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { j as IgniterAgentInMemoryAdapter, l as IgniterAgentJSONFileAdapter, k as IgniterAgentJSONFileAdapterOptions } from '../index-
|
|
1
|
+
export { j as IgniterAgentInMemoryAdapter, l as IgniterAgentJSONFileAdapter, k as IgniterAgentJSONFileAdapterOptions } from '../index-CqUbHeyY.js';
|
|
2
2
|
import 'ai';
|
|
@@ -485,7 +485,7 @@ interface IgniterAgentWorkingMemoryConfig {
|
|
|
485
485
|
* ```typescript
|
|
486
486
|
* const historyConfig: IgniterAgentHistoryConfig = {
|
|
487
487
|
* enabled: true,
|
|
488
|
-
* limit: 50 // Load last 50 messages for context
|
|
488
|
+
* limit: 50, // Load last 50 messages for context
|
|
489
489
|
* };
|
|
490
490
|
* ```
|
|
491
491
|
*
|
|
@@ -605,6 +605,56 @@ interface IgniterAgentGetMessagesParams {
|
|
|
605
605
|
*/
|
|
606
606
|
limit?: number;
|
|
607
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Parameters for searching messages in history.
|
|
610
|
+
*
|
|
611
|
+
* @public
|
|
612
|
+
*/
|
|
613
|
+
interface IgniterAgentSearchParams {
|
|
614
|
+
/**
|
|
615
|
+
* The chat session ID to retrieve messages from.
|
|
616
|
+
*/
|
|
617
|
+
chatId: string;
|
|
618
|
+
/**
|
|
619
|
+
* Optional user ID to filter messages.
|
|
620
|
+
*/
|
|
621
|
+
userId?: string;
|
|
622
|
+
/**
|
|
623
|
+
* Maximum number of messages to retrieve.
|
|
624
|
+
*/
|
|
625
|
+
limit?: number;
|
|
626
|
+
/**
|
|
627
|
+
* Optional search query to filter messages.
|
|
628
|
+
*/
|
|
629
|
+
search?: string;
|
|
630
|
+
/**
|
|
631
|
+
* Optional date range to filter messages.
|
|
632
|
+
*/
|
|
633
|
+
dateFrom?: Date;
|
|
634
|
+
/**
|
|
635
|
+
* Optional date range to filter messages.
|
|
636
|
+
*/
|
|
637
|
+
dateTo?: Date;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Search result interface.
|
|
641
|
+
*
|
|
642
|
+
* @public
|
|
643
|
+
*/
|
|
644
|
+
interface IgniterAgentSearchResult {
|
|
645
|
+
/**
|
|
646
|
+
* The message ID.
|
|
647
|
+
*/
|
|
648
|
+
id: string;
|
|
649
|
+
/**
|
|
650
|
+
* The message content.
|
|
651
|
+
*/
|
|
652
|
+
content: any;
|
|
653
|
+
/**
|
|
654
|
+
* The message timestamp.
|
|
655
|
+
*/
|
|
656
|
+
timestamp: Date;
|
|
657
|
+
}
|
|
608
658
|
/**
|
|
609
659
|
* Parameters for retrieving chat sessions.
|
|
610
660
|
*
|
|
@@ -908,6 +958,32 @@ interface IgniterAgentMemoryProvider<TScope extends string = string, TIdentifier
|
|
|
908
958
|
* ```
|
|
909
959
|
*/
|
|
910
960
|
deleteChat?(chatId: string): Promise<void>;
|
|
961
|
+
/**
|
|
962
|
+
* Searches for messages in the chat history.
|
|
963
|
+
*
|
|
964
|
+
* @description
|
|
965
|
+
* Retrieves a list of messages that match the search query.
|
|
966
|
+
*
|
|
967
|
+
* @remarks
|
|
968
|
+
* This method is optional. If not implemented, search functionality
|
|
969
|
+
* will be unavailable.
|
|
970
|
+
*
|
|
971
|
+
* @param params - Search parameters
|
|
972
|
+
* @returns List of search results
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```typescript
|
|
976
|
+
* const results = await provider.search?.({
|
|
977
|
+
* chatId: 'chat_123',
|
|
978
|
+
* userId: 'user_456',
|
|
979
|
+
* limit: 10,
|
|
980
|
+
* search: 'deployment',
|
|
981
|
+
* dateFrom: new Date('2023-01-01'),
|
|
982
|
+
* dateTo: new Date('2023-12-31'),
|
|
983
|
+
* });
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
search?(params: IgniterAgentSearchParams): Promise<IgniterAgentSearchResult[]>;
|
|
911
987
|
}
|
|
912
988
|
/**
|
|
913
989
|
* Complete memory configuration for an IgniterAgent.
|
|
@@ -2178,4 +2254,4 @@ declare class IgniterAgentJSONFileAdapter implements IgniterAgentMemoryAdapter<I
|
|
|
2178
2254
|
getStats(): Promise<IgniterAgentAdapterStats>;
|
|
2179
2255
|
}
|
|
2180
2256
|
|
|
2181
|
-
export { type
|
|
2257
|
+
export { type IgniterAgentAdapterFactory as A, type IgniterAgentAdapterBatchResult as B, type IgniterAgentAdapterStats as C, type IgniterAgentMemoryConfig as I, type IgniterAgentMemoryRuntime as a, type IgniterAgentWorkingMemoryParams as b, type IgniterAgentWorkingMemory as c, type IgniterAgentUpdateWorkingMemoryParams as d, type IgniterAgentConversationMessage as e, type IgniterAgentUIMessage as f, type IgniterAgentGetMessagesParams as g, type IgniterAgentChatSession as h, type IgniterAgentGetChatsParams as i, IgniterAgentInMemoryAdapter as j, type IgniterAgentJSONFileAdapterOptions as k, IgniterAgentJSONFileAdapter as l, type IgniterAgentMessageRole as m, type IgniterAgentMemoryScope as n, type IgniterAgentGenerateTitleConfig as o, type IgniterAgentGenerateSuggestionsConfig as p, type IgniterAgentWorkingMemoryConfig as q, type IgniterAgentHistoryConfig as r, type IgniterAgentChatsConfig as s, type IgniterAgentSearchParams as t, type IgniterAgentSearchResult as u, type IgniterAgentMemoryProvider as v, type IgniterAgentAdapterOptions as w, type IgniterAgentInMemoryAdapterOptions as x, type IgniterAgentRedisAdapterOptions as y, type IgniterAgentMemoryAdapter as z };
|