@agentforge/patterns 0.16.65 → 0.16.67
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/dist/index.cjs +51 -167
- package/dist/index.d.cts +3 -145
- package/dist/index.d.ts +3 -145
- package/dist/index.js +51 -167
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -2104,210 +2104,94 @@ function createReflectionAgent(config) {
|
|
|
2104
2104
|
}
|
|
2105
2105
|
|
|
2106
2106
|
// src/multi-agent/state.ts
|
|
2107
|
-
var
|
|
2107
|
+
var import_zod13 = require("zod");
|
|
2108
2108
|
var import_core7 = require("@agentforge/core");
|
|
2109
2109
|
|
|
2110
|
-
// src/multi-agent/schemas.ts
|
|
2110
|
+
// src/multi-agent/schemas-message.ts
|
|
2111
2111
|
var import_zod9 = require("zod");
|
|
2112
2112
|
var AgentRoleSchema = import_zod9.z.enum(["supervisor", "worker"]);
|
|
2113
2113
|
var MessageTypeSchema = import_zod9.z.enum([
|
|
2114
2114
|
"user_input",
|
|
2115
|
-
// Initial user message
|
|
2116
2115
|
"task_assignment",
|
|
2117
|
-
// Supervisor assigns task to worker
|
|
2118
2116
|
"task_result",
|
|
2119
|
-
// Worker returns result to supervisor
|
|
2120
2117
|
"handoff",
|
|
2121
|
-
// Worker hands off to another worker
|
|
2122
2118
|
"error",
|
|
2123
|
-
// Error message
|
|
2124
2119
|
"completion"
|
|
2125
|
-
// Final completion message
|
|
2126
2120
|
]);
|
|
2127
2121
|
var AgentMessageSchema = import_zod9.z.object({
|
|
2128
|
-
/**
|
|
2129
|
-
* Unique identifier for the message
|
|
2130
|
-
*/
|
|
2131
2122
|
id: import_zod9.z.string().describe("Unique message identifier"),
|
|
2132
|
-
/**
|
|
2133
|
-
* Type of message
|
|
2134
|
-
*/
|
|
2135
2123
|
type: MessageTypeSchema.describe("Type of message"),
|
|
2136
|
-
/**
|
|
2137
|
-
* Agent that sent the message
|
|
2138
|
-
*/
|
|
2139
2124
|
from: import_zod9.z.string().describe("Agent identifier that sent the message"),
|
|
2140
|
-
/**
|
|
2141
|
-
* Agent(s) that should receive the message
|
|
2142
|
-
*/
|
|
2143
2125
|
to: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.array(import_zod9.z.string())]).describe("Target agent(s)"),
|
|
2144
|
-
/**
|
|
2145
|
-
* Message content
|
|
2146
|
-
*/
|
|
2147
2126
|
content: import_zod9.z.string().describe("Message content"),
|
|
2148
|
-
/**
|
|
2149
|
-
* Optional metadata
|
|
2150
|
-
*/
|
|
2151
2127
|
metadata: JsonObjectSchema.optional().describe("Additional message metadata"),
|
|
2152
|
-
/**
|
|
2153
|
-
* Timestamp when message was created
|
|
2154
|
-
*/
|
|
2155
2128
|
timestamp: import_zod9.z.number().describe("Timestamp when message was created")
|
|
2156
2129
|
});
|
|
2157
|
-
|
|
2130
|
+
|
|
2131
|
+
// src/multi-agent/schemas-routing.ts
|
|
2132
|
+
var import_zod10 = require("zod");
|
|
2133
|
+
var RoutingStrategySchema = import_zod10.z.enum([
|
|
2158
2134
|
"llm-based",
|
|
2159
|
-
// LLM decides which agent to route to
|
|
2160
2135
|
"rule-based",
|
|
2161
|
-
// Predefined rules determine routing
|
|
2162
2136
|
"round-robin",
|
|
2163
|
-
// Distribute tasks evenly across agents
|
|
2164
2137
|
"skill-based",
|
|
2165
|
-
// Route based on agent capabilities
|
|
2166
2138
|
"load-balanced"
|
|
2167
|
-
// Route based on agent workload
|
|
2168
2139
|
]);
|
|
2169
|
-
var RoutingDecisionSchema =
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
targetAgent: import_zod9.z.string().nullable().default(null).describe("Agent to route the task to (single routing)"),
|
|
2175
|
-
/**
|
|
2176
|
-
* Target agents to route to (parallel routing)
|
|
2177
|
-
* When multiple agents are specified, they execute in parallel
|
|
2178
|
-
*/
|
|
2179
|
-
targetAgents: import_zod9.z.array(import_zod9.z.string()).nullable().default(null).describe("Agents to route the task to (parallel routing)"),
|
|
2180
|
-
/**
|
|
2181
|
-
* Reasoning for the routing decision
|
|
2182
|
-
*/
|
|
2183
|
-
reasoning: import_zod9.z.string().default("").describe("Explanation for routing decision"),
|
|
2184
|
-
/**
|
|
2185
|
-
* Confidence in the routing decision (0-1)
|
|
2186
|
-
*/
|
|
2187
|
-
confidence: import_zod9.z.number().min(0).max(1).default(0.8).describe("Confidence score"),
|
|
2188
|
-
/**
|
|
2189
|
-
* Strategy used for routing
|
|
2190
|
-
*/
|
|
2140
|
+
var RoutingDecisionSchema = import_zod10.z.object({
|
|
2141
|
+
targetAgent: import_zod10.z.string().nullable().default(null).describe("Agent to route the task to (single routing)"),
|
|
2142
|
+
targetAgents: import_zod10.z.array(import_zod10.z.string()).nullable().default(null).describe("Agents to route the task to (parallel routing)"),
|
|
2143
|
+
reasoning: import_zod10.z.string().default("").describe("Explanation for routing decision"),
|
|
2144
|
+
confidence: import_zod10.z.number().min(0).max(1).default(0.8).describe("Confidence score"),
|
|
2191
2145
|
strategy: RoutingStrategySchema.default("llm-based").describe("Strategy used for this decision"),
|
|
2192
|
-
|
|
2193
|
-
* Timestamp of the routing decision
|
|
2194
|
-
*/
|
|
2195
|
-
timestamp: import_zod9.z.number().default(() => Date.now()).describe("Timestamp of the decision")
|
|
2146
|
+
timestamp: import_zod10.z.number().default(() => Date.now()).describe("Timestamp of the decision")
|
|
2196
2147
|
}).refine(
|
|
2197
2148
|
(data) => data.targetAgent || data.targetAgents && data.targetAgents.length > 0,
|
|
2198
2149
|
{ message: "Either targetAgent or targetAgents must be provided" }
|
|
2199
2150
|
);
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
skills:
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
tools: import_zod9.z.array(import_zod9.z.string()).describe("List of tool names available to agent"),
|
|
2209
|
-
/**
|
|
2210
|
-
* Whether the agent is currently available
|
|
2211
|
-
*/
|
|
2212
|
-
available: import_zod9.z.boolean().default(true).describe("Whether agent is available"),
|
|
2213
|
-
/**
|
|
2214
|
-
* Current workload (number of active tasks)
|
|
2215
|
-
*/
|
|
2216
|
-
currentWorkload: import_zod9.z.number().int().nonnegative().default(0).describe("Current number of active tasks")
|
|
2151
|
+
|
|
2152
|
+
// src/multi-agent/schemas-worker.ts
|
|
2153
|
+
var import_zod11 = require("zod");
|
|
2154
|
+
var WorkerCapabilitiesSchema = import_zod11.z.object({
|
|
2155
|
+
skills: import_zod11.z.array(import_zod11.z.string()).describe("List of agent skills"),
|
|
2156
|
+
tools: import_zod11.z.array(import_zod11.z.string()).describe("List of tool names available to agent"),
|
|
2157
|
+
available: import_zod11.z.boolean().default(true).describe("Whether agent is available"),
|
|
2158
|
+
currentWorkload: import_zod11.z.number().int().nonnegative().default(0).describe("Current number of active tasks")
|
|
2217
2159
|
});
|
|
2218
|
-
var TaskAssignmentSchema =
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
*/
|
|
2226
|
-
workerId: import_zod9.z.string().describe("Worker identifier assigned to task"),
|
|
2227
|
-
/**
|
|
2228
|
-
* Task description
|
|
2229
|
-
*/
|
|
2230
|
-
task: import_zod9.z.string().describe("Description of the task"),
|
|
2231
|
-
/**
|
|
2232
|
-
* Task priority (1-10, higher is more urgent)
|
|
2233
|
-
*/
|
|
2234
|
-
priority: import_zod9.z.number().int().min(1).max(10).default(5).describe("Task priority"),
|
|
2235
|
-
/**
|
|
2236
|
-
* Timestamp when task was assigned
|
|
2237
|
-
*/
|
|
2238
|
-
assignedAt: import_zod9.z.number().describe("Timestamp when task was assigned"),
|
|
2239
|
-
/**
|
|
2240
|
-
* Optional deadline for task completion
|
|
2241
|
-
*/
|
|
2242
|
-
deadline: import_zod9.z.number().optional().describe("Optional task deadline timestamp")
|
|
2160
|
+
var TaskAssignmentSchema = import_zod11.z.object({
|
|
2161
|
+
id: import_zod11.z.string().describe("Unique assignment identifier"),
|
|
2162
|
+
workerId: import_zod11.z.string().describe("Worker identifier assigned to task"),
|
|
2163
|
+
task: import_zod11.z.string().describe("Description of the task"),
|
|
2164
|
+
priority: import_zod11.z.number().int().min(1).max(10).default(5).describe("Task priority"),
|
|
2165
|
+
assignedAt: import_zod11.z.number().describe("Timestamp when task was assigned"),
|
|
2166
|
+
deadline: import_zod11.z.number().optional().describe("Optional task deadline timestamp")
|
|
2243
2167
|
});
|
|
2244
|
-
var TaskResultSchema =
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
*/
|
|
2252
|
-
workerId: import_zod9.z.string().describe("Worker that completed the task"),
|
|
2253
|
-
/**
|
|
2254
|
-
* Whether the task succeeded
|
|
2255
|
-
*/
|
|
2256
|
-
success: import_zod9.z.boolean().describe("Whether the task succeeded"),
|
|
2257
|
-
/**
|
|
2258
|
-
* Task result/output
|
|
2259
|
-
*/
|
|
2260
|
-
result: import_zod9.z.string().describe("Task result or output"),
|
|
2261
|
-
/**
|
|
2262
|
-
* Optional error message if task failed
|
|
2263
|
-
*/
|
|
2264
|
-
error: import_zod9.z.string().optional().describe("Error message if task failed"),
|
|
2265
|
-
/**
|
|
2266
|
-
* Timestamp when task was completed
|
|
2267
|
-
*/
|
|
2268
|
-
completedAt: import_zod9.z.number().describe("Timestamp when task was completed"),
|
|
2269
|
-
/**
|
|
2270
|
-
* Optional metadata about execution
|
|
2271
|
-
*/
|
|
2168
|
+
var TaskResultSchema = import_zod11.z.object({
|
|
2169
|
+
assignmentId: import_zod11.z.string().describe("Assignment identifier"),
|
|
2170
|
+
workerId: import_zod11.z.string().describe("Worker that completed the task"),
|
|
2171
|
+
success: import_zod11.z.boolean().describe("Whether the task succeeded"),
|
|
2172
|
+
result: import_zod11.z.string().describe("Task result or output"),
|
|
2173
|
+
error: import_zod11.z.string().optional().describe("Error message if task failed"),
|
|
2174
|
+
completedAt: import_zod11.z.number().describe("Timestamp when task was completed"),
|
|
2272
2175
|
metadata: JsonObjectSchema.optional().describe("Execution metadata")
|
|
2273
2176
|
});
|
|
2274
|
-
|
|
2177
|
+
|
|
2178
|
+
// src/multi-agent/schemas-handoff.ts
|
|
2179
|
+
var import_zod12 = require("zod");
|
|
2180
|
+
var MultiAgentStatusSchema = import_zod12.z.enum([
|
|
2275
2181
|
"initializing",
|
|
2276
|
-
// System is initializing
|
|
2277
2182
|
"routing",
|
|
2278
|
-
// Supervisor is routing the task
|
|
2279
2183
|
"executing",
|
|
2280
|
-
// Worker is executing the task
|
|
2281
2184
|
"coordinating",
|
|
2282
|
-
// Multiple workers are coordinating
|
|
2283
2185
|
"aggregating",
|
|
2284
|
-
// Results are being aggregated
|
|
2285
2186
|
"completed",
|
|
2286
|
-
// Task is completed
|
|
2287
2187
|
"failed"
|
|
2288
|
-
// Task failed
|
|
2289
2188
|
]);
|
|
2290
|
-
var HandoffRequestSchema =
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
* Target agent for handoff
|
|
2297
|
-
*/
|
|
2298
|
-
to: import_zod9.z.string().describe("Target agent for handoff"),
|
|
2299
|
-
/**
|
|
2300
|
-
* Reason for handoff
|
|
2301
|
-
*/
|
|
2302
|
-
reason: import_zod9.z.string().describe("Reason for requesting handoff"),
|
|
2303
|
-
/**
|
|
2304
|
-
* Context to pass to next agent
|
|
2305
|
-
*/
|
|
2306
|
-
context: import_zod9.z.unknown().describe("Context to pass to next agent"),
|
|
2307
|
-
/**
|
|
2308
|
-
* Timestamp of handoff request
|
|
2309
|
-
*/
|
|
2310
|
-
timestamp: import_zod9.z.string().datetime().describe("ISO timestamp of handoff request")
|
|
2189
|
+
var HandoffRequestSchema = import_zod12.z.object({
|
|
2190
|
+
from: import_zod12.z.string().describe("Agent requesting handoff"),
|
|
2191
|
+
to: import_zod12.z.string().describe("Target agent for handoff"),
|
|
2192
|
+
reason: import_zod12.z.string().describe("Reason for requesting handoff"),
|
|
2193
|
+
context: import_zod12.z.unknown().describe("Context to pass to next agent"),
|
|
2194
|
+
timestamp: import_zod12.z.string().datetime().describe("ISO timestamp of handoff request")
|
|
2311
2195
|
});
|
|
2312
2196
|
|
|
2313
2197
|
// src/multi-agent/state.ts
|
|
@@ -2321,7 +2205,7 @@ var MultiAgentStateConfig = {
|
|
|
2321
2205
|
* Accumulates all messages between agents
|
|
2322
2206
|
*/
|
|
2323
2207
|
messages: {
|
|
2324
|
-
schema:
|
|
2208
|
+
schema: import_zod13.z.array(AgentMessageSchema),
|
|
2325
2209
|
reducer: (left, right) => [...left, ...right],
|
|
2326
2210
|
default: () => [],
|
|
2327
2211
|
description: "All messages in the multi-agent conversation"
|
|
@@ -2330,7 +2214,7 @@ var MultiAgentStateConfig = {
|
|
|
2330
2214
|
* Available worker agents and their capabilities
|
|
2331
2215
|
*/
|
|
2332
2216
|
workers: {
|
|
2333
|
-
schema:
|
|
2217
|
+
schema: import_zod13.z.record(import_zod13.z.string(), WorkerCapabilitiesSchema),
|
|
2334
2218
|
reducer: (left, right) => ({
|
|
2335
2219
|
...left,
|
|
2336
2220
|
...right
|
|
@@ -2342,7 +2226,7 @@ var MultiAgentStateConfig = {
|
|
|
2342
2226
|
* Current active agent
|
|
2343
2227
|
*/
|
|
2344
2228
|
currentAgent: {
|
|
2345
|
-
schema:
|
|
2229
|
+
schema: import_zod13.z.string().optional(),
|
|
2346
2230
|
description: "Identifier of the currently active agent"
|
|
2347
2231
|
},
|
|
2348
2232
|
/**
|
|
@@ -2350,7 +2234,7 @@ var MultiAgentStateConfig = {
|
|
|
2350
2234
|
* Accumulates all routing decisions
|
|
2351
2235
|
*/
|
|
2352
2236
|
routingHistory: {
|
|
2353
|
-
schema:
|
|
2237
|
+
schema: import_zod13.z.array(RoutingDecisionSchema),
|
|
2354
2238
|
reducer: (left, right) => [...left, ...right],
|
|
2355
2239
|
default: () => [],
|
|
2356
2240
|
description: "History of routing decisions"
|
|
@@ -2359,7 +2243,7 @@ var MultiAgentStateConfig = {
|
|
|
2359
2243
|
* Active task assignments
|
|
2360
2244
|
*/
|
|
2361
2245
|
activeAssignments: {
|
|
2362
|
-
schema:
|
|
2246
|
+
schema: import_zod13.z.array(TaskAssignmentSchema),
|
|
2363
2247
|
reducer: (left, right) => [...left, ...right],
|
|
2364
2248
|
default: () => [],
|
|
2365
2249
|
description: "Currently active task assignments"
|
|
@@ -2369,7 +2253,7 @@ var MultiAgentStateConfig = {
|
|
|
2369
2253
|
* Accumulates all completed tasks
|
|
2370
2254
|
*/
|
|
2371
2255
|
completedTasks: {
|
|
2372
|
-
schema:
|
|
2256
|
+
schema: import_zod13.z.array(TaskResultSchema),
|
|
2373
2257
|
reducer: (left, right) => [...left, ...right],
|
|
2374
2258
|
default: () => [],
|
|
2375
2259
|
description: "Completed task results"
|
|
@@ -2379,7 +2263,7 @@ var MultiAgentStateConfig = {
|
|
|
2379
2263
|
* Accumulates all handoff requests
|
|
2380
2264
|
*/
|
|
2381
2265
|
handoffs: {
|
|
2382
|
-
schema:
|
|
2266
|
+
schema: import_zod13.z.array(HandoffRequestSchema),
|
|
2383
2267
|
reducer: (left, right) => [...left, ...right],
|
|
2384
2268
|
default: () => [],
|
|
2385
2269
|
description: "Handoff requests between agents"
|
package/dist/index.d.cts
CHANGED
|
@@ -2379,47 +2379,17 @@ declare function createReflectionAgent(config: ReflectionAgentConfig): _langchai
|
|
|
2379
2379
|
finisher: Partial<ReflectionStateType>;
|
|
2380
2380
|
}, unknown, unknown>;
|
|
2381
2381
|
|
|
2382
|
-
/**
|
|
2383
|
-
* Schema for agent roles in the system
|
|
2384
|
-
*/
|
|
2385
2382
|
declare const AgentRoleSchema: z.ZodEnum<["supervisor", "worker"]>;
|
|
2386
2383
|
type AgentRole = z.infer<typeof AgentRoleSchema>;
|
|
2387
|
-
/**
|
|
2388
|
-
* Schema for message types in multi-agent communication
|
|
2389
|
-
*/
|
|
2390
2384
|
declare const MessageTypeSchema: z.ZodEnum<["user_input", "task_assignment", "task_result", "handoff", "error", "completion"]>;
|
|
2391
2385
|
type MessageType = z.infer<typeof MessageTypeSchema>;
|
|
2392
|
-
/**
|
|
2393
|
-
* Schema for a message in the multi-agent system
|
|
2394
|
-
*/
|
|
2395
2386
|
declare const AgentMessageSchema: z.ZodObject<{
|
|
2396
|
-
/**
|
|
2397
|
-
* Unique identifier for the message
|
|
2398
|
-
*/
|
|
2399
2387
|
id: z.ZodString;
|
|
2400
|
-
/**
|
|
2401
|
-
* Type of message
|
|
2402
|
-
*/
|
|
2403
2388
|
type: z.ZodEnum<["user_input", "task_assignment", "task_result", "handoff", "error", "completion"]>;
|
|
2404
|
-
/**
|
|
2405
|
-
* Agent that sent the message
|
|
2406
|
-
*/
|
|
2407
2389
|
from: z.ZodString;
|
|
2408
|
-
/**
|
|
2409
|
-
* Agent(s) that should receive the message
|
|
2410
|
-
*/
|
|
2411
2390
|
to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
2412
|
-
/**
|
|
2413
|
-
* Message content
|
|
2414
|
-
*/
|
|
2415
2391
|
content: z.ZodString;
|
|
2416
|
-
/**
|
|
2417
|
-
* Optional metadata
|
|
2418
|
-
*/
|
|
2419
2392
|
metadata: z.ZodOptional<z.ZodType<_agentforge_core.JsonObject, z.ZodTypeDef, _agentforge_core.JsonObject>>;
|
|
2420
|
-
/**
|
|
2421
|
-
* Timestamp when message was created
|
|
2422
|
-
*/
|
|
2423
2393
|
timestamp: z.ZodNumber;
|
|
2424
2394
|
}, "strip", z.ZodTypeAny, {
|
|
2425
2395
|
type: "error" | "user_input" | "task_assignment" | "task_result" | "handoff" | "completion";
|
|
@@ -2439,48 +2409,15 @@ declare const AgentMessageSchema: z.ZodObject<{
|
|
|
2439
2409
|
metadata?: _agentforge_core.JsonObject | undefined;
|
|
2440
2410
|
}>;
|
|
2441
2411
|
type AgentMessage = z.infer<typeof AgentMessageSchema>;
|
|
2442
|
-
|
|
2443
|
-
* Schema for routing strategies
|
|
2444
|
-
*/
|
|
2412
|
+
|
|
2445
2413
|
declare const RoutingStrategySchema: z.ZodEnum<["llm-based", "rule-based", "round-robin", "skill-based", "load-balanced"]>;
|
|
2446
2414
|
type RoutingStrategy = z.infer<typeof RoutingStrategySchema>;
|
|
2447
|
-
/**
|
|
2448
|
-
* Schema for routing decision
|
|
2449
|
-
*
|
|
2450
|
-
* Supports both single-agent and parallel multi-agent routing:
|
|
2451
|
-
* - Single: Use `targetAgent` field
|
|
2452
|
-
* - Parallel: Use `targetAgents` array field
|
|
2453
|
-
*
|
|
2454
|
-
* If both are provided, `targetAgents` takes precedence.
|
|
2455
|
-
*
|
|
2456
|
-
* Note: Uses .nullable() instead of .optional() for OpenAI structured output compatibility
|
|
2457
|
-
*/
|
|
2458
2415
|
declare const RoutingDecisionSchema: z.ZodEffects<z.ZodObject<{
|
|
2459
|
-
/**
|
|
2460
|
-
* Target agent to route to (single agent routing)
|
|
2461
|
-
* @deprecated Use targetAgents for parallel routing support
|
|
2462
|
-
*/
|
|
2463
2416
|
targetAgent: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2464
|
-
/**
|
|
2465
|
-
* Target agents to route to (parallel routing)
|
|
2466
|
-
* When multiple agents are specified, they execute in parallel
|
|
2467
|
-
*/
|
|
2468
2417
|
targetAgents: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
2469
|
-
/**
|
|
2470
|
-
* Reasoning for the routing decision
|
|
2471
|
-
*/
|
|
2472
2418
|
reasoning: z.ZodDefault<z.ZodString>;
|
|
2473
|
-
/**
|
|
2474
|
-
* Confidence in the routing decision (0-1)
|
|
2475
|
-
*/
|
|
2476
2419
|
confidence: z.ZodDefault<z.ZodNumber>;
|
|
2477
|
-
/**
|
|
2478
|
-
* Strategy used for routing
|
|
2479
|
-
*/
|
|
2480
2420
|
strategy: z.ZodDefault<z.ZodEnum<["llm-based", "rule-based", "round-robin", "skill-based", "load-balanced"]>>;
|
|
2481
|
-
/**
|
|
2482
|
-
* Timestamp of the routing decision
|
|
2483
|
-
*/
|
|
2484
2421
|
timestamp: z.ZodDefault<z.ZodNumber>;
|
|
2485
2422
|
}, "strip", z.ZodTypeAny, {
|
|
2486
2423
|
timestamp: number;
|
|
@@ -2512,25 +2449,11 @@ declare const RoutingDecisionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2512
2449
|
strategy?: "llm-based" | "rule-based" | "round-robin" | "skill-based" | "load-balanced" | undefined;
|
|
2513
2450
|
}>;
|
|
2514
2451
|
type RoutingDecision = z.infer<typeof RoutingDecisionSchema>;
|
|
2515
|
-
|
|
2516
|
-
* Schema for worker agent capabilities
|
|
2517
|
-
*/
|
|
2452
|
+
|
|
2518
2453
|
declare const WorkerCapabilitiesSchema: z.ZodObject<{
|
|
2519
|
-
/**
|
|
2520
|
-
* Skills/capabilities the agent has
|
|
2521
|
-
*/
|
|
2522
2454
|
skills: z.ZodArray<z.ZodString, "many">;
|
|
2523
|
-
/**
|
|
2524
|
-
* Tools available to the agent
|
|
2525
|
-
*/
|
|
2526
2455
|
tools: z.ZodArray<z.ZodString, "many">;
|
|
2527
|
-
/**
|
|
2528
|
-
* Whether the agent is currently available
|
|
2529
|
-
*/
|
|
2530
2456
|
available: z.ZodDefault<z.ZodBoolean>;
|
|
2531
|
-
/**
|
|
2532
|
-
* Current workload (number of active tasks)
|
|
2533
|
-
*/
|
|
2534
2457
|
currentWorkload: z.ZodDefault<z.ZodNumber>;
|
|
2535
2458
|
}, "strip", z.ZodTypeAny, {
|
|
2536
2459
|
tools: string[];
|
|
@@ -2544,33 +2467,12 @@ declare const WorkerCapabilitiesSchema: z.ZodObject<{
|
|
|
2544
2467
|
currentWorkload?: number | undefined;
|
|
2545
2468
|
}>;
|
|
2546
2469
|
type WorkerCapabilities = z.infer<typeof WorkerCapabilitiesSchema>;
|
|
2547
|
-
/**
|
|
2548
|
-
* Schema for task assignment
|
|
2549
|
-
*/
|
|
2550
2470
|
declare const TaskAssignmentSchema: z.ZodObject<{
|
|
2551
|
-
/**
|
|
2552
|
-
* Unique assignment identifier
|
|
2553
|
-
*/
|
|
2554
2471
|
id: z.ZodString;
|
|
2555
|
-
/**
|
|
2556
|
-
* Worker ID assigned to the task
|
|
2557
|
-
*/
|
|
2558
2472
|
workerId: z.ZodString;
|
|
2559
|
-
/**
|
|
2560
|
-
* Task description
|
|
2561
|
-
*/
|
|
2562
2473
|
task: z.ZodString;
|
|
2563
|
-
/**
|
|
2564
|
-
* Task priority (1-10, higher is more urgent)
|
|
2565
|
-
*/
|
|
2566
2474
|
priority: z.ZodDefault<z.ZodNumber>;
|
|
2567
|
-
/**
|
|
2568
|
-
* Timestamp when task was assigned
|
|
2569
|
-
*/
|
|
2570
2475
|
assignedAt: z.ZodNumber;
|
|
2571
|
-
/**
|
|
2572
|
-
* Optional deadline for task completion
|
|
2573
|
-
*/
|
|
2574
2476
|
deadline: z.ZodOptional<z.ZodNumber>;
|
|
2575
2477
|
}, "strip", z.ZodTypeAny, {
|
|
2576
2478
|
id: string;
|
|
@@ -2588,37 +2490,13 @@ declare const TaskAssignmentSchema: z.ZodObject<{
|
|
|
2588
2490
|
deadline?: number | undefined;
|
|
2589
2491
|
}>;
|
|
2590
2492
|
type TaskAssignment = z.infer<typeof TaskAssignmentSchema>;
|
|
2591
|
-
/**
|
|
2592
|
-
* Schema for task result
|
|
2593
|
-
*/
|
|
2594
2493
|
declare const TaskResultSchema: z.ZodObject<{
|
|
2595
|
-
/**
|
|
2596
|
-
* Assignment identifier
|
|
2597
|
-
*/
|
|
2598
2494
|
assignmentId: z.ZodString;
|
|
2599
|
-
/**
|
|
2600
|
-
* Worker that completed the task
|
|
2601
|
-
*/
|
|
2602
2495
|
workerId: z.ZodString;
|
|
2603
|
-
/**
|
|
2604
|
-
* Whether the task succeeded
|
|
2605
|
-
*/
|
|
2606
2496
|
success: z.ZodBoolean;
|
|
2607
|
-
/**
|
|
2608
|
-
* Task result/output
|
|
2609
|
-
*/
|
|
2610
2497
|
result: z.ZodString;
|
|
2611
|
-
/**
|
|
2612
|
-
* Optional error message if task failed
|
|
2613
|
-
*/
|
|
2614
2498
|
error: z.ZodOptional<z.ZodString>;
|
|
2615
|
-
/**
|
|
2616
|
-
* Timestamp when task was completed
|
|
2617
|
-
*/
|
|
2618
2499
|
completedAt: z.ZodNumber;
|
|
2619
|
-
/**
|
|
2620
|
-
* Optional metadata about execution
|
|
2621
|
-
*/
|
|
2622
2500
|
metadata: z.ZodOptional<z.ZodType<_agentforge_core.JsonObject, z.ZodTypeDef, _agentforge_core.JsonObject>>;
|
|
2623
2501
|
}, "strip", z.ZodTypeAny, {
|
|
2624
2502
|
result: string;
|
|
@@ -2638,34 +2516,14 @@ declare const TaskResultSchema: z.ZodObject<{
|
|
|
2638
2516
|
error?: string | undefined;
|
|
2639
2517
|
}>;
|
|
2640
2518
|
type TaskResult = z.infer<typeof TaskResultSchema>;
|
|
2641
|
-
|
|
2642
|
-
* Schema for multi-agent execution status
|
|
2643
|
-
*/
|
|
2519
|
+
|
|
2644
2520
|
declare const MultiAgentStatusSchema: z.ZodEnum<["initializing", "routing", "executing", "coordinating", "aggregating", "completed", "failed"]>;
|
|
2645
2521
|
type MultiAgentStatus = z.infer<typeof MultiAgentStatusSchema>;
|
|
2646
|
-
/**
|
|
2647
|
-
* Schema for handoff request
|
|
2648
|
-
*/
|
|
2649
2522
|
declare const HandoffRequestSchema: z.ZodObject<{
|
|
2650
|
-
/**
|
|
2651
|
-
* Agent requesting the handoff
|
|
2652
|
-
*/
|
|
2653
2523
|
from: z.ZodString;
|
|
2654
|
-
/**
|
|
2655
|
-
* Target agent for handoff
|
|
2656
|
-
*/
|
|
2657
2524
|
to: z.ZodString;
|
|
2658
|
-
/**
|
|
2659
|
-
* Reason for handoff
|
|
2660
|
-
*/
|
|
2661
2525
|
reason: z.ZodString;
|
|
2662
|
-
/**
|
|
2663
|
-
* Context to pass to next agent
|
|
2664
|
-
*/
|
|
2665
2526
|
context: z.ZodUnknown;
|
|
2666
|
-
/**
|
|
2667
|
-
* Timestamp of handoff request
|
|
2668
|
-
*/
|
|
2669
2527
|
timestamp: z.ZodString;
|
|
2670
2528
|
}, "strip", z.ZodTypeAny, {
|
|
2671
2529
|
timestamp: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2379,47 +2379,17 @@ declare function createReflectionAgent(config: ReflectionAgentConfig): _langchai
|
|
|
2379
2379
|
finisher: Partial<ReflectionStateType>;
|
|
2380
2380
|
}, unknown, unknown>;
|
|
2381
2381
|
|
|
2382
|
-
/**
|
|
2383
|
-
* Schema for agent roles in the system
|
|
2384
|
-
*/
|
|
2385
2382
|
declare const AgentRoleSchema: z.ZodEnum<["supervisor", "worker"]>;
|
|
2386
2383
|
type AgentRole = z.infer<typeof AgentRoleSchema>;
|
|
2387
|
-
/**
|
|
2388
|
-
* Schema for message types in multi-agent communication
|
|
2389
|
-
*/
|
|
2390
2384
|
declare const MessageTypeSchema: z.ZodEnum<["user_input", "task_assignment", "task_result", "handoff", "error", "completion"]>;
|
|
2391
2385
|
type MessageType = z.infer<typeof MessageTypeSchema>;
|
|
2392
|
-
/**
|
|
2393
|
-
* Schema for a message in the multi-agent system
|
|
2394
|
-
*/
|
|
2395
2386
|
declare const AgentMessageSchema: z.ZodObject<{
|
|
2396
|
-
/**
|
|
2397
|
-
* Unique identifier for the message
|
|
2398
|
-
*/
|
|
2399
2387
|
id: z.ZodString;
|
|
2400
|
-
/**
|
|
2401
|
-
* Type of message
|
|
2402
|
-
*/
|
|
2403
2388
|
type: z.ZodEnum<["user_input", "task_assignment", "task_result", "handoff", "error", "completion"]>;
|
|
2404
|
-
/**
|
|
2405
|
-
* Agent that sent the message
|
|
2406
|
-
*/
|
|
2407
2389
|
from: z.ZodString;
|
|
2408
|
-
/**
|
|
2409
|
-
* Agent(s) that should receive the message
|
|
2410
|
-
*/
|
|
2411
2390
|
to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
2412
|
-
/**
|
|
2413
|
-
* Message content
|
|
2414
|
-
*/
|
|
2415
2391
|
content: z.ZodString;
|
|
2416
|
-
/**
|
|
2417
|
-
* Optional metadata
|
|
2418
|
-
*/
|
|
2419
2392
|
metadata: z.ZodOptional<z.ZodType<_agentforge_core.JsonObject, z.ZodTypeDef, _agentforge_core.JsonObject>>;
|
|
2420
|
-
/**
|
|
2421
|
-
* Timestamp when message was created
|
|
2422
|
-
*/
|
|
2423
2393
|
timestamp: z.ZodNumber;
|
|
2424
2394
|
}, "strip", z.ZodTypeAny, {
|
|
2425
2395
|
type: "error" | "user_input" | "task_assignment" | "task_result" | "handoff" | "completion";
|
|
@@ -2439,48 +2409,15 @@ declare const AgentMessageSchema: z.ZodObject<{
|
|
|
2439
2409
|
metadata?: _agentforge_core.JsonObject | undefined;
|
|
2440
2410
|
}>;
|
|
2441
2411
|
type AgentMessage = z.infer<typeof AgentMessageSchema>;
|
|
2442
|
-
|
|
2443
|
-
* Schema for routing strategies
|
|
2444
|
-
*/
|
|
2412
|
+
|
|
2445
2413
|
declare const RoutingStrategySchema: z.ZodEnum<["llm-based", "rule-based", "round-robin", "skill-based", "load-balanced"]>;
|
|
2446
2414
|
type RoutingStrategy = z.infer<typeof RoutingStrategySchema>;
|
|
2447
|
-
/**
|
|
2448
|
-
* Schema for routing decision
|
|
2449
|
-
*
|
|
2450
|
-
* Supports both single-agent and parallel multi-agent routing:
|
|
2451
|
-
* - Single: Use `targetAgent` field
|
|
2452
|
-
* - Parallel: Use `targetAgents` array field
|
|
2453
|
-
*
|
|
2454
|
-
* If both are provided, `targetAgents` takes precedence.
|
|
2455
|
-
*
|
|
2456
|
-
* Note: Uses .nullable() instead of .optional() for OpenAI structured output compatibility
|
|
2457
|
-
*/
|
|
2458
2415
|
declare const RoutingDecisionSchema: z.ZodEffects<z.ZodObject<{
|
|
2459
|
-
/**
|
|
2460
|
-
* Target agent to route to (single agent routing)
|
|
2461
|
-
* @deprecated Use targetAgents for parallel routing support
|
|
2462
|
-
*/
|
|
2463
2416
|
targetAgent: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2464
|
-
/**
|
|
2465
|
-
* Target agents to route to (parallel routing)
|
|
2466
|
-
* When multiple agents are specified, they execute in parallel
|
|
2467
|
-
*/
|
|
2468
2417
|
targetAgents: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
2469
|
-
/**
|
|
2470
|
-
* Reasoning for the routing decision
|
|
2471
|
-
*/
|
|
2472
2418
|
reasoning: z.ZodDefault<z.ZodString>;
|
|
2473
|
-
/**
|
|
2474
|
-
* Confidence in the routing decision (0-1)
|
|
2475
|
-
*/
|
|
2476
2419
|
confidence: z.ZodDefault<z.ZodNumber>;
|
|
2477
|
-
/**
|
|
2478
|
-
* Strategy used for routing
|
|
2479
|
-
*/
|
|
2480
2420
|
strategy: z.ZodDefault<z.ZodEnum<["llm-based", "rule-based", "round-robin", "skill-based", "load-balanced"]>>;
|
|
2481
|
-
/**
|
|
2482
|
-
* Timestamp of the routing decision
|
|
2483
|
-
*/
|
|
2484
2421
|
timestamp: z.ZodDefault<z.ZodNumber>;
|
|
2485
2422
|
}, "strip", z.ZodTypeAny, {
|
|
2486
2423
|
timestamp: number;
|
|
@@ -2512,25 +2449,11 @@ declare const RoutingDecisionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2512
2449
|
strategy?: "llm-based" | "rule-based" | "round-robin" | "skill-based" | "load-balanced" | undefined;
|
|
2513
2450
|
}>;
|
|
2514
2451
|
type RoutingDecision = z.infer<typeof RoutingDecisionSchema>;
|
|
2515
|
-
|
|
2516
|
-
* Schema for worker agent capabilities
|
|
2517
|
-
*/
|
|
2452
|
+
|
|
2518
2453
|
declare const WorkerCapabilitiesSchema: z.ZodObject<{
|
|
2519
|
-
/**
|
|
2520
|
-
* Skills/capabilities the agent has
|
|
2521
|
-
*/
|
|
2522
2454
|
skills: z.ZodArray<z.ZodString, "many">;
|
|
2523
|
-
/**
|
|
2524
|
-
* Tools available to the agent
|
|
2525
|
-
*/
|
|
2526
2455
|
tools: z.ZodArray<z.ZodString, "many">;
|
|
2527
|
-
/**
|
|
2528
|
-
* Whether the agent is currently available
|
|
2529
|
-
*/
|
|
2530
2456
|
available: z.ZodDefault<z.ZodBoolean>;
|
|
2531
|
-
/**
|
|
2532
|
-
* Current workload (number of active tasks)
|
|
2533
|
-
*/
|
|
2534
2457
|
currentWorkload: z.ZodDefault<z.ZodNumber>;
|
|
2535
2458
|
}, "strip", z.ZodTypeAny, {
|
|
2536
2459
|
tools: string[];
|
|
@@ -2544,33 +2467,12 @@ declare const WorkerCapabilitiesSchema: z.ZodObject<{
|
|
|
2544
2467
|
currentWorkload?: number | undefined;
|
|
2545
2468
|
}>;
|
|
2546
2469
|
type WorkerCapabilities = z.infer<typeof WorkerCapabilitiesSchema>;
|
|
2547
|
-
/**
|
|
2548
|
-
* Schema for task assignment
|
|
2549
|
-
*/
|
|
2550
2470
|
declare const TaskAssignmentSchema: z.ZodObject<{
|
|
2551
|
-
/**
|
|
2552
|
-
* Unique assignment identifier
|
|
2553
|
-
*/
|
|
2554
2471
|
id: z.ZodString;
|
|
2555
|
-
/**
|
|
2556
|
-
* Worker ID assigned to the task
|
|
2557
|
-
*/
|
|
2558
2472
|
workerId: z.ZodString;
|
|
2559
|
-
/**
|
|
2560
|
-
* Task description
|
|
2561
|
-
*/
|
|
2562
2473
|
task: z.ZodString;
|
|
2563
|
-
/**
|
|
2564
|
-
* Task priority (1-10, higher is more urgent)
|
|
2565
|
-
*/
|
|
2566
2474
|
priority: z.ZodDefault<z.ZodNumber>;
|
|
2567
|
-
/**
|
|
2568
|
-
* Timestamp when task was assigned
|
|
2569
|
-
*/
|
|
2570
2475
|
assignedAt: z.ZodNumber;
|
|
2571
|
-
/**
|
|
2572
|
-
* Optional deadline for task completion
|
|
2573
|
-
*/
|
|
2574
2476
|
deadline: z.ZodOptional<z.ZodNumber>;
|
|
2575
2477
|
}, "strip", z.ZodTypeAny, {
|
|
2576
2478
|
id: string;
|
|
@@ -2588,37 +2490,13 @@ declare const TaskAssignmentSchema: z.ZodObject<{
|
|
|
2588
2490
|
deadline?: number | undefined;
|
|
2589
2491
|
}>;
|
|
2590
2492
|
type TaskAssignment = z.infer<typeof TaskAssignmentSchema>;
|
|
2591
|
-
/**
|
|
2592
|
-
* Schema for task result
|
|
2593
|
-
*/
|
|
2594
2493
|
declare const TaskResultSchema: z.ZodObject<{
|
|
2595
|
-
/**
|
|
2596
|
-
* Assignment identifier
|
|
2597
|
-
*/
|
|
2598
2494
|
assignmentId: z.ZodString;
|
|
2599
|
-
/**
|
|
2600
|
-
* Worker that completed the task
|
|
2601
|
-
*/
|
|
2602
2495
|
workerId: z.ZodString;
|
|
2603
|
-
/**
|
|
2604
|
-
* Whether the task succeeded
|
|
2605
|
-
*/
|
|
2606
2496
|
success: z.ZodBoolean;
|
|
2607
|
-
/**
|
|
2608
|
-
* Task result/output
|
|
2609
|
-
*/
|
|
2610
2497
|
result: z.ZodString;
|
|
2611
|
-
/**
|
|
2612
|
-
* Optional error message if task failed
|
|
2613
|
-
*/
|
|
2614
2498
|
error: z.ZodOptional<z.ZodString>;
|
|
2615
|
-
/**
|
|
2616
|
-
* Timestamp when task was completed
|
|
2617
|
-
*/
|
|
2618
2499
|
completedAt: z.ZodNumber;
|
|
2619
|
-
/**
|
|
2620
|
-
* Optional metadata about execution
|
|
2621
|
-
*/
|
|
2622
2500
|
metadata: z.ZodOptional<z.ZodType<_agentforge_core.JsonObject, z.ZodTypeDef, _agentforge_core.JsonObject>>;
|
|
2623
2501
|
}, "strip", z.ZodTypeAny, {
|
|
2624
2502
|
result: string;
|
|
@@ -2638,34 +2516,14 @@ declare const TaskResultSchema: z.ZodObject<{
|
|
|
2638
2516
|
error?: string | undefined;
|
|
2639
2517
|
}>;
|
|
2640
2518
|
type TaskResult = z.infer<typeof TaskResultSchema>;
|
|
2641
|
-
|
|
2642
|
-
* Schema for multi-agent execution status
|
|
2643
|
-
*/
|
|
2519
|
+
|
|
2644
2520
|
declare const MultiAgentStatusSchema: z.ZodEnum<["initializing", "routing", "executing", "coordinating", "aggregating", "completed", "failed"]>;
|
|
2645
2521
|
type MultiAgentStatus = z.infer<typeof MultiAgentStatusSchema>;
|
|
2646
|
-
/**
|
|
2647
|
-
* Schema for handoff request
|
|
2648
|
-
*/
|
|
2649
2522
|
declare const HandoffRequestSchema: z.ZodObject<{
|
|
2650
|
-
/**
|
|
2651
|
-
* Agent requesting the handoff
|
|
2652
|
-
*/
|
|
2653
2523
|
from: z.ZodString;
|
|
2654
|
-
/**
|
|
2655
|
-
* Target agent for handoff
|
|
2656
|
-
*/
|
|
2657
2524
|
to: z.ZodString;
|
|
2658
|
-
/**
|
|
2659
|
-
* Reason for handoff
|
|
2660
|
-
*/
|
|
2661
2525
|
reason: z.ZodString;
|
|
2662
|
-
/**
|
|
2663
|
-
* Context to pass to next agent
|
|
2664
|
-
*/
|
|
2665
2526
|
context: z.ZodUnknown;
|
|
2666
|
-
/**
|
|
2667
|
-
* Timestamp of handoff request
|
|
2668
|
-
*/
|
|
2669
2527
|
timestamp: z.ZodString;
|
|
2670
2528
|
}, "strip", z.ZodTypeAny, {
|
|
2671
2529
|
timestamp: string;
|
package/dist/index.js
CHANGED
|
@@ -2006,210 +2006,94 @@ function createReflectionAgent(config) {
|
|
|
2006
2006
|
}
|
|
2007
2007
|
|
|
2008
2008
|
// src/multi-agent/state.ts
|
|
2009
|
-
import { z as
|
|
2009
|
+
import { z as z13 } from "zod";
|
|
2010
2010
|
import { createStateAnnotation as createStateAnnotation4 } from "@agentforge/core";
|
|
2011
2011
|
|
|
2012
|
-
// src/multi-agent/schemas.ts
|
|
2012
|
+
// src/multi-agent/schemas-message.ts
|
|
2013
2013
|
import { z as z9 } from "zod";
|
|
2014
2014
|
var AgentRoleSchema = z9.enum(["supervisor", "worker"]);
|
|
2015
2015
|
var MessageTypeSchema = z9.enum([
|
|
2016
2016
|
"user_input",
|
|
2017
|
-
// Initial user message
|
|
2018
2017
|
"task_assignment",
|
|
2019
|
-
// Supervisor assigns task to worker
|
|
2020
2018
|
"task_result",
|
|
2021
|
-
// Worker returns result to supervisor
|
|
2022
2019
|
"handoff",
|
|
2023
|
-
// Worker hands off to another worker
|
|
2024
2020
|
"error",
|
|
2025
|
-
// Error message
|
|
2026
2021
|
"completion"
|
|
2027
|
-
// Final completion message
|
|
2028
2022
|
]);
|
|
2029
2023
|
var AgentMessageSchema = z9.object({
|
|
2030
|
-
/**
|
|
2031
|
-
* Unique identifier for the message
|
|
2032
|
-
*/
|
|
2033
2024
|
id: z9.string().describe("Unique message identifier"),
|
|
2034
|
-
/**
|
|
2035
|
-
* Type of message
|
|
2036
|
-
*/
|
|
2037
2025
|
type: MessageTypeSchema.describe("Type of message"),
|
|
2038
|
-
/**
|
|
2039
|
-
* Agent that sent the message
|
|
2040
|
-
*/
|
|
2041
2026
|
from: z9.string().describe("Agent identifier that sent the message"),
|
|
2042
|
-
/**
|
|
2043
|
-
* Agent(s) that should receive the message
|
|
2044
|
-
*/
|
|
2045
2027
|
to: z9.union([z9.string(), z9.array(z9.string())]).describe("Target agent(s)"),
|
|
2046
|
-
/**
|
|
2047
|
-
* Message content
|
|
2048
|
-
*/
|
|
2049
2028
|
content: z9.string().describe("Message content"),
|
|
2050
|
-
/**
|
|
2051
|
-
* Optional metadata
|
|
2052
|
-
*/
|
|
2053
2029
|
metadata: JsonObjectSchema.optional().describe("Additional message metadata"),
|
|
2054
|
-
/**
|
|
2055
|
-
* Timestamp when message was created
|
|
2056
|
-
*/
|
|
2057
2030
|
timestamp: z9.number().describe("Timestamp when message was created")
|
|
2058
2031
|
});
|
|
2059
|
-
|
|
2032
|
+
|
|
2033
|
+
// src/multi-agent/schemas-routing.ts
|
|
2034
|
+
import { z as z10 } from "zod";
|
|
2035
|
+
var RoutingStrategySchema = z10.enum([
|
|
2060
2036
|
"llm-based",
|
|
2061
|
-
// LLM decides which agent to route to
|
|
2062
2037
|
"rule-based",
|
|
2063
|
-
// Predefined rules determine routing
|
|
2064
2038
|
"round-robin",
|
|
2065
|
-
// Distribute tasks evenly across agents
|
|
2066
2039
|
"skill-based",
|
|
2067
|
-
// Route based on agent capabilities
|
|
2068
2040
|
"load-balanced"
|
|
2069
|
-
// Route based on agent workload
|
|
2070
2041
|
]);
|
|
2071
|
-
var RoutingDecisionSchema =
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
targetAgent: z9.string().nullable().default(null).describe("Agent to route the task to (single routing)"),
|
|
2077
|
-
/**
|
|
2078
|
-
* Target agents to route to (parallel routing)
|
|
2079
|
-
* When multiple agents are specified, they execute in parallel
|
|
2080
|
-
*/
|
|
2081
|
-
targetAgents: z9.array(z9.string()).nullable().default(null).describe("Agents to route the task to (parallel routing)"),
|
|
2082
|
-
/**
|
|
2083
|
-
* Reasoning for the routing decision
|
|
2084
|
-
*/
|
|
2085
|
-
reasoning: z9.string().default("").describe("Explanation for routing decision"),
|
|
2086
|
-
/**
|
|
2087
|
-
* Confidence in the routing decision (0-1)
|
|
2088
|
-
*/
|
|
2089
|
-
confidence: z9.number().min(0).max(1).default(0.8).describe("Confidence score"),
|
|
2090
|
-
/**
|
|
2091
|
-
* Strategy used for routing
|
|
2092
|
-
*/
|
|
2042
|
+
var RoutingDecisionSchema = z10.object({
|
|
2043
|
+
targetAgent: z10.string().nullable().default(null).describe("Agent to route the task to (single routing)"),
|
|
2044
|
+
targetAgents: z10.array(z10.string()).nullable().default(null).describe("Agents to route the task to (parallel routing)"),
|
|
2045
|
+
reasoning: z10.string().default("").describe("Explanation for routing decision"),
|
|
2046
|
+
confidence: z10.number().min(0).max(1).default(0.8).describe("Confidence score"),
|
|
2093
2047
|
strategy: RoutingStrategySchema.default("llm-based").describe("Strategy used for this decision"),
|
|
2094
|
-
|
|
2095
|
-
* Timestamp of the routing decision
|
|
2096
|
-
*/
|
|
2097
|
-
timestamp: z9.number().default(() => Date.now()).describe("Timestamp of the decision")
|
|
2048
|
+
timestamp: z10.number().default(() => Date.now()).describe("Timestamp of the decision")
|
|
2098
2049
|
}).refine(
|
|
2099
2050
|
(data) => data.targetAgent || data.targetAgents && data.targetAgents.length > 0,
|
|
2100
2051
|
{ message: "Either targetAgent or targetAgents must be provided" }
|
|
2101
2052
|
);
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
skills:
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
tools: z9.array(z9.string()).describe("List of tool names available to agent"),
|
|
2111
|
-
/**
|
|
2112
|
-
* Whether the agent is currently available
|
|
2113
|
-
*/
|
|
2114
|
-
available: z9.boolean().default(true).describe("Whether agent is available"),
|
|
2115
|
-
/**
|
|
2116
|
-
* Current workload (number of active tasks)
|
|
2117
|
-
*/
|
|
2118
|
-
currentWorkload: z9.number().int().nonnegative().default(0).describe("Current number of active tasks")
|
|
2053
|
+
|
|
2054
|
+
// src/multi-agent/schemas-worker.ts
|
|
2055
|
+
import { z as z11 } from "zod";
|
|
2056
|
+
var WorkerCapabilitiesSchema = z11.object({
|
|
2057
|
+
skills: z11.array(z11.string()).describe("List of agent skills"),
|
|
2058
|
+
tools: z11.array(z11.string()).describe("List of tool names available to agent"),
|
|
2059
|
+
available: z11.boolean().default(true).describe("Whether agent is available"),
|
|
2060
|
+
currentWorkload: z11.number().int().nonnegative().default(0).describe("Current number of active tasks")
|
|
2119
2061
|
});
|
|
2120
|
-
var TaskAssignmentSchema =
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
*/
|
|
2128
|
-
workerId: z9.string().describe("Worker identifier assigned to task"),
|
|
2129
|
-
/**
|
|
2130
|
-
* Task description
|
|
2131
|
-
*/
|
|
2132
|
-
task: z9.string().describe("Description of the task"),
|
|
2133
|
-
/**
|
|
2134
|
-
* Task priority (1-10, higher is more urgent)
|
|
2135
|
-
*/
|
|
2136
|
-
priority: z9.number().int().min(1).max(10).default(5).describe("Task priority"),
|
|
2137
|
-
/**
|
|
2138
|
-
* Timestamp when task was assigned
|
|
2139
|
-
*/
|
|
2140
|
-
assignedAt: z9.number().describe("Timestamp when task was assigned"),
|
|
2141
|
-
/**
|
|
2142
|
-
* Optional deadline for task completion
|
|
2143
|
-
*/
|
|
2144
|
-
deadline: z9.number().optional().describe("Optional task deadline timestamp")
|
|
2062
|
+
var TaskAssignmentSchema = z11.object({
|
|
2063
|
+
id: z11.string().describe("Unique assignment identifier"),
|
|
2064
|
+
workerId: z11.string().describe("Worker identifier assigned to task"),
|
|
2065
|
+
task: z11.string().describe("Description of the task"),
|
|
2066
|
+
priority: z11.number().int().min(1).max(10).default(5).describe("Task priority"),
|
|
2067
|
+
assignedAt: z11.number().describe("Timestamp when task was assigned"),
|
|
2068
|
+
deadline: z11.number().optional().describe("Optional task deadline timestamp")
|
|
2145
2069
|
});
|
|
2146
|
-
var TaskResultSchema =
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
*/
|
|
2154
|
-
workerId: z9.string().describe("Worker that completed the task"),
|
|
2155
|
-
/**
|
|
2156
|
-
* Whether the task succeeded
|
|
2157
|
-
*/
|
|
2158
|
-
success: z9.boolean().describe("Whether the task succeeded"),
|
|
2159
|
-
/**
|
|
2160
|
-
* Task result/output
|
|
2161
|
-
*/
|
|
2162
|
-
result: z9.string().describe("Task result or output"),
|
|
2163
|
-
/**
|
|
2164
|
-
* Optional error message if task failed
|
|
2165
|
-
*/
|
|
2166
|
-
error: z9.string().optional().describe("Error message if task failed"),
|
|
2167
|
-
/**
|
|
2168
|
-
* Timestamp when task was completed
|
|
2169
|
-
*/
|
|
2170
|
-
completedAt: z9.number().describe("Timestamp when task was completed"),
|
|
2171
|
-
/**
|
|
2172
|
-
* Optional metadata about execution
|
|
2173
|
-
*/
|
|
2070
|
+
var TaskResultSchema = z11.object({
|
|
2071
|
+
assignmentId: z11.string().describe("Assignment identifier"),
|
|
2072
|
+
workerId: z11.string().describe("Worker that completed the task"),
|
|
2073
|
+
success: z11.boolean().describe("Whether the task succeeded"),
|
|
2074
|
+
result: z11.string().describe("Task result or output"),
|
|
2075
|
+
error: z11.string().optional().describe("Error message if task failed"),
|
|
2076
|
+
completedAt: z11.number().describe("Timestamp when task was completed"),
|
|
2174
2077
|
metadata: JsonObjectSchema.optional().describe("Execution metadata")
|
|
2175
2078
|
});
|
|
2176
|
-
|
|
2079
|
+
|
|
2080
|
+
// src/multi-agent/schemas-handoff.ts
|
|
2081
|
+
import { z as z12 } from "zod";
|
|
2082
|
+
var MultiAgentStatusSchema = z12.enum([
|
|
2177
2083
|
"initializing",
|
|
2178
|
-
// System is initializing
|
|
2179
2084
|
"routing",
|
|
2180
|
-
// Supervisor is routing the task
|
|
2181
2085
|
"executing",
|
|
2182
|
-
// Worker is executing the task
|
|
2183
2086
|
"coordinating",
|
|
2184
|
-
// Multiple workers are coordinating
|
|
2185
2087
|
"aggregating",
|
|
2186
|
-
// Results are being aggregated
|
|
2187
2088
|
"completed",
|
|
2188
|
-
// Task is completed
|
|
2189
2089
|
"failed"
|
|
2190
|
-
// Task failed
|
|
2191
2090
|
]);
|
|
2192
|
-
var HandoffRequestSchema =
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
* Target agent for handoff
|
|
2199
|
-
*/
|
|
2200
|
-
to: z9.string().describe("Target agent for handoff"),
|
|
2201
|
-
/**
|
|
2202
|
-
* Reason for handoff
|
|
2203
|
-
*/
|
|
2204
|
-
reason: z9.string().describe("Reason for requesting handoff"),
|
|
2205
|
-
/**
|
|
2206
|
-
* Context to pass to next agent
|
|
2207
|
-
*/
|
|
2208
|
-
context: z9.unknown().describe("Context to pass to next agent"),
|
|
2209
|
-
/**
|
|
2210
|
-
* Timestamp of handoff request
|
|
2211
|
-
*/
|
|
2212
|
-
timestamp: z9.string().datetime().describe("ISO timestamp of handoff request")
|
|
2091
|
+
var HandoffRequestSchema = z12.object({
|
|
2092
|
+
from: z12.string().describe("Agent requesting handoff"),
|
|
2093
|
+
to: z12.string().describe("Target agent for handoff"),
|
|
2094
|
+
reason: z12.string().describe("Reason for requesting handoff"),
|
|
2095
|
+
context: z12.unknown().describe("Context to pass to next agent"),
|
|
2096
|
+
timestamp: z12.string().datetime().describe("ISO timestamp of handoff request")
|
|
2213
2097
|
});
|
|
2214
2098
|
|
|
2215
2099
|
// src/multi-agent/state.ts
|
|
@@ -2223,7 +2107,7 @@ var MultiAgentStateConfig = {
|
|
|
2223
2107
|
* Accumulates all messages between agents
|
|
2224
2108
|
*/
|
|
2225
2109
|
messages: {
|
|
2226
|
-
schema:
|
|
2110
|
+
schema: z13.array(AgentMessageSchema),
|
|
2227
2111
|
reducer: (left, right) => [...left, ...right],
|
|
2228
2112
|
default: () => [],
|
|
2229
2113
|
description: "All messages in the multi-agent conversation"
|
|
@@ -2232,7 +2116,7 @@ var MultiAgentStateConfig = {
|
|
|
2232
2116
|
* Available worker agents and their capabilities
|
|
2233
2117
|
*/
|
|
2234
2118
|
workers: {
|
|
2235
|
-
schema:
|
|
2119
|
+
schema: z13.record(z13.string(), WorkerCapabilitiesSchema),
|
|
2236
2120
|
reducer: (left, right) => ({
|
|
2237
2121
|
...left,
|
|
2238
2122
|
...right
|
|
@@ -2244,7 +2128,7 @@ var MultiAgentStateConfig = {
|
|
|
2244
2128
|
* Current active agent
|
|
2245
2129
|
*/
|
|
2246
2130
|
currentAgent: {
|
|
2247
|
-
schema:
|
|
2131
|
+
schema: z13.string().optional(),
|
|
2248
2132
|
description: "Identifier of the currently active agent"
|
|
2249
2133
|
},
|
|
2250
2134
|
/**
|
|
@@ -2252,7 +2136,7 @@ var MultiAgentStateConfig = {
|
|
|
2252
2136
|
* Accumulates all routing decisions
|
|
2253
2137
|
*/
|
|
2254
2138
|
routingHistory: {
|
|
2255
|
-
schema:
|
|
2139
|
+
schema: z13.array(RoutingDecisionSchema),
|
|
2256
2140
|
reducer: (left, right) => [...left, ...right],
|
|
2257
2141
|
default: () => [],
|
|
2258
2142
|
description: "History of routing decisions"
|
|
@@ -2261,7 +2145,7 @@ var MultiAgentStateConfig = {
|
|
|
2261
2145
|
* Active task assignments
|
|
2262
2146
|
*/
|
|
2263
2147
|
activeAssignments: {
|
|
2264
|
-
schema:
|
|
2148
|
+
schema: z13.array(TaskAssignmentSchema),
|
|
2265
2149
|
reducer: (left, right) => [...left, ...right],
|
|
2266
2150
|
default: () => [],
|
|
2267
2151
|
description: "Currently active task assignments"
|
|
@@ -2271,7 +2155,7 @@ var MultiAgentStateConfig = {
|
|
|
2271
2155
|
* Accumulates all completed tasks
|
|
2272
2156
|
*/
|
|
2273
2157
|
completedTasks: {
|
|
2274
|
-
schema:
|
|
2158
|
+
schema: z13.array(TaskResultSchema),
|
|
2275
2159
|
reducer: (left, right) => [...left, ...right],
|
|
2276
2160
|
default: () => [],
|
|
2277
2161
|
description: "Completed task results"
|
|
@@ -2281,7 +2165,7 @@ var MultiAgentStateConfig = {
|
|
|
2281
2165
|
* Accumulates all handoff requests
|
|
2282
2166
|
*/
|
|
2283
2167
|
handoffs: {
|
|
2284
|
-
schema:
|
|
2168
|
+
schema: z13.array(HandoffRequestSchema),
|
|
2285
2169
|
reducer: (left, right) => [...left, ...right],
|
|
2286
2170
|
default: () => [],
|
|
2287
2171
|
description: "Handoff requests between agents"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentforge/patterns",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.67",
|
|
4
4
|
"description": "Production-ready agent workflow patterns for TypeScript including ReAct and Planner-Executor, built on LangGraph.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"url": "https://github.com/TVScoundrel/agentforge/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@agentforge/core": "0.16.
|
|
44
|
+
"@agentforge/core": "0.16.67",
|
|
45
45
|
"@langchain/core": "^1.1.17",
|
|
46
46
|
"@langchain/langgraph": "^1.1.2",
|
|
47
47
|
"zod": "^3.23.8"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@agentforge/testing": "0.16.
|
|
50
|
+
"@agentforge/testing": "0.16.67",
|
|
51
51
|
"@eslint/js": "^9.17.0",
|
|
52
52
|
"@types/node": "^22.10.2",
|
|
53
53
|
"eslint": "^9.17.0",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
62
62
|
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
63
|
-
"test": "vitest",
|
|
64
|
-
"test:coverage": "vitest --coverage",
|
|
63
|
+
"test": "pnpm --dir ../.. exec vitest --config packages/patterns/vitest.config.ts",
|
|
64
|
+
"test:coverage": "pnpm --dir ../.. exec vitest --config packages/patterns/vitest.config.ts --coverage",
|
|
65
65
|
"typecheck": "tsc -p tsconfig.typecheck.json --noEmit",
|
|
66
66
|
"lint": "eslint src",
|
|
67
67
|
"lint:fix": "eslint src --fix",
|