@inkeep/agents-core 0.59.4 → 0.61.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.
Files changed (88) hide show
  1. package/dist/auth/auth-validation-schemas.d.ts +154 -154
  2. package/dist/auth/init.js +42 -0
  3. package/dist/auth/wait-for-spicedb.d.ts +1 -0
  4. package/dist/auth/wait-for-spicedb.js +51 -0
  5. package/dist/client-exports.d.ts +4 -107
  6. package/dist/client-exports.js +3 -61
  7. package/dist/constants/context-breakdown.js +5 -0
  8. package/dist/constants/otel-attributes.d.ts +25 -1
  9. package/dist/constants/otel-attributes.js +25 -1
  10. package/dist/data-access/index.d.ts +4 -3
  11. package/dist/data-access/index.js +4 -3
  12. package/dist/data-access/manage/agentFull.js +15 -10
  13. package/dist/data-access/manage/agents.d.ts +69 -63
  14. package/dist/data-access/manage/agents.js +2 -0
  15. package/dist/data-access/manage/artifactComponents.d.ts +12 -12
  16. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  17. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  18. package/dist/data-access/manage/functionTools.d.ts +18 -18
  19. package/dist/data-access/manage/functionTools.js +2 -2
  20. package/dist/data-access/manage/projectFull.js +24 -3
  21. package/dist/data-access/manage/skills.d.ts +14 -14
  22. package/dist/data-access/manage/skills.js +2 -3
  23. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +27 -27
  24. package/dist/data-access/manage/subAgentExternalAgentRelations.js +2 -2
  25. package/dist/data-access/manage/subAgentRelations.d.ts +29 -29
  26. package/dist/data-access/manage/subAgentRelations.js +2 -2
  27. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +30 -30
  28. package/dist/data-access/manage/subAgentTeamAgentRelations.js +2 -2
  29. package/dist/data-access/manage/subAgents.d.ts +36 -36
  30. package/dist/data-access/manage/tools.d.ts +21 -21
  31. package/dist/data-access/manage/tools.js +2 -2
  32. package/dist/data-access/manage/triggers.d.ts +2 -2
  33. package/dist/data-access/runtime/apiKeys.d.ts +16 -16
  34. package/dist/data-access/runtime/apps.d.ts +61 -13
  35. package/dist/data-access/runtime/apps.js +15 -1
  36. package/dist/data-access/runtime/conversations.d.ts +23 -23
  37. package/dist/data-access/runtime/conversations.js +18 -1
  38. package/dist/data-access/runtime/ledgerArtifacts.d.ts +11 -2
  39. package/dist/data-access/runtime/ledgerArtifacts.js +12 -1
  40. package/dist/data-access/runtime/messages.d.ts +18 -18
  41. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
  42. package/dist/data-access/runtime/tasks.d.ts +4 -4
  43. package/dist/data-access/runtime/workflowExecutions.d.ts +25 -0
  44. package/dist/data-access/runtime/workflowExecutions.js +32 -0
  45. package/dist/db/manage/manage-schema.d.ts +495 -475
  46. package/dist/db/manage/manage-schema.js +1 -0
  47. package/dist/db/runtime/runtime-schema.d.ts +568 -334
  48. package/dist/db/runtime/runtime-schema.js +19 -2
  49. package/dist/dolt/fk-map.d.ts +5 -0
  50. package/dist/dolt/fk-map.js +34 -0
  51. package/dist/dolt/index.d.ts +3 -2
  52. package/dist/dolt/index.js +3 -2
  53. package/dist/dolt/resolve-conflicts.d.ts +11 -1
  54. package/dist/dolt/resolve-conflicts.js +105 -47
  55. package/dist/index.d.ts +15 -10
  56. package/dist/index.js +13 -8
  57. package/dist/types/entities.d.ts +5 -2
  58. package/dist/types/index.d.ts +3 -3
  59. package/dist/types/utility.d.ts +11 -3
  60. package/dist/utils/apiKeys.js +1 -1
  61. package/dist/utils/conversations.d.ts +10 -1
  62. package/dist/utils/conversations.js +19 -1
  63. package/dist/utils/error.d.ts +51 -51
  64. package/dist/utils/index.d.ts +7 -2
  65. package/dist/utils/index.js +5 -2
  66. package/dist/utils/model-factory.js +35 -10
  67. package/dist/utils/token-estimator.d.ts +19 -0
  68. package/dist/utils/token-estimator.js +17 -0
  69. package/dist/utils/usage-cost-middleware.d.ts +13 -0
  70. package/dist/utils/usage-cost-middleware.js +60 -0
  71. package/dist/utils/usage-tracker.d.ts +2 -0
  72. package/dist/utils/usage-tracker.js +1 -0
  73. package/dist/utils/validate-public-key.d.ts +10 -0
  74. package/dist/utils/validate-public-key.js +89 -0
  75. package/dist/validation/agentFull.js +0 -1
  76. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  77. package/dist/validation/index.d.ts +2 -2
  78. package/dist/validation/index.js +2 -2
  79. package/dist/validation/schemas.d.ts +3518 -2682
  80. package/dist/validation/schemas.js +104 -36
  81. package/drizzle/manage/0013_gorgeous_umar.sql +1 -0
  82. package/drizzle/manage/meta/0013_snapshot.json +3704 -0
  83. package/drizzle/manage/meta/_journal.json +7 -0
  84. package/drizzle/runtime/0025_faulty_kylun.sql +1 -0
  85. package/drizzle/runtime/0026_graceful_scorpion.sql +15 -0
  86. package/drizzle/runtime/meta/0026_snapshot.json +4389 -0
  87. package/drizzle/runtime/meta/_journal.json +14 -0
  88. package/package.json +1 -1
@@ -22,11 +22,11 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
22
22
  }) => Promise<{
23
23
  id: string;
24
24
  name: string;
25
- description: string | null;
26
- tenantId: string;
27
- projectId: string;
28
25
  createdAt: string;
29
26
  updatedAt: string;
27
+ description: string | null;
28
+ projectId: string;
29
+ tenantId: string;
30
30
  headers: Record<string, string> | null;
31
31
  config: {
32
32
  type: "mcp";
@@ -80,11 +80,11 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
80
80
  declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
81
81
  id: string;
82
82
  name: string;
83
- description: string | null;
84
- tenantId: string;
85
- projectId: string;
86
83
  createdAt: string;
87
84
  updatedAt: string;
85
+ description: string | null;
86
+ projectId: string;
87
+ tenantId: string;
88
88
  headers: Record<string, string> | null;
89
89
  config: {
90
90
  type: "mcp";
@@ -136,17 +136,17 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
136
136
  }> | null;
137
137
  }) => Promise<{
138
138
  id: string;
139
- tenantId: string;
140
- projectId: string;
141
- agentId: string;
142
139
  createdAt: string;
143
140
  updatedAt: string;
141
+ agentId: string;
142
+ projectId: string;
143
+ tenantId: string;
144
+ subAgentId: string;
144
145
  toolId: string;
145
146
  headers: Record<string, string> | null;
146
147
  toolPolicies: Record<string, {
147
148
  needsApproval?: boolean;
148
149
  }> | null;
149
- subAgentId: string;
150
150
  selectedTools: string[] | null;
151
151
  }>;
152
152
  declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -155,17 +155,17 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
155
155
  toolId: string;
156
156
  }) => Promise<{
157
157
  id: string;
158
- tenantId: string;
159
- projectId: string;
160
- agentId: string;
161
158
  createdAt: string;
162
159
  updatedAt: string;
160
+ agentId: string;
161
+ projectId: string;
162
+ tenantId: string;
163
+ subAgentId: string;
163
164
  toolId: string;
164
165
  headers: Record<string, string> | null;
165
166
  toolPolicies: Record<string, {
166
167
  needsApproval?: boolean;
167
168
  }> | null;
168
- subAgentId: string;
169
169
  selectedTools: string[] | null;
170
170
  }>;
171
171
  /**
@@ -183,17 +183,17 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
183
183
  relationId?: string;
184
184
  }) => Promise<{
185
185
  id: string;
186
- tenantId: string;
187
- projectId: string;
188
- agentId: string;
189
186
  createdAt: string;
190
187
  updatedAt: string;
188
+ agentId: string;
189
+ projectId: string;
190
+ tenantId: string;
191
+ subAgentId: string;
191
192
  toolId: string;
192
193
  headers: Record<string, string> | null;
193
194
  toolPolicies: Record<string, {
194
195
  needsApproval?: boolean;
195
196
  }> | null;
196
- subAgentId: string;
197
197
  selectedTools: string[] | null;
198
198
  }>;
199
199
  /**
@@ -204,11 +204,11 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
204
204
  }) => Promise<{
205
205
  id: string;
206
206
  name: string;
207
- description: string | null;
208
- tenantId: string;
209
- projectId: string;
210
207
  createdAt: string;
211
208
  updatedAt: string;
209
+ description: string | null;
210
+ projectId: string;
211
+ tenantId: string;
212
212
  headers: Record<string, string> | null;
213
213
  config: {
214
214
  type: "mcp";
@@ -9,7 +9,7 @@ import { getCredentialStoreLookupKeyFromRetrievalParams } from "../../utils/cred
9
9
  import { CredentialStuffer } from "../../credential-stuffer/CredentialStuffer.js";
10
10
  import "../../credential-stuffer/index.js";
11
11
  import { createAgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
12
- import { generateId } from "../../utils/conversations.js";
12
+ import { deriveRelationId } from "../../utils/conversations.js";
13
13
  import { getActiveBranch } from "../../dolt/schema-sync.js";
14
14
  import { agentScopedWhere, projectScopedWhere } from "./scope-helpers.js";
15
15
  import { isSlackWorkAppTool } from "../runtime/slack-work-app-mcp.js";
@@ -371,7 +371,7 @@ const deleteTool = (db) => async (params) => {
371
371
  return true;
372
372
  };
373
373
  const addToolToAgent = (db) => async (params) => {
374
- const id = generateId();
374
+ const id = deriveRelationId(params.scopes.tenantId, params.scopes.projectId, params.scopes.agentId, params.subAgentId, params.toolId);
375
375
  const now = (/* @__PURE__ */ new Date()).toISOString();
376
376
  const [created] = await db.insert(subAgentToolRelations).values({
377
377
  id,
@@ -40,13 +40,13 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
40
40
  algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
41
41
  encoding: "hex" | "base64";
42
42
  signature: {
43
- source: "query" | "body" | "header";
43
+ source: "query" | "header" | "body";
44
44
  key: string;
45
45
  prefix?: string | undefined;
46
46
  regex?: string | undefined;
47
47
  };
48
48
  signedComponents: {
49
- source: "literal" | "body" | "header";
49
+ source: "literal" | "header" | "body";
50
50
  required: boolean;
51
51
  key?: string | undefined;
52
52
  value?: string | undefined;
@@ -10,30 +10,30 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
10
10
  }) => Promise<{
11
11
  id: string;
12
12
  name: string | null;
13
- tenantId: string;
14
- projectId: string;
15
- agentId: string;
16
13
  createdAt: string;
17
14
  updatedAt: string;
18
15
  expiresAt: string | null;
19
- lastUsedAt: string | null;
16
+ agentId: string;
17
+ projectId: string;
18
+ tenantId: string;
20
19
  publicId: string;
21
20
  keyHash: string;
22
21
  keyPrefix: string;
22
+ lastUsedAt: string | null;
23
23
  } | undefined>;
24
24
  declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
25
25
  id: string;
26
26
  name: string | null;
27
- tenantId: string;
28
- projectId: string;
29
- agentId: string;
30
27
  createdAt: string;
31
28
  updatedAt: string;
32
29
  expiresAt: string | null;
33
- lastUsedAt: string | null;
30
+ agentId: string;
31
+ projectId: string;
32
+ tenantId: string;
34
33
  publicId: string;
35
34
  keyHash: string;
36
35
  keyPrefix: string;
36
+ lastUsedAt: string | null;
37
37
  } | undefined>;
38
38
  declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
39
39
  scopes: ProjectScopeConfig;
@@ -41,16 +41,16 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
41
41
  }) => Promise<{
42
42
  id: string;
43
43
  name: string | null;
44
- tenantId: string;
45
- projectId: string;
46
- agentId: string;
47
44
  createdAt: string;
48
45
  updatedAt: string;
49
46
  expiresAt: string | null;
50
- lastUsedAt: string | null;
47
+ agentId: string;
48
+ projectId: string;
49
+ tenantId: string;
51
50
  publicId: string;
52
51
  keyHash: string;
53
52
  keyPrefix: string;
53
+ lastUsedAt: string | null;
54
54
  }[]>;
55
55
  declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
56
56
  scopes: ProjectScopeConfig;
@@ -68,16 +68,16 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
68
68
  declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
69
69
  id: string;
70
70
  name: string | null;
71
- tenantId: string;
72
- projectId: string;
73
- agentId: string;
74
71
  createdAt: string;
75
72
  updatedAt: string;
76
73
  expiresAt: string | null;
77
- lastUsedAt: string | null;
74
+ agentId: string;
75
+ projectId: string;
76
+ tenantId: string;
78
77
  publicId: string;
79
78
  keyHash: string;
80
79
  keyPrefix: string;
80
+ lastUsedAt: string | null;
81
81
  }>;
82
82
  declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
83
83
  scopes: ProjectScopeConfig;
@@ -5,27 +5,39 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
5
5
 
6
6
  //#region src/data-access/runtime/apps.d.ts
7
7
  declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
8
+ type: AppType;
8
9
  id: string;
9
10
  name: string;
10
- description: string | null;
11
- tenantId: string | null;
12
- projectId: string | null;
13
- type: AppType;
14
11
  createdAt: string;
15
12
  updatedAt: string;
13
+ description: string | null;
16
14
  enabled: boolean;
15
+ projectId: string | null;
16
+ tenantId: string | null;
17
+ prompt: string | null;
17
18
  config: {
18
19
  type: "web_client";
19
20
  webClient: {
20
21
  allowedDomains: string[];
22
+ auth?: {
23
+ publicKeys: {
24
+ kid: string;
25
+ publicKey: string;
26
+ algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
27
+ addedAt: string;
28
+ }[];
29
+ audience?: string | undefined;
30
+ validateScopeClaims?: boolean | undefined;
31
+ allowAnonymous?: boolean | undefined;
32
+ } | undefined;
21
33
  };
22
34
  } | {
23
35
  type: "api";
24
36
  api: Record<string, never>;
25
37
  };
26
- defaultAgentId: string | null;
27
- defaultProjectId: string | null;
28
38
  lastUsedAt: string | null;
39
+ defaultProjectId: string | null;
40
+ defaultAgentId: string | null;
29
41
  } | undefined>;
30
42
  declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
31
43
  declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
@@ -52,27 +64,39 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
52
64
  };
53
65
  }>;
54
66
  declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
67
+ type: AppType;
55
68
  id: string;
56
69
  name: string;
57
- description: string | null;
58
- tenantId: string | null;
59
- projectId: string | null;
60
- type: AppType;
61
70
  createdAt: string;
62
71
  updatedAt: string;
72
+ description: string | null;
63
73
  enabled: boolean;
74
+ projectId: string | null;
75
+ tenantId: string | null;
76
+ prompt: string | null;
64
77
  config: {
65
78
  type: "web_client";
66
79
  webClient: {
67
80
  allowedDomains: string[];
81
+ auth?: {
82
+ publicKeys: {
83
+ kid: string;
84
+ publicKey: string;
85
+ algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
86
+ addedAt: string;
87
+ }[];
88
+ audience?: string | undefined;
89
+ validateScopeClaims?: boolean | undefined;
90
+ allowAnonymous?: boolean | undefined;
91
+ } | undefined;
68
92
  };
69
93
  } | {
70
94
  type: "api";
71
95
  api: Record<string, never>;
72
96
  };
73
- defaultAgentId: string | null;
74
- defaultProjectId: string | null;
75
97
  lastUsedAt: string | null;
98
+ defaultProjectId: string | null;
99
+ defaultAgentId: string | null;
76
100
  }>;
77
101
  declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
78
102
  scopes: TenantScopeConfig;
@@ -95,6 +119,18 @@ declare const deleteAppForProject: (db: AgentsRunDatabaseClient) => (params: {
95
119
  declare const deleteAppsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
96
120
  declare const clearAppDefaultsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
97
121
  declare const clearAppDefaultsByAgent: (db: AgentsRunDatabaseClient) => (tenantId: string, agentId: string) => Promise<number>;
122
+ declare const getAppAuthKeysForProject: (db: AgentsRunDatabaseClient) => (params: {
123
+ scopes: ProjectScopeConfig;
124
+ id: string;
125
+ }) => Promise<{
126
+ config: AppSelect["config"];
127
+ type: AppSelect["type"];
128
+ } | undefined>;
129
+ declare const updateAppAuthKeysForProject: (db: AgentsRunDatabaseClient) => (params: {
130
+ scopes: ProjectScopeConfig;
131
+ id: string;
132
+ config: AppSelect["config"];
133
+ }) => Promise<AppSelect | undefined>;
98
134
  declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
99
135
  id: string;
100
136
  data: AppUpdate;
@@ -109,11 +145,23 @@ declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
109
145
  type: AppType;
110
146
  defaultProjectId: string | null;
111
147
  defaultAgentId: string | null;
148
+ prompt: string | null;
112
149
  enabled: boolean;
113
150
  config: {
114
151
  type: "web_client";
115
152
  webClient: {
116
153
  allowedDomains: string[];
154
+ auth?: {
155
+ publicKeys: {
156
+ kid: string;
157
+ publicKey: string;
158
+ algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
159
+ addedAt: string;
160
+ }[];
161
+ audience?: string | undefined;
162
+ validateScopeClaims?: boolean | undefined;
163
+ allowAnonymous?: boolean | undefined;
164
+ } | undefined;
117
165
  };
118
166
  } | {
119
167
  type: "api";
@@ -123,4 +171,4 @@ declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
123
171
  }>;
124
172
  declare const deleteApp: (db: AgentsRunDatabaseClient) => (id: string) => Promise<boolean>;
125
173
  //#endregion
126
- export { clearAppDefaultsByAgent, clearAppDefaultsByProject, createApp, deleteApp, deleteAppForProject, deleteAppForTenant, deleteAppsByProject, getAppById, getAppByIdForProject, getAppByIdForTenant, listAppsPaginated, updateApp, updateAppForProject, updateAppForTenant, updateAppLastUsed };
174
+ export { clearAppDefaultsByAgent, clearAppDefaultsByProject, createApp, deleteApp, deleteAppForProject, deleteAppForTenant, deleteAppsByProject, getAppAuthKeysForProject, getAppById, getAppByIdForProject, getAppByIdForTenant, listAppsPaginated, updateApp, updateAppAuthKeysForProject, updateAppForProject, updateAppForTenant, updateAppLastUsed };
@@ -76,6 +76,20 @@ const clearAppDefaultsByAgent = (db) => async (tenantId, agentId) => {
76
76
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
77
77
  }).where(and(tenantScopedWhere(apps, { tenantId }), eq(apps.defaultAgentId, agentId))).returning()).length;
78
78
  };
79
+ const getAppAuthKeysForProject = (db) => async (params) => {
80
+ return (await db.select({
81
+ config: apps.config,
82
+ type: apps.type
83
+ }).from(apps).where(and(eq(apps.id, params.id), projectScopedWhere(apps, params.scopes))).limit(1))[0];
84
+ };
85
+ const updateAppAuthKeysForProject = (db) => async (params) => {
86
+ const now = (/* @__PURE__ */ new Date()).toISOString();
87
+ const [updated] = await db.update(apps).set({
88
+ config: params.config,
89
+ updatedAt: now
90
+ }).where(and(eq(apps.id, params.id), projectScopedWhere(apps, params.scopes))).returning();
91
+ return updated;
92
+ };
79
93
  const updateApp = (db) => async (params) => {
80
94
  const now = (/* @__PURE__ */ new Date()).toISOString();
81
95
  const [updatedApp] = await db.update(apps).set({
@@ -91,4 +105,4 @@ const deleteApp = (db) => async (id) => {
91
105
  };
92
106
 
93
107
  //#endregion
94
- export { clearAppDefaultsByAgent, clearAppDefaultsByProject, createApp, deleteApp, deleteAppForProject, deleteAppForTenant, deleteAppsByProject, getAppById, getAppByIdForProject, getAppByIdForTenant, listAppsPaginated, updateApp, updateAppForProject, updateAppForTenant, updateAppLastUsed };
108
+ export { clearAppDefaultsByAgent, clearAppDefaultsByProject, createApp, deleteApp, deleteAppForProject, deleteAppForTenant, deleteAppsByProject, getAppAuthKeysForProject, getAppById, getAppByIdForProject, getAppByIdForTenant, listAppsPaginated, updateApp, updateAppAuthKeysForProject, updateAppForProject, updateAppForTenant, updateAppLastUsed };
@@ -3,8 +3,7 @@ import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
3
3
  import { ConversationHistoryConfig, ConversationMetadata, PaginationConfig } from "../../types/utility.js";
4
4
  import "../../types/index.js";
5
5
  import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
6
- import "../../index.js";
7
- import { ConversationInsert, ConversationSelect, ConversationUpdate } from "../../types/entities.js";
6
+ import { ConversationInsert, ConversationSelect, ConversationUpdate, MessageSelect } from "../../types/entities.js";
8
7
 
9
8
  //#region src/data-access/runtime/conversations.d.ts
10
9
  declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
@@ -17,19 +16,19 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
17
16
  }>;
18
17
  declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
19
18
  id: string;
20
- tenantId: string;
21
- projectId: string;
22
- agentId: string | null;
23
- title: string | null;
24
19
  createdAt: string;
25
20
  updatedAt: string;
26
- metadata: ConversationMetadata | null;
27
21
  ref: {
28
22
  type: "commit" | "tag" | "branch";
29
23
  name: string;
30
24
  hash: string;
31
25
  } | null;
32
26
  userId: string | null;
27
+ metadata: ConversationMetadata | null;
28
+ agentId: string | null;
29
+ projectId: string;
30
+ tenantId: string;
31
+ title: string | null;
33
32
  activeSubAgentId: string;
34
33
  lastContextResolution: string | null;
35
34
  }>;
@@ -86,19 +85,19 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
86
85
  conversationId: string;
87
86
  }) => Promise<{
88
87
  id: string;
89
- tenantId: string;
90
- projectId: string;
91
- agentId: string | null;
92
- title: string | null;
93
88
  createdAt: string;
94
89
  updatedAt: string;
95
- metadata: ConversationMetadata | null;
96
90
  ref: {
97
91
  type: "commit" | "tag" | "branch";
98
92
  name: string;
99
93
  hash: string;
100
94
  } | null;
101
95
  userId: string | null;
96
+ metadata: ConversationMetadata | null;
97
+ agentId: string | null;
98
+ projectId: string;
99
+ tenantId: string;
100
+ title: string | null;
102
101
  activeSubAgentId: string;
103
102
  lastContextResolution: string | null;
104
103
  } | undefined>;
@@ -122,19 +121,19 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
122
121
  contextConfigId?: string | undefined;
123
122
  } | {
124
123
  id: string;
125
- tenantId: string;
126
- projectId: string;
127
- agentId: string | null;
128
- title: string | null;
129
124
  createdAt: string;
130
125
  updatedAt: string;
131
- metadata: ConversationMetadata | null;
132
126
  ref: {
133
127
  type: "commit" | "tag" | "branch";
134
128
  name: string;
135
129
  hash: string;
136
130
  } | null;
137
131
  userId: string | null;
132
+ metadata: ConversationMetadata | null;
133
+ agentId: string | null;
134
+ projectId: string;
135
+ tenantId: string;
136
+ title: string | null;
138
137
  activeSubAgentId: string;
139
138
  lastContextResolution: string | null;
140
139
  }>;
@@ -145,7 +144,7 @@ declare const getConversationHistory: (db: AgentsRunDatabaseClient) => (params:
145
144
  scopes: ProjectScopeConfig;
146
145
  conversationId: string;
147
146
  options?: ConversationHistoryConfig;
148
- }) => Promise<any[]>;
147
+ }) => Promise<MessageSelect[]>;
149
148
  /**
150
149
  * Get active agent for a conversation
151
150
  */
@@ -154,19 +153,19 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
154
153
  conversationId: string;
155
154
  }) => Promise<{
156
155
  id: string;
157
- tenantId: string;
158
- projectId: string;
159
- agentId: string | null;
160
- title: string | null;
161
156
  createdAt: string;
162
157
  updatedAt: string;
163
- metadata: ConversationMetadata | null;
164
158
  ref: {
165
159
  type: "commit" | "tag" | "branch";
166
160
  name: string;
167
161
  hash: string;
168
162
  } | null;
169
163
  userId: string | null;
164
+ metadata: ConversationMetadata | null;
165
+ agentId: string | null;
166
+ projectId: string;
167
+ tenantId: string;
168
+ title: string | null;
170
169
  activeSubAgentId: string;
171
170
  lastContextResolution: string | null;
172
171
  } | undefined>;
@@ -180,6 +179,7 @@ declare const setActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
180
179
  agentId: string;
181
180
  ref: ResolvedRef;
182
181
  userId?: string;
182
+ metadata?: ConversationMetadata;
183
183
  }) => Promise<void>;
184
184
  declare const setActiveAgentForThread: (db: AgentsRunDatabaseClient) => ({
185
185
  scopes,
@@ -113,13 +113,29 @@ function applyContextWindowManagement(messageHistory, maxTokens) {
113
113
  totalTokens += messageTokens;
114
114
  } else {
115
115
  if (i > 0) {
116
+ const referenceMessage = messageHistory[0];
116
117
  const summaryMessage = {
117
118
  id: `summary-${getConversationId()}`,
119
+ tenantId: referenceMessage.tenantId,
120
+ projectId: referenceMessage.projectId,
121
+ conversationId: referenceMessage.conversationId,
118
122
  role: "system",
123
+ fromSubAgentId: null,
124
+ toSubAgentId: null,
125
+ fromExternalAgentId: null,
126
+ toExternalAgentId: null,
127
+ fromTeamAgentId: null,
128
+ toTeamAgentId: null,
119
129
  content: { text: `[Previous conversation history truncated - ${i + 1} earlier messages]` },
120
130
  visibility: "system",
121
131
  messageType: "chat",
122
- createdAt: messageHistory[0].createdAt
132
+ taskId: null,
133
+ parentMessageId: null,
134
+ a2aTaskId: null,
135
+ a2aSessionId: null,
136
+ metadata: null,
137
+ createdAt: referenceMessage.createdAt,
138
+ updatedAt: referenceMessage.updatedAt
123
139
  };
124
140
  managedHistory.unshift(summaryMessage);
125
141
  }
@@ -159,6 +175,7 @@ const setActiveAgentForConversation = (db) => async (params) => {
159
175
  agentId: params.agentId,
160
176
  ref: params.ref,
161
177
  userId: params.userId,
178
+ metadata: params.metadata,
162
179
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
163
180
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
164
181
  }).onConflictDoUpdate({
@@ -1,4 +1,4 @@
1
- import { Artifact } from "../../types/a2a.js";
1
+ import { Artifact, Part } from "../../types/a2a.js";
2
2
  import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
3
3
  import "../../types/index.js";
4
4
  import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
@@ -47,6 +47,15 @@ declare const getLedgerArtifactsByContext: (db: AgentsRunDatabaseClient) => (par
47
47
  scopes: ProjectScopeConfig;
48
48
  contextId: string;
49
49
  }) => Promise<LedgerArtifactSelect[]>;
50
+ /**
51
+ * Update the parts column of an existing ledger artifact by ID.
52
+ * Used to persist modifications (e.g. key_findings) to artifacts that already exist.
53
+ */
54
+ declare const updateLedgerArtifactParts: (db: AgentsRunDatabaseClient) => (params: {
55
+ scopes: ProjectScopeConfig;
56
+ artifactId: string;
57
+ parts: Part[];
58
+ }) => Promise<boolean>;
50
59
  /**
51
60
  * Delete ledger artifacts by task ID
52
61
  */
@@ -69,4 +78,4 @@ declare const countLedgerArtifactsByTask: (db: AgentsRunDatabaseClient) => (para
69
78
  taskId: string;
70
79
  }) => Promise<number>;
71
80
  //#endregion
72
- export { addLedgerArtifacts, countLedgerArtifactsByTask, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, getLedgerArtifacts, getLedgerArtifactsByContext, upsertLedgerArtifact };
81
+ export { addLedgerArtifacts, countLedgerArtifactsByTask, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, getLedgerArtifacts, getLedgerArtifactsByContext, updateLedgerArtifactParts, upsertLedgerArtifact };
@@ -212,6 +212,17 @@ const getLedgerArtifactsByContext = (db) => async (params) => {
212
212
  return await db.select().from(ledgerArtifacts).where(and(projectScopedWhere(ledgerArtifacts, params.scopes), eq(ledgerArtifacts.contextId, params.contextId)));
213
213
  };
214
214
  /**
215
+ * Update the parts column of an existing ledger artifact by ID.
216
+ * Used to persist modifications (e.g. key_findings) to artifacts that already exist.
217
+ */
218
+ const updateLedgerArtifactParts = (db) => async (params) => {
219
+ const { scopes, artifactId, parts } = params;
220
+ return (await db.update(ledgerArtifacts).set({
221
+ parts,
222
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
223
+ }).where(and(projectScopedWhere(ledgerArtifacts, scopes), eq(ledgerArtifacts.id, artifactId))).returning()).length > 0;
224
+ };
225
+ /**
215
226
  * Delete ledger artifacts by task ID
216
227
  */
217
228
  const deleteLedgerArtifactsByTask = (db) => async (params) => {
@@ -232,4 +243,4 @@ const countLedgerArtifactsByTask = (db) => async (params) => {
232
243
  };
233
244
 
234
245
  //#endregion
235
- export { addLedgerArtifacts, countLedgerArtifactsByTask, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, getLedgerArtifacts, getLedgerArtifactsByContext, upsertLedgerArtifact };
246
+ export { addLedgerArtifacts, countLedgerArtifactsByTask, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, getLedgerArtifacts, getLedgerArtifactsByContext, updateLedgerArtifactParts, upsertLedgerArtifact };