@lov3kaizen/agentsea-core 1.0.0 → 1.1.0
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -3
- package/dist/index.mjs +34 -3
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -374,6 +374,7 @@ declare abstract class Workflow {
|
|
|
374
374
|
constructor(config: WorkflowConfig, provider: LLMProvider, toolRegistry: ToolRegistry, memory?: MemoryStore | undefined);
|
|
375
375
|
private initializeAgents;
|
|
376
376
|
abstract execute(input: string, context: AgentContext): Promise<AgentResponse>;
|
|
377
|
+
protected executeAgent(agent: Agent, input: string, context: AgentContext): Promise<AgentResponse>;
|
|
377
378
|
protected handleError(error: Error, agentName: string, _context: AgentContext): AgentResponse | null;
|
|
378
379
|
protected getAgent(name: string): Agent;
|
|
379
380
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -374,6 +374,7 @@ declare abstract class Workflow {
|
|
|
374
374
|
constructor(config: WorkflowConfig, provider: LLMProvider, toolRegistry: ToolRegistry, memory?: MemoryStore | undefined);
|
|
375
375
|
private initializeAgents;
|
|
376
376
|
abstract execute(input: string, context: AgentContext): Promise<AgentResponse>;
|
|
377
|
+
protected executeAgent(agent: Agent, input: string, context: AgentContext): Promise<AgentResponse>;
|
|
377
378
|
protected handleError(error: Error, agentName: string, _context: AgentContext): AgentResponse | null;
|
|
378
379
|
protected getAgent(name: string): Agent;
|
|
379
380
|
}
|
package/dist/index.js
CHANGED
|
@@ -3536,6 +3536,37 @@ var Workflow = class {
|
|
|
3536
3536
|
this.agents.set(agentConfig.name, agent);
|
|
3537
3537
|
}
|
|
3538
3538
|
}
|
|
3539
|
+
/**
|
|
3540
|
+
* Run a single agent, applying the `retry` error-handling strategy when
|
|
3541
|
+
* configured. On the `retry` strategy the agent is re-invoked up to
|
|
3542
|
+
* `retry.maxAttempts` times (with optional fixed/exponential backoff) before
|
|
3543
|
+
* the final error propagates to {@link handleError}. For every other strategy
|
|
3544
|
+
* the agent runs exactly once and any error propagates unchanged.
|
|
3545
|
+
*/
|
|
3546
|
+
async executeAgent(agent, input, context) {
|
|
3547
|
+
if ((this.config.errorHandling ?? "fail-fast") !== "retry") {
|
|
3548
|
+
return agent.execute(input, context);
|
|
3549
|
+
}
|
|
3550
|
+
const maxAttempts = Math.max(1, this.config.retry?.maxAttempts ?? 3);
|
|
3551
|
+
const initialDelayMs = this.config.retry?.initialDelayMs ?? 0;
|
|
3552
|
+
const maxDelayMs = this.config.retry?.maxDelayMs ?? Infinity;
|
|
3553
|
+
const backoff = this.config.retry?.backoff ?? "exponential";
|
|
3554
|
+
let lastError;
|
|
3555
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
3556
|
+
try {
|
|
3557
|
+
return await agent.execute(input, context);
|
|
3558
|
+
} catch (error) {
|
|
3559
|
+
lastError = error;
|
|
3560
|
+
if (attempt < maxAttempts && initialDelayMs > 0) {
|
|
3561
|
+
const raw = backoff === "linear" ? initialDelayMs * attempt : initialDelayMs * 2 ** (attempt - 1);
|
|
3562
|
+
await new Promise(
|
|
3563
|
+
(resolve) => setTimeout(resolve, Math.min(raw, maxDelayMs))
|
|
3564
|
+
);
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
throw lastError ?? new Error("Agent execution failed after retries");
|
|
3569
|
+
}
|
|
3539
3570
|
/**
|
|
3540
3571
|
* Handle errors based on the configured strategy
|
|
3541
3572
|
*/
|
|
@@ -3585,7 +3616,7 @@ var SequentialWorkflow = class extends Workflow {
|
|
|
3585
3616
|
for (const agentConfig of this.config.agents) {
|
|
3586
3617
|
try {
|
|
3587
3618
|
const agent = this.getAgent(agentConfig.name);
|
|
3588
|
-
const response = await
|
|
3619
|
+
const response = await this.executeAgent(agent, currentInput, context);
|
|
3589
3620
|
totalTokens += response.metadata.tokensUsed;
|
|
3590
3621
|
totalIterations += response.metadata.iterations;
|
|
3591
3622
|
currentInput = response.content;
|
|
@@ -3632,7 +3663,7 @@ var ParallelWorkflow = class extends Workflow {
|
|
|
3632
3663
|
const promises = this.config.agents.map(async (agentConfig) => {
|
|
3633
3664
|
try {
|
|
3634
3665
|
const agent = this.getAgent(agentConfig.name);
|
|
3635
|
-
const response = await
|
|
3666
|
+
const response = await this.executeAgent(agent, input, context);
|
|
3636
3667
|
return {
|
|
3637
3668
|
agentName: agentConfig.name,
|
|
3638
3669
|
response,
|
|
@@ -3701,7 +3732,7 @@ var SupervisorWorkflow = class extends Workflow {
|
|
|
3701
3732
|
routingCount++;
|
|
3702
3733
|
try {
|
|
3703
3734
|
const agent = this.getAgent(currentAgentName);
|
|
3704
|
-
const response = await
|
|
3735
|
+
const response = await this.executeAgent(agent, currentInput, context);
|
|
3705
3736
|
totalTokens += response.metadata.tokensUsed;
|
|
3706
3737
|
totalIterations += response.metadata.iterations;
|
|
3707
3738
|
finalResponse = response;
|
package/dist/index.mjs
CHANGED
|
@@ -3526,6 +3526,37 @@ var Workflow = class {
|
|
|
3526
3526
|
this.agents.set(agentConfig.name, agent);
|
|
3527
3527
|
}
|
|
3528
3528
|
}
|
|
3529
|
+
/**
|
|
3530
|
+
* Run a single agent, applying the `retry` error-handling strategy when
|
|
3531
|
+
* configured. On the `retry` strategy the agent is re-invoked up to
|
|
3532
|
+
* `retry.maxAttempts` times (with optional fixed/exponential backoff) before
|
|
3533
|
+
* the final error propagates to {@link handleError}. For every other strategy
|
|
3534
|
+
* the agent runs exactly once and any error propagates unchanged.
|
|
3535
|
+
*/
|
|
3536
|
+
async executeAgent(agent, input, context) {
|
|
3537
|
+
if ((this.config.errorHandling ?? "fail-fast") !== "retry") {
|
|
3538
|
+
return agent.execute(input, context);
|
|
3539
|
+
}
|
|
3540
|
+
const maxAttempts = Math.max(1, this.config.retry?.maxAttempts ?? 3);
|
|
3541
|
+
const initialDelayMs = this.config.retry?.initialDelayMs ?? 0;
|
|
3542
|
+
const maxDelayMs = this.config.retry?.maxDelayMs ?? Infinity;
|
|
3543
|
+
const backoff = this.config.retry?.backoff ?? "exponential";
|
|
3544
|
+
let lastError;
|
|
3545
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
3546
|
+
try {
|
|
3547
|
+
return await agent.execute(input, context);
|
|
3548
|
+
} catch (error) {
|
|
3549
|
+
lastError = error;
|
|
3550
|
+
if (attempt < maxAttempts && initialDelayMs > 0) {
|
|
3551
|
+
const raw = backoff === "linear" ? initialDelayMs * attempt : initialDelayMs * 2 ** (attempt - 1);
|
|
3552
|
+
await new Promise(
|
|
3553
|
+
(resolve) => setTimeout(resolve, Math.min(raw, maxDelayMs))
|
|
3554
|
+
);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
throw lastError ?? new Error("Agent execution failed after retries");
|
|
3559
|
+
}
|
|
3529
3560
|
/**
|
|
3530
3561
|
* Handle errors based on the configured strategy
|
|
3531
3562
|
*/
|
|
@@ -3575,7 +3606,7 @@ var SequentialWorkflow = class extends Workflow {
|
|
|
3575
3606
|
for (const agentConfig of this.config.agents) {
|
|
3576
3607
|
try {
|
|
3577
3608
|
const agent = this.getAgent(agentConfig.name);
|
|
3578
|
-
const response = await
|
|
3609
|
+
const response = await this.executeAgent(agent, currentInput, context);
|
|
3579
3610
|
totalTokens += response.metadata.tokensUsed;
|
|
3580
3611
|
totalIterations += response.metadata.iterations;
|
|
3581
3612
|
currentInput = response.content;
|
|
@@ -3622,7 +3653,7 @@ var ParallelWorkflow = class extends Workflow {
|
|
|
3622
3653
|
const promises = this.config.agents.map(async (agentConfig) => {
|
|
3623
3654
|
try {
|
|
3624
3655
|
const agent = this.getAgent(agentConfig.name);
|
|
3625
|
-
const response = await
|
|
3656
|
+
const response = await this.executeAgent(agent, input, context);
|
|
3626
3657
|
return {
|
|
3627
3658
|
agentName: agentConfig.name,
|
|
3628
3659
|
response,
|
|
@@ -3691,7 +3722,7 @@ var SupervisorWorkflow = class extends Workflow {
|
|
|
3691
3722
|
routingCount++;
|
|
3692
3723
|
try {
|
|
3693
3724
|
const agent = this.getAgent(currentAgentName);
|
|
3694
|
-
const response = await
|
|
3725
|
+
const response = await this.executeAgent(agent, currentInput, context);
|
|
3695
3726
|
totalTokens += response.metadata.tokensUsed;
|
|
3696
3727
|
totalIterations += response.metadata.iterations;
|
|
3697
3728
|
finalResponse = response;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lov3kaizen/agentsea-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "AgentSea - Unite and orchestrate AI agents. A production-ready ADK for building agentic AI applications with multi-provider support.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"winston": "^3.19.0",
|
|
26
26
|
"ioredis": "^5.11.1",
|
|
27
27
|
"marked": "^12.0.2",
|
|
28
|
-
"@lov3kaizen/agentsea-types": "1.
|
|
28
|
+
"@lov3kaizen/agentsea-types": "1.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.19.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"nodejs"
|
|
73
73
|
],
|
|
74
74
|
"engines": {
|
|
75
|
-
"node": ">=
|
|
75
|
+
"node": ">=20.0.0"
|
|
76
76
|
},
|
|
77
77
|
"author": "lovekaizen",
|
|
78
78
|
"license": "MIT",
|