agent-swarm-kit 1.1.54 → 1.1.56

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 +61 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -346,6 +346,67 @@ Here’s a rundown of the demo projects showcasing `agent-swarm-kit` in action:
346
346
 
347
347
  5. If the agent output do not pass the validation (not existing tool call, tool call with invalid arguments, empty output, XML tags in output or JSON in output by default), the resque algorithm will try to fix the model. At first it will hide the previos messeges from a model, if this will not help, it return a placeholder like `Sorry, I missed that. Could you say it again?`
348
348
 
349
+ ---
350
+
351
+ # ⚡ Multithreading
352
+
353
+ The following example demonstrates how to use a background agent to generate a Bitcoin trading report using a [fork-like mechanism](https://en.wikipedia.org/wiki/Fork_(system_call)), ensuring the process runs independently of the main chat session:
354
+
355
+ ```tsx
356
+ import { inject } from "../../../core/di";
357
+ import { TYPES } from "../../../core/types";
358
+ import { log } from "pinolog";
359
+ import { fork, overrideAgent, scope } from "agent-swarm-kit";
360
+ import { randomString, str, ttl } from "functools-kit";
361
+ import { SwarmName } from "../../../../enum/SwarmName";
362
+ import SwingRangeReportPrivateService from "../private/SwingRangeReportPrivateService";
363
+ import { AgentName } from "../../../../enum/AgentName";
364
+
365
+ const REPORT_TTL = 30 * 60 * 1_000;
366
+
367
+ export class SwingRangeReportPublicService {
368
+ private swingRangeReportPrivateService =
369
+ inject<SwingRangeReportPrivateService>(
370
+ TYPES.swingRangeReportPrivateService
371
+ );
372
+
373
+ public getBtcReport = ttl(
374
+ async () => {
375
+ log("swingRangeReportPublicService getBtcReport");
376
+ return await scope(async () => {
377
+ overrideAgent({
378
+ agentName: AgentName.ReportAgent,
379
+ systemDynamic: async () => str.newline([
380
+ `Current date/time: ${new Date().toISOString()}`,
381
+ "In the report, be sure to write the date of the indicators you refer to.",
382
+ "Give priority to the last relevant indicator in the report",
383
+ ]),
384
+ mcp: [],
385
+ });
386
+ return await fork(
387
+ async (clientId, agentName) => {
388
+ return await this.swingRangeReportPrivateService.getBtcReport(
389
+ clientId,
390
+ agentName
391
+ );
392
+ },
393
+ {
394
+ clientId: `swing-range-report_${randomString()}`,
395
+ swarmName: SwarmName.ReportSwarm,
396
+ }
397
+ );
398
+ });
399
+ },
400
+ {
401
+ timeout: REPORT_TTL,
402
+ }
403
+ );
404
+ }
405
+
406
+ export default SwingRangeReportPublicService;
407
+ ```
408
+
409
+ P.S. [openai threads](https://platform.openai.com/docs/api-reference/threads) doc
349
410
 
350
411
  ---
351
412
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.1.54",
3
+ "version": "1.1.56",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -79,7 +79,7 @@
79
79
  "typescript": "^5.0.0"
80
80
  },
81
81
  "dependencies": {
82
- "di-kit": "^1.0.14",
82
+ "di-kit": "^1.0.15",
83
83
  "di-scoped": "^1.0.20",
84
84
  "functools-kit": "^1.0.82",
85
85
  "get-moment-stamp": "^1.1.1",