@autobe/agent 0.7.3 → 0.9.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/lib/AutoBeAgent.d.ts +183 -12
- package/lib/AutoBeAgent.js +249 -65
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +5 -4
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/context/AutoBeContext.d.ts +2 -2
- package/lib/factory/index.d.ts +0 -1
- package/lib/factory/index.js +0 -1
- package/lib/factory/index.js.map +1 -1
- package/lib/index.mjs +1024 -663
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +7 -8
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +2 -5
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +6 -8
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +9 -6
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +3 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +5 -8
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +5 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +3 -6
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js +11 -7
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js +1 -1
- package/lib/orchestrate/prisma/transformPrismaCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js +4 -8
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +2 -2
- package/lib/orchestrate/test/orchestrateTestCorrect.js +90 -60
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestProgress.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestProgress.js +75 -50
- package/lib/orchestrate/test/orchestrateTestProgress.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +617 -208
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +123 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.js.map +1 -0
- package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +2 -1
- package/lib/orchestrate/test/transformTestCorrectHistories.js +14 -10
- package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestProgressHistories.d.ts +7 -1
- package/lib/orchestrate/test/transformTestProgressHistories.js +20 -20
- package/lib/orchestrate/test/transformTestProgressHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestScenarioHistories.d.ts +1 -2
- package/lib/orchestrate/test/transformTestScenarioHistories.js +1 -77
- package/lib/orchestrate/test/transformTestScenarioHistories.js.map +1 -1
- package/lib/structures/IAutoBeConfig.d.ts +48 -10
- package/lib/structures/IAutoBeProps.d.ts +87 -0
- package/lib/structures/IAutoBeVendor.d.ts +64 -22
- package/lib/utils/backoffRetry.d.ts +7 -0
- package/lib/utils/backoffRetry.js +73 -0
- package/lib/utils/backoffRetry.js.map +1 -0
- package/lib/utils/enforceToolCall.d.ts +3 -0
- package/lib/utils/enforceToolCall.js +13 -0
- package/lib/utils/enforceToolCall.js.map +1 -0
- package/lib/utils/types/BackoffOptions.d.ts +12 -0
- package/lib/utils/types/BackoffOptions.js +3 -0
- package/lib/utils/types/BackoffOptions.js.map +1 -0
- package/package.json +5 -5
- package/src/AutoBeAgent.ts +252 -52
- package/src/constants/AutoBeSystemPromptConstant.ts +5 -4
- package/src/context/AutoBeContext.ts +7 -2
- package/src/factory/index.ts +0 -1
- package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +5 -10
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +2 -6
- package/src/orchestrate/interface/orchestrateInterface.ts +1 -1
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +12 -11
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +7 -6
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +2 -1
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +4 -9
- package/src/orchestrate/prisma/orchestratePrisma.ts +1 -0
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +4 -1
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +6 -7
- package/src/orchestrate/prisma/orchestratePrismaSchema.ts +10 -7
- package/src/orchestrate/test/orchestrateTest.ts +6 -13
- package/src/orchestrate/test/orchestrateTestCorrect.ts +127 -78
- package/src/orchestrate/test/orchestrateTestProgress.ts +88 -47
- package/src/orchestrate/test/orchestrateTestScenario.ts +194 -105
- package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +132 -0
- package/src/orchestrate/test/transformTestCorrectHistories.ts +14 -10
- package/src/orchestrate/test/transformTestProgressHistories.ts +25 -22
- package/src/orchestrate/test/transformTestScenarioHistories.ts +0 -79
- package/src/structures/IAutoBeConfig.ts +48 -10
- package/src/structures/IAutoBeProps.ts +91 -0
- package/src/structures/IAutoBeVendor.ts +64 -22
- package/src/utils/backoffRetry.ts +84 -0
- package/src/utils/enforceToolCall.ts +13 -0
- package/src/utils/types/BackoffOptions.ts +15 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { RetryOptions } from "./types/BackoffOptions";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param fn Function to Apply the retry logic.
|
|
5
|
+
* @param maxRetries How many time to try. Max Retry is 5.
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export async function randomBackoffRetry<T>(
|
|
9
|
+
fn: () => Promise<T>,
|
|
10
|
+
options: Partial<RetryOptions> = {},
|
|
11
|
+
): Promise<T> {
|
|
12
|
+
const {
|
|
13
|
+
maxRetries = 5,
|
|
14
|
+
baseDelay = 4_000,
|
|
15
|
+
maxDelay = 60_000,
|
|
16
|
+
jitter = 0.8,
|
|
17
|
+
handleError = isRetryError,
|
|
18
|
+
} = options;
|
|
19
|
+
|
|
20
|
+
let lastError: unknown;
|
|
21
|
+
|
|
22
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
23
|
+
try {
|
|
24
|
+
return await fn();
|
|
25
|
+
} catch (err) {
|
|
26
|
+
lastError = err;
|
|
27
|
+
|
|
28
|
+
if (attempt === maxRetries - 1) throw err;
|
|
29
|
+
|
|
30
|
+
if (!handleError(err)) throw err;
|
|
31
|
+
|
|
32
|
+
const tempDelay = Math.min(baseDelay * 2 ** attempt, maxDelay);
|
|
33
|
+
const delay = tempDelay * (1 + Math.random() * jitter);
|
|
34
|
+
|
|
35
|
+
await new Promise((res) => setTimeout(res, delay));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
throw lastError;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isRetryError(error: any): boolean {
|
|
43
|
+
// 1) Quota exceeded → No retry
|
|
44
|
+
if (
|
|
45
|
+
error?.code === "insufficient_quota" ||
|
|
46
|
+
error?.error?.type === "insufficient_quota"
|
|
47
|
+
) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 2) 5xx / server_error → Retry
|
|
52
|
+
if (
|
|
53
|
+
(typeof error?.status === "number" && error.status >= 500) ||
|
|
54
|
+
error?.error?.type === "server_error"
|
|
55
|
+
) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 3) HTTP 429
|
|
60
|
+
if (error?.status === 429) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 4) undici / network related
|
|
65
|
+
const code = error?.code || error?.cause?.code;
|
|
66
|
+
if (
|
|
67
|
+
[
|
|
68
|
+
"UND_ERR_SOCKET",
|
|
69
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
70
|
+
"ETIMEDOUT",
|
|
71
|
+
"ECONNRESET",
|
|
72
|
+
"EPIPE",
|
|
73
|
+
].includes(code)
|
|
74
|
+
) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 5) fetch abort
|
|
79
|
+
if (error?.message === "terminated" || error?.name === "AbortError") {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MicroAgentica } from "@agentica/core";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
|
|
4
|
+
export function enforceToolCall<Model extends ILlmSchema.Model>(
|
|
5
|
+
agent: MicroAgentica<Model>,
|
|
6
|
+
): MicroAgentica<Model> {
|
|
7
|
+
agent.on("request", (event) => {
|
|
8
|
+
if (event.body.tools) event.body.tool_choice = "required";
|
|
9
|
+
if (event.body.parallel_tool_calls !== undefined)
|
|
10
|
+
delete event.body.parallel_tool_calls;
|
|
11
|
+
});
|
|
12
|
+
return agent;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Random exponential backoff retry utility for handling rate limits
|
|
3
|
+
*/
|
|
4
|
+
export interface RetryOptions {
|
|
5
|
+
/** Maximum number of retry attempts (default: 5) */
|
|
6
|
+
maxRetries: number;
|
|
7
|
+
/** Base delay in milliseconds (default: 2000) */
|
|
8
|
+
baseDelay: number;
|
|
9
|
+
/** Maximum delay in milliseconds (default: 60_000) */
|
|
10
|
+
maxDelay: number;
|
|
11
|
+
/** Jitter factor for randomization (0-1, default: 0.3) */
|
|
12
|
+
jitter: number;
|
|
13
|
+
/** Function to determine if error should trigger retry (default: isRetryError) */
|
|
14
|
+
handleError: (error: any) => boolean;
|
|
15
|
+
}
|