@inkeep/agents-core 0.79.0 → 0.80.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/auth/auth-schema.d.ts +227 -227
- package/dist/auth/auth-validation-schemas.d.ts +154 -154
- package/dist/auth/auth.js +1 -1
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/data-access/index.d.ts +2 -1
- package/dist/data-access/index.js +2 -1
- package/dist/data-access/manage/agents.d.ts +20 -20
- package/dist/data-access/manage/artifactComponents.d.ts +10 -10
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +4 -4
- package/dist/data-access/manage/functionTools.d.ts +16 -16
- package/dist/data-access/manage/skills.d.ts +12 -12
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +32 -32
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/tools.js +33 -8
- package/dist/data-access/manage/triggers.d.ts +4 -4
- package/dist/data-access/runtime/apiKeys.d.ts +20 -20
- package/dist/data-access/runtime/apps.d.ts +17 -17
- package/dist/data-access/runtime/conversations.d.ts +32 -32
- package/dist/data-access/runtime/evalRuns.d.ts +5 -0
- package/dist/data-access/runtime/evalRuns.js +3 -0
- package/dist/data-access/runtime/events.d.ts +4 -4
- package/dist/data-access/runtime/feedback.d.ts +8 -8
- package/dist/data-access/runtime/feedback.js +2 -2
- package/dist/data-access/runtime/messages.d.ts +27 -27
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +5 -5
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +2 -2
- package/dist/data-access/runtime/tasks.d.ts +6 -6
- package/dist/data-access/runtime/toolApprovalDecisions.d.ts +37 -0
- package/dist/data-access/runtime/toolApprovalDecisions.js +76 -0
- package/dist/db/manage/manage-schema.d.ts +506 -506
- package/dist/db/runtime/runtime-schema.d.ts +602 -454
- package/dist/db/runtime/runtime-schema.js +30 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/utils/json-schema-walk.d.ts +50 -0
- package/dist/utils/json-schema-walk.js +202 -0
- package/dist/utils/mcp-client.js +14 -32
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas/skills.d.ts +45 -45
- package/dist/validation/schemas.d.ts +2248 -2247
- package/dist/validation/schemas.js +1 -0
- package/drizzle/runtime/0044_productive_bromley.sql +12 -0
- package/drizzle/runtime/meta/0044_snapshot.json +6386 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +5 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { toolApprovalDecisions } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { and, eq, sql } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/data-access/runtime/toolApprovalDecisions.ts
|
|
5
|
+
const DEFAULT_CLEANUP_AGE_MINUTES = 15;
|
|
6
|
+
const DEFAULT_CLEANUP_BATCH_SIZE = 1e3;
|
|
7
|
+
const decisionConditions = (scope, toolCallId) => [
|
|
8
|
+
eq(toolApprovalDecisions.tenantId, scope.tenantId),
|
|
9
|
+
eq(toolApprovalDecisions.projectId, scope.projectId),
|
|
10
|
+
eq(toolApprovalDecisions.conversationId, scope.conversationId),
|
|
11
|
+
eq(toolApprovalDecisions.toolCallId, toolCallId)
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Persist an approval/denial so the instance running the suspended agent can
|
|
15
|
+
* pick it up. Used when the approval request lands on a different instance than
|
|
16
|
+
* the one holding the in-memory pending approval. Upserts so a retry/re-submit
|
|
17
|
+
* overwrites rather than conflicts.
|
|
18
|
+
*/
|
|
19
|
+
const recordToolApprovalDecision = (db) => async (params) => {
|
|
20
|
+
await db.insert(toolApprovalDecisions).values({
|
|
21
|
+
tenantId: params.tenantId,
|
|
22
|
+
projectId: params.projectId,
|
|
23
|
+
conversationId: params.conversationId,
|
|
24
|
+
toolCallId: params.toolCallId,
|
|
25
|
+
approved: params.approved,
|
|
26
|
+
reason: params.reason ?? null
|
|
27
|
+
}).onConflictDoUpdate({
|
|
28
|
+
target: [
|
|
29
|
+
toolApprovalDecisions.tenantId,
|
|
30
|
+
toolApprovalDecisions.projectId,
|
|
31
|
+
toolApprovalDecisions.conversationId,
|
|
32
|
+
toolApprovalDecisions.toolCallId
|
|
33
|
+
],
|
|
34
|
+
set: {
|
|
35
|
+
approved: params.approved,
|
|
36
|
+
reason: params.reason ?? null
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Atomically read-and-delete a pending decision for a tool call. Returns null
|
|
42
|
+
* when none is present. The delete-on-read (DELETE ... RETURNING) guarantees a
|
|
43
|
+
* single waiter consumes any given decision exactly once.
|
|
44
|
+
*/
|
|
45
|
+
const consumeToolApprovalDecision = (db) => async (params) => {
|
|
46
|
+
const [row] = await db.delete(toolApprovalDecisions).where(and(...decisionConditions(params, params.toolCallId))).returning();
|
|
47
|
+
if (!row) return null;
|
|
48
|
+
return {
|
|
49
|
+
approved: row.approved,
|
|
50
|
+
reason: row.reason ?? null
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Delete decisions older than the timeout window. Batched to bound statement
|
|
55
|
+
* size, mirroring cleanupExpiredStreamChunks.
|
|
56
|
+
*/
|
|
57
|
+
const cleanupExpiredToolApprovalDecisions = (db) => async (olderThanMinutes = DEFAULT_CLEANUP_AGE_MINUTES, batchSize = DEFAULT_CLEANUP_BATCH_SIZE) => {
|
|
58
|
+
const cutoff = sql`now() - make_interval(mins => ${olderThanMinutes})`;
|
|
59
|
+
let deleted;
|
|
60
|
+
do {
|
|
61
|
+
const batch = await db.select({
|
|
62
|
+
tenantId: toolApprovalDecisions.tenantId,
|
|
63
|
+
projectId: toolApprovalDecisions.projectId,
|
|
64
|
+
conversationId: toolApprovalDecisions.conversationId,
|
|
65
|
+
toolCallId: toolApprovalDecisions.toolCallId
|
|
66
|
+
}).from(toolApprovalDecisions).where(sql`${toolApprovalDecisions.createdAt} < ${cutoff}`).limit(batchSize);
|
|
67
|
+
deleted = batch.length;
|
|
68
|
+
if (deleted > 0) {
|
|
69
|
+
const pks = batch.map((row) => sql`(${row.tenantId}, ${row.projectId}, ${row.conversationId}, ${row.toolCallId})`);
|
|
70
|
+
await db.delete(toolApprovalDecisions).where(sql`(${toolApprovalDecisions.tenantId}, ${toolApprovalDecisions.projectId}, ${toolApprovalDecisions.conversationId}, ${toolApprovalDecisions.toolCallId}) IN (${sql.join(pks, sql`, `)})`);
|
|
71
|
+
}
|
|
72
|
+
} while (deleted >= batchSize);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { cleanupExpiredToolApprovalDecisions, consumeToolApprovalDecision, recordToolApprovalDecision };
|