agent-swarm-kit 0.0.1 → 1.0.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Petr Tripolsky
3
+ Copyright (c) 2024 Petr Tripolsky
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1 +1,159 @@
1
- # todo
1
+ # 🐝 agent-swarm-kit
2
+
3
+ > A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems
4
+
5
+ ## Installation
6
+
7
+ In comparison with langchain js this library provide the lightweight API so you can delegate the prompt engineering to other junior developers
8
+
9
+ ```bash
10
+ npm install agent-swarm-kit
11
+ ```
12
+
13
+ ## Code sample
14
+
15
+ ```tsx
16
+ import {
17
+ addAgent,
18
+ addCompletion,
19
+ addSwarm,
20
+ addTool,
21
+ changeAgent,
22
+ execute,
23
+ session,
24
+ } from "agent-swarm-kit";
25
+
26
+ const NAVIGATE_TOOL = addTool({
27
+ toolName: "navigate-tool",
28
+ call: async (clientId, agentName, { to }) => {
29
+ await changeAgent(to, clientId);
30
+ await execute("Navigation complete. Notify the user", clientId);
31
+ },
32
+ validate: async () => true,
33
+ type: "function",
34
+ function: {
35
+ name: "navigate-tool",
36
+ description: "The tool for navigation",
37
+ parameters: {
38
+ type: "object",
39
+ properties: {
40
+ type: "string",
41
+ description: "The target agent for navigation",
42
+ },
43
+ required: ["to"],
44
+ },
45
+ },
46
+ });
47
+
48
+ const ollama = new Ollama({ host: CC_OLLAMA_HOST });
49
+
50
+ const MOCK_COMPLETION = addCompletion({
51
+ completionName: "navigate-completion",
52
+ /**
53
+ * Use whatever you want: NVIDIA NIM, OpenAI, GPT4All, Ollama or LM Studio
54
+ */
55
+ getCompletion: async ({ messages, tools }) => {
56
+ return ollama.chat({
57
+ model: CC_OLLAMA_CHAT_MODEL,
58
+ keep_alive: "1h",
59
+ messages,
60
+ tools,
61
+ })
62
+ },
63
+ });
64
+
65
+ const TRIAGE_AGENT = addAgent({
66
+ agentName: "triage-agent",
67
+ completion: MOCK_COMPLETION,
68
+ prompt: "You are to triage a users request, and call a tool to transfer to the right agent. There are two agents available: `sales-agent` and `refund-agent`",
69
+ tools: [NAVIGATE_TOOL],
70
+ });
71
+
72
+ const SALES_AGENT = addAgent({
73
+ agentName: "sales-agent",
74
+ completion: MOCK_COMPLETION,
75
+ prompt: "You are a sales agent that handles all actions related to placing the order to purchase an item.",
76
+ tools: [NAVIGATE_TOOL],
77
+ });
78
+
79
+ const REDUND_AGENT = addAgent({
80
+ agentName: "refund-agent",
81
+ completion: MOCK_COMPLETION,
82
+ prompt: "You are a refund agent that handles all actions related to refunds after a return has been processed.",
83
+ tools: [NAVIGATE_TOOL],
84
+ });
85
+
86
+ const TEST_SWARM = addSwarm({
87
+ agentList: [TRIAGE_AGENT, SALES_AGENT, REDUND_AGENT],
88
+ defaultAgent: TRIAGE_AGENT,
89
+ swarmName: "navigation-swarm",
90
+ });
91
+
92
+ ...
93
+
94
+
95
+ app.get("/api/v1/session/:clientId", upgradeWebSocket((ctx) => {
96
+ const clientId = ctx.req.param("clientId");
97
+
98
+ const { complete, dispose } = session(clientId, TEST_SWARM)
99
+
100
+ return {
101
+ onMessage(event) {
102
+ const message = event.data.toString();
103
+ incomingSubject.next(await complete(message));
104
+ },
105
+ onClose: () => {
106
+ await dispose();
107
+ },
108
+ }
109
+ }));
110
+
111
+ ```
112
+
113
+ The feature of this library is dependency inversion for agents injection. The agents are being lazy loaded during runtime, so you can declare them in separate modules and connect them to swarm with a string constant
114
+
115
+ ```tsx
116
+
117
+ addTool({
118
+ toolName: "test-tool",
119
+ ...
120
+ })
121
+
122
+ addAgent({
123
+ agentName: "test-agent",
124
+ completion: "openai-completion",
125
+ prompt: "...",
126
+ tools: ["test-tool"],
127
+ });
128
+
129
+ addSwarm({
130
+ agentList: ["test-agent"],
131
+ defaultAgent: "test-agent",
132
+ swarmName: "test-swarm",
133
+ });
134
+
135
+ const { complete, dispose } = session(clientId, "test-swarm")
136
+ ```
137
+
138
+ ## Briefing
139
+
140
+ Agent Swarm Kit lets you build intelligent multi-agent systems where different agents can collaborate, execute tasks, and communicate seamlessly. Think of it like creating a team of specialized AI agents that can work together, share information, validate their actions, and track their interactions - all through a structured TypeScript framework. It's essentially a toolkit for creating complex, coordinated AI workflows where agents can execute commands, commit outputs, and maintain a history of their interactions.
141
+
142
+ **Key Features:**
143
+ - Create and manage complex agent networks
144
+ - Enable agents to execute tasks, communicate, and collaborate
145
+ - Provide robust validation for tools, agents, and sessions
146
+ - Track agent interactions and maintain comprehensive history
147
+ - Support seamless message passing and output tracking
148
+
149
+ **Core Components:**
150
+ - Agent Management: Create, validate, and connect agents
151
+ - Session Handling: Execute commands across agent networks
152
+ - Tool Validation: Ensure agent tools meet system requirements
153
+ - History Tracking: Log and retrieve agent interactions
154
+
155
+ **Use Cases:**
156
+ - AI-powered workflow automation
157
+ - Collaborative problem-solving systems
158
+ - Complex task distribution across specialized agents
159
+ - Intelligent system design with modular agent architecture
package/build/.gitkeep ADDED
File without changes