@inkeep/agents-core 0.58.14 → 0.58.15
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/auth/auth-schema.d.ts +85 -85
- package/dist/auth/auth-validation-schemas.d.ts +135 -135
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/auth.js +17 -45
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/data-access/index.d.ts +4 -1
- package/dist/data-access/index.js +4 -1
- package/dist/data-access/manage/agentFull.js +28 -12
- package/dist/data-access/manage/agents.d.ts +25 -24
- package/dist/data-access/manage/agents.js +33 -33
- package/dist/data-access/manage/artifactComponents.d.ts +14 -14
- package/dist/data-access/manage/artifactComponents.js +14 -13
- package/dist/data-access/manage/audit-queries.js +6 -5
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/contextConfigs.js +7 -6
- package/dist/data-access/manage/credentialReferences.js +12 -11
- package/dist/data-access/manage/dataComponents.d.ts +8 -8
- package/dist/data-access/manage/dataComponents.js +13 -11
- package/dist/data-access/manage/evalConfig.js +42 -41
- package/dist/data-access/manage/externalAgents.js +8 -7
- package/dist/data-access/manage/functionTools.d.ts +19 -23
- package/dist/data-access/manage/functionTools.js +27 -65
- package/dist/data-access/manage/functions.js +7 -10
- package/dist/data-access/manage/projects.js +37 -36
- package/dist/data-access/manage/scheduledTriggers.js +10 -6
- package/dist/data-access/manage/scheduledWorkflows.js +3 -2
- package/dist/data-access/manage/scope-helpers.d.ts +2 -1
- package/dist/data-access/manage/scope-helpers.js +2 -1
- package/dist/data-access/manage/skills.d.ts +17 -17
- package/dist/data-access/manage/skills.js +14 -9
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +34 -34
- package/dist/data-access/manage/subAgentRelations.js +28 -26
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentTeamAgentRelations.js +16 -16
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/subAgents.js +8 -7
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/tools.js +8 -6
- package/dist/data-access/manage/triggers.js +12 -8
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apiKeys.js +16 -12
- package/dist/data-access/runtime/apps.d.ts +8 -8
- package/dist/data-access/runtime/apps.js +8 -7
- package/dist/data-access/runtime/audit-queries.js +7 -7
- package/dist/data-access/runtime/auth.d.ts +18 -0
- package/dist/data-access/runtime/auth.js +35 -0
- package/dist/data-access/runtime/cascade-delete.js +29 -24
- package/dist/data-access/runtime/contextCache.d.ts +1 -0
- package/dist/data-access/runtime/contextCache.js +9 -8
- package/dist/data-access/runtime/conversations.d.ts +31 -31
- package/dist/data-access/runtime/conversations.js +8 -12
- package/dist/data-access/runtime/evalRuns.js +23 -22
- package/dist/data-access/runtime/github-work-app-installations.js +32 -21
- package/dist/data-access/runtime/ledgerArtifacts.js +9 -24
- package/dist/data-access/runtime/messages.d.ts +24 -24
- package/dist/data-access/runtime/messages.js +9 -8
- package/dist/data-access/runtime/projects.js +6 -5
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +16 -26
- package/dist/data-access/runtime/slack-work-app-mcp.js +6 -5
- package/dist/data-access/runtime/tasks.d.ts +12 -8
- package/dist/data-access/runtime/tasks.js +4 -5
- package/dist/data-access/runtime/triggerInvocations.js +4 -8
- package/dist/data-access/runtime/workAppSlack.js +21 -14
- package/dist/db/manage/manage-schema.d.ts +449 -449
- package/dist/db/runtime/runtime-schema.d.ts +332 -332
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -1
- package/dist/retry/index.d.ts +3 -0
- package/dist/retry/index.js +4 -0
- package/dist/retry/retryable-errors.d.ts +10 -0
- package/dist/retry/retryable-errors.js +72 -0
- package/dist/retry/withRetry.d.ts +15 -0
- package/dist/retry/withRetry.js +37 -0
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/schemas.d.ts +412 -412
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/retry/retryable-errors.ts
|
|
2
|
+
const TIER_1_ALWAYS_RETRY = new Set(["40001", "40P01"]);
|
|
3
|
+
const TIER_2_CONNECTION = new Set([
|
|
4
|
+
"08000",
|
|
5
|
+
"08003",
|
|
6
|
+
"08006",
|
|
7
|
+
"08001",
|
|
8
|
+
"08004",
|
|
9
|
+
"57P01",
|
|
10
|
+
"57P03"
|
|
11
|
+
]);
|
|
12
|
+
const TIER_3_RESOURCE = new Set([
|
|
13
|
+
"53000",
|
|
14
|
+
"53100",
|
|
15
|
+
"53200",
|
|
16
|
+
"53300",
|
|
17
|
+
"55P03",
|
|
18
|
+
"57014"
|
|
19
|
+
]);
|
|
20
|
+
const DEFAULT_RETRYABLE_CODES = new Set([
|
|
21
|
+
...TIER_1_ALWAYS_RETRY,
|
|
22
|
+
...TIER_2_CONNECTION,
|
|
23
|
+
...TIER_3_RESOURCE
|
|
24
|
+
]);
|
|
25
|
+
const RETRYABLE_NODE_ERROR_CODES = new Set([
|
|
26
|
+
"ECONNREFUSED",
|
|
27
|
+
"ECONNRESET",
|
|
28
|
+
"EPIPE",
|
|
29
|
+
"ETIMEDOUT",
|
|
30
|
+
"EHOSTUNREACH",
|
|
31
|
+
"ENETUNREACH",
|
|
32
|
+
"EAI_AGAIN"
|
|
33
|
+
]);
|
|
34
|
+
const RETRYABLE_POOL_MESSAGES = [
|
|
35
|
+
"timeout exceeded when trying to connect",
|
|
36
|
+
"Connection terminated due to connection timeout",
|
|
37
|
+
"Connection terminated unexpectedly"
|
|
38
|
+
];
|
|
39
|
+
const NON_RETRYABLE_POOL_MESSAGES = ["Cannot use a pool after calling end on the pool"];
|
|
40
|
+
const SQLSTATE_PATTERN = /^[0-9A-Z]{5}$/;
|
|
41
|
+
function getPostgresErrorCode(error) {
|
|
42
|
+
if (!error || typeof error !== "object") return void 0;
|
|
43
|
+
const err = error;
|
|
44
|
+
if (err.cause?.code && typeof err.cause.code === "string" && SQLSTATE_PATTERN.test(err.cause.code)) return err.cause.code;
|
|
45
|
+
if (err.code && typeof err.code === "string" && SQLSTATE_PATTERN.test(err.code)) return err.code;
|
|
46
|
+
}
|
|
47
|
+
function isRetryableError(error, retryableCodes = DEFAULT_RETRYABLE_CODES) {
|
|
48
|
+
if (!error || typeof error !== "object") return false;
|
|
49
|
+
const err = error;
|
|
50
|
+
const sqlstate = getPostgresErrorCode(error);
|
|
51
|
+
if (sqlstate && retryableCodes.has(sqlstate)) return true;
|
|
52
|
+
const nodeCode = err.code ?? err.cause?.code;
|
|
53
|
+
if (typeof nodeCode === "string" && RETRYABLE_NODE_ERROR_CODES.has(nodeCode)) return true;
|
|
54
|
+
const messages = [err.message, err.cause?.message].filter((m) => typeof m === "string");
|
|
55
|
+
for (const message of messages) {
|
|
56
|
+
if (NON_RETRYABLE_POOL_MESSAGES.some((m) => message.includes(m))) return false;
|
|
57
|
+
if (RETRYABLE_POOL_MESSAGES.some((m) => message.includes(m))) return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function isForeignKeyViolation(error) {
|
|
62
|
+
return getPostgresErrorCode(error) === "23503";
|
|
63
|
+
}
|
|
64
|
+
function isSerializationError(error) {
|
|
65
|
+
if (!error || typeof error !== "object") return false;
|
|
66
|
+
const err = error;
|
|
67
|
+
const code = err?.cause?.code ?? err?.code;
|
|
68
|
+
return code === "40001" || code === "40P01" || code === "XX000";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { DEFAULT_RETRYABLE_CODES, RETRYABLE_NODE_ERROR_CODES, RETRYABLE_POOL_MESSAGES, getPostgresErrorCode, isForeignKeyViolation, isRetryableError, isSerializationError };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/retry/withRetry.d.ts
|
|
2
|
+
interface RetryOptions {
|
|
3
|
+
maxRetries?: number;
|
|
4
|
+
baseDelayMs?: number;
|
|
5
|
+
maxDelayMs?: number;
|
|
6
|
+
retryableCodes?: Set<string>;
|
|
7
|
+
context?: string;
|
|
8
|
+
noRetry?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
11
|
+
declare function withRetryTransaction<T>(db: {
|
|
12
|
+
transaction: (fn: (tx: any) => Promise<T>) => Promise<T>;
|
|
13
|
+
}, txFn: (tx: any) => Promise<T>, options?: Omit<RetryOptions, 'noRetry'>): Promise<T>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { RetryOptions, withRetry, withRetryTransaction };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getLogger } from "../utils/logger.js";
|
|
2
|
+
import { DEFAULT_RETRYABLE_CODES, getPostgresErrorCode, isRetryableError } from "./retryable-errors.js";
|
|
3
|
+
|
|
4
|
+
//#region src/retry/withRetry.ts
|
|
5
|
+
const logger = getLogger("retry");
|
|
6
|
+
async function withRetry(fn, options = {}) {
|
|
7
|
+
const { maxRetries = 3, baseDelayMs = 50, maxDelayMs = 5e3, retryableCodes = DEFAULT_RETRYABLE_CODES, context = "db-operation", noRetry = false } = options;
|
|
8
|
+
if (noRetry) return fn();
|
|
9
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) try {
|
|
10
|
+
return await fn();
|
|
11
|
+
} catch (error) {
|
|
12
|
+
const isLastAttempt = attempt === maxRetries;
|
|
13
|
+
const retryable = isRetryableError(error, retryableCodes);
|
|
14
|
+
if (isLastAttempt || !retryable) throw error;
|
|
15
|
+
const expDelay = Math.min(maxDelayMs, baseDelayMs * 2 ** attempt);
|
|
16
|
+
const jitteredDelay = Math.random() * expDelay;
|
|
17
|
+
logger.warn({
|
|
18
|
+
context,
|
|
19
|
+
attempt: attempt + 1,
|
|
20
|
+
maxRetries,
|
|
21
|
+
delayMs: Math.round(jitteredDelay),
|
|
22
|
+
errorCode: getPostgresErrorCode(error) ?? error?.code ?? error?.cause?.code,
|
|
23
|
+
errorMessage: error?.message ?? String(error)
|
|
24
|
+
}, "Retrying transient database error");
|
|
25
|
+
await new Promise((resolve) => setTimeout(resolve, jitteredDelay));
|
|
26
|
+
}
|
|
27
|
+
throw new Error("unreachable");
|
|
28
|
+
}
|
|
29
|
+
async function withRetryTransaction(db, txFn, options = {}) {
|
|
30
|
+
return withRetry(() => db.transaction(txFn), {
|
|
31
|
+
...options,
|
|
32
|
+
context: options.context ?? "transaction"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { withRetry, withRetryTransaction };
|