@inkeep/agents-core 0.78.5 → 0.79.1
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/data-access/index.d.ts +2 -1
- package/dist/data-access/index.js +2 -1
- package/dist/data-access/manage/agents.d.ts +26 -26
- package/dist/data-access/manage/artifactComponents.d.ts +2 -2
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +6 -6
- package/dist/data-access/manage/skills.d.ts +4 -4
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgents.d.ts +6 -6
- package/dist/data-access/manage/tools.d.ts +12 -12
- package/dist/data-access/manage/triggers.d.ts +3 -3
- package/dist/data-access/manage/webhookDestinations.d.ts +2 -1
- package/dist/data-access/runtime/apiKeys.d.ts +4 -4
- package/dist/data-access/runtime/apps.d.ts +2 -2
- package/dist/data-access/runtime/conversations.d.ts +12 -12
- package/dist/data-access/runtime/events.d.ts +3 -3
- package/dist/data-access/runtime/feedback.d.ts +2 -2
- package/dist/data-access/runtime/messages.d.ts +18 -18
- package/dist/data-access/runtime/organizations.d.ts +4 -3
- package/dist/data-access/runtime/organizations.js +5 -4
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +5 -5
- package/dist/data-access/runtime/tasks.d.ts +1 -1
- 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 +420 -401
- package/dist/db/manage/manage-schema.js +2 -1
- package/dist/db/runtime/runtime-schema.d.ts +562 -414
- package/dist/db/runtime/runtime-schema.js +30 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas/skills.d.ts +25 -25
- package/dist/validation/schemas.d.ts +633 -588
- package/dist/validation/schemas.js +6 -2
- package/drizzle/manage/0024_blue_junta.sql +2 -0
- package/drizzle/manage/meta/0024_snapshot.json +4323 -0
- package/drizzle/manage/meta/_journal.json +7 -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 +1 -1
|
@@ -40,7 +40,7 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
|
|
|
40
40
|
name: string;
|
|
41
41
|
hash: string;
|
|
42
42
|
} | null;
|
|
43
|
-
status: "pending" | "
|
|
43
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
44
44
|
scheduledFor: string;
|
|
45
45
|
startedAt: string | null;
|
|
46
46
|
completedAt: string | null;
|
|
@@ -199,7 +199,7 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
|
|
|
199
199
|
name: string;
|
|
200
200
|
hash: string;
|
|
201
201
|
} | null;
|
|
202
|
-
status: "pending" | "
|
|
202
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
203
203
|
scheduledFor: string;
|
|
204
204
|
startedAt: string | null;
|
|
205
205
|
completedAt: string | null;
|
|
@@ -239,7 +239,7 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
|
|
|
239
239
|
name: string;
|
|
240
240
|
hash: string;
|
|
241
241
|
} | null;
|
|
242
|
-
status: "pending" | "
|
|
242
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
243
243
|
scheduledFor: string;
|
|
244
244
|
startedAt: string | null;
|
|
245
245
|
completedAt: string | null;
|
|
@@ -292,7 +292,7 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
|
|
|
292
292
|
name: string;
|
|
293
293
|
hash: string;
|
|
294
294
|
} | null;
|
|
295
|
-
status: "pending" | "
|
|
295
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
296
296
|
scheduledFor: string;
|
|
297
297
|
startedAt: string | null;
|
|
298
298
|
completedAt: string | null;
|
|
@@ -320,7 +320,7 @@ declare const listScheduledTriggerInvocationsByDatasetRunId: (db: AgentsRunDatab
|
|
|
320
320
|
name: string;
|
|
321
321
|
hash: string;
|
|
322
322
|
} | null;
|
|
323
|
-
status: "pending" | "
|
|
323
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
324
324
|
scheduledFor: string;
|
|
325
325
|
startedAt: string | null;
|
|
326
326
|
completedAt: string | null;
|
|
@@ -17,9 +17,9 @@ declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert)
|
|
|
17
17
|
} | null;
|
|
18
18
|
metadata: TaskMetadataConfig | null;
|
|
19
19
|
status: string;
|
|
20
|
+
agentId: string;
|
|
20
21
|
projectId: string;
|
|
21
22
|
tenantId: string;
|
|
22
|
-
agentId: string;
|
|
23
23
|
subAgentId: string;
|
|
24
24
|
contextId: string;
|
|
25
25
|
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data-access/runtime/toolApprovalDecisions.d.ts
|
|
4
|
+
interface ToolApprovalScope {
|
|
5
|
+
tenantId: string;
|
|
6
|
+
projectId: string;
|
|
7
|
+
conversationId: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Persist an approval/denial so the instance running the suspended agent can
|
|
11
|
+
* pick it up. Used when the approval request lands on a different instance than
|
|
12
|
+
* the one holding the in-memory pending approval. Upserts so a retry/re-submit
|
|
13
|
+
* overwrites rather than conflicts.
|
|
14
|
+
*/
|
|
15
|
+
declare const recordToolApprovalDecision: (db: AgentsRunDatabaseClient) => (params: ToolApprovalScope & {
|
|
16
|
+
toolCallId: string;
|
|
17
|
+
approved: boolean;
|
|
18
|
+
reason?: string;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Atomically read-and-delete a pending decision for a tool call. Returns null
|
|
22
|
+
* when none is present. The delete-on-read (DELETE ... RETURNING) guarantees a
|
|
23
|
+
* single waiter consumes any given decision exactly once.
|
|
24
|
+
*/
|
|
25
|
+
declare const consumeToolApprovalDecision: (db: AgentsRunDatabaseClient) => (params: ToolApprovalScope & {
|
|
26
|
+
toolCallId: string;
|
|
27
|
+
}) => Promise<{
|
|
28
|
+
approved: boolean;
|
|
29
|
+
reason: string | null;
|
|
30
|
+
} | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete decisions older than the timeout window. Batched to bound statement
|
|
33
|
+
* size, mirroring cleanupExpiredStreamChunks.
|
|
34
|
+
*/
|
|
35
|
+
declare const cleanupExpiredToolApprovalDecisions: (db: AgentsRunDatabaseClient) => (olderThanMinutes?: number, batchSize?: number) => Promise<void>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { cleanupExpiredToolApprovalDecisions, consumeToolApprovalDecision, recordToolApprovalDecision };
|
|
@@ -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 };
|