@inkeep/agents-run-api 0.8.1 → 0.8.2
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/chunk-A2S7GSHL.js +1 -0
- package/dist/{chunk-ETRXGI47.js → chunk-OFGZSGQI.js} +60 -54
- package/dist/chunk-PEMWKWTV.js +54 -0
- package/dist/conversations-W5BDU2IU.js +1 -0
- package/dist/dbClient-LO5HXH2I.js +1 -0
- package/dist/index.cjs +2965 -1470
- package/dist/index.js +2867 -1499
- package/dist/json-postprocessor-VOMU4E5L.js +12 -0
- package/dist/logger-6JGMWF6F.js +1 -0
- package/package.json +2 -2
- package/templates/v1/{system-prompt.xml → phase1/system-prompt.xml} +1 -2
- package/templates/v1/{thinking-preparation.xml → phase1/thinking-preparation.xml} +13 -3
- package/templates/v1/phase2/data-components.xml +22 -0
- package/templates/v1/phase2/system-prompt.xml +22 -0
- package/templates/v1/shared/artifact-retrieval-guidance.xml +49 -0
- package/templates/v1/{artifact.xml → shared/artifact.xml} +1 -0
- package/dist/conversations-I6KHD42D.js +0 -1
- /package/templates/v1/{tool.xml → phase1/tool.xml} +0 -0
- /package/templates/v1/{data-component.xml → phase2/data-component.xml} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getLogger } from '@inkeep/agents-core';
|
|
@@ -1,58 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dbClient_default } from './chunk-PEMWKWTV.js';
|
|
2
|
+
import { createMessage, getConversationHistory } from '@inkeep/agents-core';
|
|
2
3
|
import { nanoid } from 'nanoid';
|
|
3
|
-
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
// src/data/conversations.ts
|
|
6
|
-
loadEnvironmentFiles();
|
|
7
|
-
var envSchema = z.object({
|
|
8
|
-
NODE_ENV: z.enum(["development", "production", "test"]).optional(),
|
|
9
|
-
ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
|
|
10
|
-
DB_FILE_NAME: z.string(),
|
|
11
|
-
TURSO_DATABASE_URL: z.string().optional(),
|
|
12
|
-
TURSO_AUTH_TOKEN: z.string().optional(),
|
|
13
|
-
AGENTS_RUN_API_URL: z.string().optional().default("http://localhost:3003"),
|
|
14
|
-
LOG_LEVEL: z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
|
|
15
|
-
NANGO_SECRET_KEY: z.string().optional(),
|
|
16
|
-
OPENAI_API_KEY: z.string().optional(),
|
|
17
|
-
ANTHROPIC_API_KEY: z.string(),
|
|
18
|
-
INKEEP_AGENTS_RUN_API_BYPASS_SECRET: z.string().optional()
|
|
19
|
-
});
|
|
20
|
-
var parseEnv = () => {
|
|
21
|
-
try {
|
|
22
|
-
const parsedEnv = envSchema.parse(process.env);
|
|
23
|
-
return parsedEnv;
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (error instanceof z.ZodError) {
|
|
26
|
-
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
27
|
-
throw new Error(
|
|
28
|
-
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|
|
29
|
-
${error.message}`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var env = parseEnv();
|
|
36
|
-
|
|
37
|
-
// src/data/db/dbClient.ts
|
|
38
|
-
var getDbConfig = () => {
|
|
39
|
-
if (env.ENVIRONMENT === "test") {
|
|
40
|
-
return { url: ":memory:" };
|
|
41
|
-
}
|
|
42
|
-
if (env.TURSO_DATABASE_URL && env.TURSO_AUTH_TOKEN) {
|
|
43
|
-
return {
|
|
44
|
-
url: env.TURSO_DATABASE_URL,
|
|
45
|
-
authToken: env.TURSO_AUTH_TOKEN
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
url: env.DB_FILE_NAME
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
var dbClient = createDatabaseClient(getDbConfig());
|
|
53
|
-
var dbClient_default = dbClient;
|
|
54
|
-
|
|
55
|
-
// src/data/conversations.ts
|
|
56
5
|
function createDefaultConversationHistoryConfig(mode = "full") {
|
|
57
6
|
return {
|
|
58
7
|
mode,
|
|
@@ -217,5 +166,62 @@ ${formattedHistory}
|
|
|
217
166
|
</conversation_history>
|
|
218
167
|
`;
|
|
219
168
|
}
|
|
169
|
+
async function getConversationScopedArtifacts(params) {
|
|
170
|
+
const { tenantId, projectId, conversationId, historyConfig } = params;
|
|
171
|
+
if (!conversationId) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
if (historyConfig.mode === "none") {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
const visibleMessages = await getScopedHistory({
|
|
179
|
+
tenantId,
|
|
180
|
+
projectId,
|
|
181
|
+
conversationId,
|
|
182
|
+
options: historyConfig
|
|
183
|
+
});
|
|
184
|
+
if (visibleMessages.length === 0) {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
const visibleMessageIds = visibleMessages.filter((msg) => !(msg.messageType === "system" && msg.content?.text?.includes("Previous conversation history truncated"))).map((msg) => msg.id);
|
|
188
|
+
if (visibleMessageIds.length === 0) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
const { getLedgerArtifacts } = await import('@inkeep/agents-core');
|
|
192
|
+
const dbClient = (await import('./dbClient-LO5HXH2I.js')).default;
|
|
193
|
+
const visibleTaskIds = visibleMessages.map((msg) => msg.taskId).filter((taskId) => Boolean(taskId));
|
|
194
|
+
const referenceArtifacts = [];
|
|
195
|
+
for (const taskId of visibleTaskIds) {
|
|
196
|
+
const artifacts = await getLedgerArtifacts(dbClient)({
|
|
197
|
+
scopes: { tenantId, projectId },
|
|
198
|
+
taskId
|
|
199
|
+
});
|
|
200
|
+
referenceArtifacts.push(...artifacts);
|
|
201
|
+
}
|
|
202
|
+
const logger = (await import('./logger-6JGMWF6F.js')).getLogger("conversations");
|
|
203
|
+
logger.debug(
|
|
204
|
+
{
|
|
205
|
+
conversationId,
|
|
206
|
+
visibleMessages: visibleMessages.length,
|
|
207
|
+
visibleTasks: visibleTaskIds.length,
|
|
208
|
+
artifacts: referenceArtifacts.length,
|
|
209
|
+
historyMode: historyConfig.mode
|
|
210
|
+
},
|
|
211
|
+
"Loaded conversation-scoped artifacts"
|
|
212
|
+
);
|
|
213
|
+
return referenceArtifacts;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
const logger = (await import('./logger-6JGMWF6F.js')).getLogger("conversations");
|
|
216
|
+
logger.error(
|
|
217
|
+
{
|
|
218
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
219
|
+
conversationId
|
|
220
|
+
},
|
|
221
|
+
"Failed to get conversation-scoped artifacts"
|
|
222
|
+
);
|
|
223
|
+
return [];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
220
226
|
|
|
221
|
-
export { createDefaultConversationHistoryConfig,
|
|
227
|
+
export { createDefaultConversationHistoryConfig, getConversationScopedArtifacts, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { loadEnvironmentFiles, createDatabaseClient } from '@inkeep/agents-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// src/data/db/dbClient.ts
|
|
5
|
+
loadEnvironmentFiles();
|
|
6
|
+
var envSchema = z.object({
|
|
7
|
+
NODE_ENV: z.enum(["development", "production", "test"]).optional(),
|
|
8
|
+
ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
|
|
9
|
+
DB_FILE_NAME: z.string(),
|
|
10
|
+
TURSO_DATABASE_URL: z.string().optional(),
|
|
11
|
+
TURSO_AUTH_TOKEN: z.string().optional(),
|
|
12
|
+
AGENTS_RUN_API_URL: z.string().optional().default("http://localhost:3003"),
|
|
13
|
+
LOG_LEVEL: z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
|
|
14
|
+
NANGO_SECRET_KEY: z.string().optional(),
|
|
15
|
+
OPENAI_API_KEY: z.string().optional(),
|
|
16
|
+
ANTHROPIC_API_KEY: z.string(),
|
|
17
|
+
INKEEP_AGENTS_RUN_API_BYPASS_SECRET: z.string().optional()
|
|
18
|
+
});
|
|
19
|
+
var parseEnv = () => {
|
|
20
|
+
try {
|
|
21
|
+
const parsedEnv = envSchema.parse(process.env);
|
|
22
|
+
return parsedEnv;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error instanceof z.ZodError) {
|
|
25
|
+
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
26
|
+
throw new Error(
|
|
27
|
+
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|
|
28
|
+
${error.message}`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var env = parseEnv();
|
|
35
|
+
|
|
36
|
+
// src/data/db/dbClient.ts
|
|
37
|
+
var getDbConfig = () => {
|
|
38
|
+
if (env.ENVIRONMENT === "test") {
|
|
39
|
+
return { url: ":memory:" };
|
|
40
|
+
}
|
|
41
|
+
if (env.TURSO_DATABASE_URL && env.TURSO_AUTH_TOKEN) {
|
|
42
|
+
return {
|
|
43
|
+
url: env.TURSO_DATABASE_URL,
|
|
44
|
+
authToken: env.TURSO_AUTH_TOKEN
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
url: env.DB_FILE_NAME
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
var dbClient = createDatabaseClient(getDbConfig());
|
|
52
|
+
var dbClient_default = dbClient;
|
|
53
|
+
|
|
54
|
+
export { dbClient_default, env };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDefaultConversationHistoryConfig, getConversationScopedArtifacts, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse } from './chunk-OFGZSGQI.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dbClient_default as default } from './chunk-PEMWKWTV.js';
|