opencode-swarm-plugin 0.12.7 → 0.12.8
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.js +17 -1
- package/dist/plugin.js +17 -1
- package/package.json +1 -1
- package/src/agent-mail.ts +27 -6
package/dist/index.js
CHANGED
|
@@ -22931,6 +22931,7 @@ async function mcpCallOnce(toolName, args) {
|
|
|
22931
22931
|
}
|
|
22932
22932
|
async function mcpCall(toolName, args) {
|
|
22933
22933
|
let lastError = null;
|
|
22934
|
+
let restartAttempted = false;
|
|
22934
22935
|
for (let attempt = 0;attempt <= RETRY_CONFIG.maxRetries; attempt++) {
|
|
22935
22936
|
if (attempt > 0) {
|
|
22936
22937
|
const delay = calculateBackoffDelay(attempt);
|
|
@@ -22943,13 +22944,28 @@ async function mcpCall(toolName, args) {
|
|
|
22943
22944
|
return result;
|
|
22944
22945
|
} catch (error45) {
|
|
22945
22946
|
lastError = error45 instanceof Error ? error45 : new Error(String(error45));
|
|
22947
|
+
const errorMessage = lastError.message.toLowerCase();
|
|
22946
22948
|
consecutiveFailures++;
|
|
22947
22949
|
const retryable = isRetryableError(error45);
|
|
22948
|
-
|
|
22950
|
+
const isUnexpectedError = errorMessage.includes("unexpected error");
|
|
22951
|
+
if (isUnexpectedError && !restartAttempted && RECOVERY_CONFIG.enabled) {
|
|
22952
|
+
console.warn(`[agent-mail] "${toolName}" got unexpected error, restarting server immediately...`);
|
|
22953
|
+
restartAttempted = true;
|
|
22954
|
+
const restarted = await restartServer();
|
|
22955
|
+
if (restarted) {
|
|
22956
|
+
agentMailAvailable = null;
|
|
22957
|
+
consecutiveFailures = 0;
|
|
22958
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
22959
|
+
attempt--;
|
|
22960
|
+
continue;
|
|
22961
|
+
}
|
|
22962
|
+
}
|
|
22963
|
+
if (!isUnexpectedError && consecutiveFailures >= RECOVERY_CONFIG.failureThreshold && RECOVERY_CONFIG.enabled && !restartAttempted) {
|
|
22949
22964
|
console.warn(`[agent-mail] ${consecutiveFailures} consecutive failures, checking server health...`);
|
|
22950
22965
|
const healthy = await isServerFunctional();
|
|
22951
22966
|
if (!healthy) {
|
|
22952
22967
|
console.warn("[agent-mail] Server unhealthy, attempting restart...");
|
|
22968
|
+
restartAttempted = true;
|
|
22953
22969
|
const restarted = await restartServer();
|
|
22954
22970
|
if (restarted) {
|
|
22955
22971
|
agentMailAvailable = null;
|
package/dist/plugin.js
CHANGED
|
@@ -22905,6 +22905,7 @@ async function mcpCallOnce(toolName, args) {
|
|
|
22905
22905
|
}
|
|
22906
22906
|
async function mcpCall(toolName, args) {
|
|
22907
22907
|
let lastError = null;
|
|
22908
|
+
let restartAttempted = false;
|
|
22908
22909
|
for (let attempt = 0;attempt <= RETRY_CONFIG.maxRetries; attempt++) {
|
|
22909
22910
|
if (attempt > 0) {
|
|
22910
22911
|
const delay = calculateBackoffDelay(attempt);
|
|
@@ -22917,13 +22918,28 @@ async function mcpCall(toolName, args) {
|
|
|
22917
22918
|
return result;
|
|
22918
22919
|
} catch (error45) {
|
|
22919
22920
|
lastError = error45 instanceof Error ? error45 : new Error(String(error45));
|
|
22921
|
+
const errorMessage = lastError.message.toLowerCase();
|
|
22920
22922
|
consecutiveFailures++;
|
|
22921
22923
|
const retryable = isRetryableError(error45);
|
|
22922
|
-
|
|
22924
|
+
const isUnexpectedError = errorMessage.includes("unexpected error");
|
|
22925
|
+
if (isUnexpectedError && !restartAttempted && RECOVERY_CONFIG.enabled) {
|
|
22926
|
+
console.warn(`[agent-mail] "${toolName}" got unexpected error, restarting server immediately...`);
|
|
22927
|
+
restartAttempted = true;
|
|
22928
|
+
const restarted = await restartServer();
|
|
22929
|
+
if (restarted) {
|
|
22930
|
+
agentMailAvailable = null;
|
|
22931
|
+
consecutiveFailures = 0;
|
|
22932
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
22933
|
+
attempt--;
|
|
22934
|
+
continue;
|
|
22935
|
+
}
|
|
22936
|
+
}
|
|
22937
|
+
if (!isUnexpectedError && consecutiveFailures >= RECOVERY_CONFIG.failureThreshold && RECOVERY_CONFIG.enabled && !restartAttempted) {
|
|
22923
22938
|
console.warn(`[agent-mail] ${consecutiveFailures} consecutive failures, checking server health...`);
|
|
22924
22939
|
const healthy = await isServerFunctional();
|
|
22925
22940
|
if (!healthy) {
|
|
22926
22941
|
console.warn("[agent-mail] Server unhealthy, attempting restart...");
|
|
22942
|
+
restartAttempted = true;
|
|
22927
22943
|
const restarted = await restartServer();
|
|
22928
22944
|
if (restarted) {
|
|
22929
22945
|
agentMailAvailable = null;
|
package/package.json
CHANGED
package/src/agent-mail.ts
CHANGED
|
@@ -704,6 +704,7 @@ export async function mcpCall<T>(
|
|
|
704
704
|
args: Record<string, unknown>,
|
|
705
705
|
): Promise<T> {
|
|
706
706
|
let lastError: Error | null = null;
|
|
707
|
+
let restartAttempted = false;
|
|
707
708
|
|
|
708
709
|
for (let attempt = 0; attempt <= RETRY_CONFIG.maxRetries; attempt++) {
|
|
709
710
|
// Apply backoff delay (except first attempt)
|
|
@@ -723,17 +724,39 @@ export async function mcpCall<T>(
|
|
|
723
724
|
return result;
|
|
724
725
|
} catch (error) {
|
|
725
726
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
727
|
+
const errorMessage = lastError.message.toLowerCase();
|
|
726
728
|
|
|
727
729
|
// Track consecutive failures
|
|
728
730
|
consecutiveFailures++;
|
|
729
731
|
|
|
730
|
-
// Check if error is retryable
|
|
732
|
+
// Check if error is retryable
|
|
731
733
|
const retryable = isRetryableError(error);
|
|
732
734
|
|
|
733
|
-
//
|
|
735
|
+
// AGGRESSIVE: If it's an "unexpected error", restart immediately (once per call)
|
|
736
|
+
const isUnexpectedError = errorMessage.includes("unexpected error");
|
|
737
|
+
if (isUnexpectedError && !restartAttempted && RECOVERY_CONFIG.enabled) {
|
|
738
|
+
console.warn(
|
|
739
|
+
`[agent-mail] "${toolName}" got unexpected error, restarting server immediately...`,
|
|
740
|
+
);
|
|
741
|
+
restartAttempted = true;
|
|
742
|
+
const restarted = await restartServer();
|
|
743
|
+
if (restarted) {
|
|
744
|
+
agentMailAvailable = null;
|
|
745
|
+
consecutiveFailures = 0;
|
|
746
|
+
// Small delay to let server stabilize
|
|
747
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
748
|
+
// Don't count this attempt - retry immediately
|
|
749
|
+
attempt--;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// Standard retry logic for other retryable errors
|
|
734
755
|
if (
|
|
756
|
+
!isUnexpectedError &&
|
|
735
757
|
consecutiveFailures >= RECOVERY_CONFIG.failureThreshold &&
|
|
736
|
-
RECOVERY_CONFIG.enabled
|
|
758
|
+
RECOVERY_CONFIG.enabled &&
|
|
759
|
+
!restartAttempted
|
|
737
760
|
) {
|
|
738
761
|
console.warn(
|
|
739
762
|
`[agent-mail] ${consecutiveFailures} consecutive failures, checking server health...`,
|
|
@@ -742,13 +765,11 @@ export async function mcpCall<T>(
|
|
|
742
765
|
const healthy = await isServerFunctional();
|
|
743
766
|
if (!healthy) {
|
|
744
767
|
console.warn("[agent-mail] Server unhealthy, attempting restart...");
|
|
768
|
+
restartAttempted = true;
|
|
745
769
|
const restarted = await restartServer();
|
|
746
770
|
if (restarted) {
|
|
747
|
-
// Reset availability cache since server restarted
|
|
748
771
|
agentMailAvailable = null;
|
|
749
|
-
// Only retry if the error was retryable in the first place
|
|
750
772
|
if (retryable) {
|
|
751
|
-
// Don't count this attempt against retries - try again
|
|
752
773
|
attempt--;
|
|
753
774
|
continue;
|
|
754
775
|
}
|