@inkeep/agents-run-api 0.0.0-dev-20251003195502 → 0.0.0-dev-20251003220013
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-F46V23RK.js → chunk-5GUNCN5X.js} +2 -2
- package/dist/chunk-7IMXW4RD.js +26 -0
- package/dist/{chunk-TWVQBIUL.js → chunk-NZHNG4A3.js} +6 -27
- package/dist/{chunk-USFUAR3Y.js → chunk-XO4RG36I.js} +11 -2
- package/dist/{conversations-AP5WZGWA.js → conversations-6HJ4FX5F.js} +1 -1
- package/dist/dbClient-UQHVUUUY.js +1 -0
- package/dist/index.cjs +17 -15
- package/dist/index.js +9 -17
- package/dist/instrumentation.cjs +43 -1
- package/dist/instrumentation.d.cts +2 -1
- package/dist/instrumentation.d.ts +2 -1
- package/dist/instrumentation.js +1 -1
- package/package.json +2 -2
- package/dist/dbClient-GGR4KMBD.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dbClient_default } from './chunk-
|
|
1
|
+
import { dbClient_default } from './chunk-7IMXW4RD.js';
|
|
2
2
|
import { createMessage, getConversationHistory } from '@inkeep/agents-core';
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
|
|
@@ -189,7 +189,7 @@ async function getConversationScopedArtifacts(params) {
|
|
|
189
189
|
return [];
|
|
190
190
|
}
|
|
191
191
|
const { getLedgerArtifacts } = await import('@inkeep/agents-core');
|
|
192
|
-
const dbClient = (await import('./dbClient-
|
|
192
|
+
const dbClient = (await import('./dbClient-UQHVUUUY.js')).default;
|
|
193
193
|
const visibleTaskIds = visibleMessages.map((msg) => msg.taskId).filter((taskId) => Boolean(taskId));
|
|
194
194
|
const referenceArtifacts = [];
|
|
195
195
|
for (const taskId of visibleTaskIds) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { env } from './chunk-NZHNG4A3.js';
|
|
2
|
+
import { createDatabaseClient } from '@inkeep/agents-core';
|
|
3
|
+
|
|
4
|
+
var getDbConfig = () => {
|
|
5
|
+
if (env.ENVIRONMENT === "test") {
|
|
6
|
+
return { url: ":memory:" };
|
|
7
|
+
}
|
|
8
|
+
if (env.TURSO_DATABASE_URL && env.TURSO_AUTH_TOKEN) {
|
|
9
|
+
return {
|
|
10
|
+
url: env.TURSO_DATABASE_URL,
|
|
11
|
+
authToken: env.TURSO_AUTH_TOKEN
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (!env.DB_FILE_NAME) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
"Database configuration error: DB_FILE_NAME must be set if Turso is not configured."
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
url: env.DB_FILE_NAME
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
var dbClient = createDatabaseClient(getDbConfig());
|
|
24
|
+
var dbClient_default = dbClient;
|
|
25
|
+
|
|
26
|
+
export { dbClient_default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { loadEnvironmentFiles
|
|
1
|
+
import { loadEnvironmentFiles } from '@inkeep/agents-core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
-
// src/
|
|
4
|
+
// src/env.ts
|
|
5
5
|
loadEnvironmentFiles();
|
|
6
6
|
var envSchema = z.object({
|
|
7
7
|
NODE_ENV: z.enum(["development", "production", "test"]).optional(),
|
|
@@ -14,7 +14,9 @@ var envSchema = z.object({
|
|
|
14
14
|
NANGO_SECRET_KEY: z.string().optional(),
|
|
15
15
|
OPENAI_API_KEY: z.string().optional(),
|
|
16
16
|
ANTHROPIC_API_KEY: z.string(),
|
|
17
|
-
INKEEP_AGENTS_RUN_API_BYPASS_SECRET: z.string().optional()
|
|
17
|
+
INKEEP_AGENTS_RUN_API_BYPASS_SECRET: z.string().optional(),
|
|
18
|
+
OTEL_BSP_SCHEDULE_DELAY: z.coerce.number().optional().default(500),
|
|
19
|
+
OTEL_BSP_MAX_EXPORT_BATCH_SIZE: z.coerce.number().optional().default(64)
|
|
18
20
|
});
|
|
19
21
|
var parseEnv = () => {
|
|
20
22
|
try {
|
|
@@ -33,27 +35,4 @@ ${error.message}`
|
|
|
33
35
|
};
|
|
34
36
|
var env = parseEnv();
|
|
35
37
|
|
|
36
|
-
|
|
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
|
-
if (!env.DB_FILE_NAME) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
"Database configuration error: DB_FILE_NAME must be set if Turso is not configured."
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
url: env.DB_FILE_NAME
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
var dbClient = createDatabaseClient(getDbConfig());
|
|
57
|
-
var dbClient_default = dbClient;
|
|
58
|
-
|
|
59
|
-
export { dbClient_default, env };
|
|
38
|
+
export { env };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getLogger } from './chunk-A2S7GSHL.js';
|
|
2
|
+
import { env } from './chunk-NZHNG4A3.js';
|
|
2
3
|
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
3
4
|
import { BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS } from '@opentelemetry/baggage-span-processor';
|
|
4
5
|
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
|
|
@@ -14,7 +15,8 @@ var logger = getLogger("instrumentation");
|
|
|
14
15
|
function createSafeBatchProcessor() {
|
|
15
16
|
try {
|
|
16
17
|
return new BatchSpanProcessor(otlpExporter, {
|
|
17
|
-
scheduledDelayMillis:
|
|
18
|
+
scheduledDelayMillis: env.OTEL_BSP_SCHEDULE_DELAY,
|
|
19
|
+
maxExportBatchSize: env.OTEL_BSP_MAX_EXPORT_BATCH_SIZE
|
|
18
20
|
});
|
|
19
21
|
} catch (error) {
|
|
20
22
|
logger.warn({ error }, "Failed to create batch processor");
|
|
@@ -62,5 +64,12 @@ var defaultSDK = new NodeSDK({
|
|
|
62
64
|
spanProcessors: defaultSpanProcessors,
|
|
63
65
|
instrumentations: defaultInstrumentations
|
|
64
66
|
});
|
|
67
|
+
async function flushBatchProcessor() {
|
|
68
|
+
try {
|
|
69
|
+
await defaultBatchProcessor.forceFlush();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
logger.warn({ error }, "Failed to flush batch processor");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
65
74
|
|
|
66
|
-
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator };
|
|
75
|
+
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator, flushBatchProcessor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createDefaultConversationHistoryConfig, getConversationScopedArtifacts, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse } from './chunk-
|
|
1
|
+
export { createDefaultConversationHistoryConfig, getConversationScopedArtifacts, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse } from './chunk-5GUNCN5X.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dbClient_default as default } from './chunk-7IMXW4RD.js';
|
package/dist/index.cjs
CHANGED
|
@@ -71,7 +71,9 @@ var init_env = __esm({
|
|
|
71
71
|
NANGO_SECRET_KEY: z5.z.string().optional(),
|
|
72
72
|
OPENAI_API_KEY: z5.z.string().optional(),
|
|
73
73
|
ANTHROPIC_API_KEY: z5.z.string(),
|
|
74
|
-
INKEEP_AGENTS_RUN_API_BYPASS_SECRET: z5.z.string().optional()
|
|
74
|
+
INKEEP_AGENTS_RUN_API_BYPASS_SECRET: z5.z.string().optional(),
|
|
75
|
+
OTEL_BSP_SCHEDULE_DELAY: z5.z.coerce.number().optional().default(500),
|
|
76
|
+
OTEL_BSP_MAX_EXPORT_BATCH_SIZE: z5.z.coerce.number().optional().default(64)
|
|
75
77
|
});
|
|
76
78
|
parseEnv = () => {
|
|
77
79
|
try {
|
|
@@ -397,13 +399,15 @@ var init_json_postprocessor = __esm({
|
|
|
397
399
|
init_env();
|
|
398
400
|
|
|
399
401
|
// src/instrumentation.ts
|
|
402
|
+
init_env();
|
|
400
403
|
init_logger();
|
|
401
404
|
var otlpExporter = new exporterTraceOtlpHttp.OTLPTraceExporter();
|
|
402
405
|
var logger = agentsCore.getLogger("instrumentation");
|
|
403
406
|
function createSafeBatchProcessor() {
|
|
404
407
|
try {
|
|
405
408
|
return new sdkTraceBase.BatchSpanProcessor(otlpExporter, {
|
|
406
|
-
scheduledDelayMillis:
|
|
409
|
+
scheduledDelayMillis: env.OTEL_BSP_SCHEDULE_DELAY,
|
|
410
|
+
maxExportBatchSize: env.OTEL_BSP_MAX_EXPORT_BATCH_SIZE
|
|
407
411
|
});
|
|
408
412
|
} catch (error) {
|
|
409
413
|
logger.warn({ error }, "Failed to create batch processor");
|
|
@@ -451,6 +455,13 @@ new sdkNode.NodeSDK({
|
|
|
451
455
|
spanProcessors: defaultSpanProcessors,
|
|
452
456
|
instrumentations: defaultInstrumentations
|
|
453
457
|
});
|
|
458
|
+
async function flushBatchProcessor() {
|
|
459
|
+
try {
|
|
460
|
+
await defaultBatchProcessor.forceFlush();
|
|
461
|
+
} catch (error) {
|
|
462
|
+
logger.warn({ error }, "Failed to flush batch processor");
|
|
463
|
+
}
|
|
464
|
+
}
|
|
454
465
|
|
|
455
466
|
// src/app.ts
|
|
456
467
|
init_logger();
|
|
@@ -3175,7 +3186,6 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
3175
3186
|
return { summaries: [] };
|
|
3176
3187
|
} finally {
|
|
3177
3188
|
span.end();
|
|
3178
|
-
await defaultBatchProcessor.forceFlush();
|
|
3179
3189
|
}
|
|
3180
3190
|
}
|
|
3181
3191
|
);
|
|
@@ -3594,7 +3604,6 @@ Make it specific and relevant.`;
|
|
|
3594
3604
|
);
|
|
3595
3605
|
} finally {
|
|
3596
3606
|
span.end();
|
|
3597
|
-
await defaultBatchProcessor.forceFlush();
|
|
3598
3607
|
}
|
|
3599
3608
|
}
|
|
3600
3609
|
);
|
|
@@ -4152,7 +4161,6 @@ var ResponseFormatter = class {
|
|
|
4152
4161
|
};
|
|
4153
4162
|
} finally {
|
|
4154
4163
|
span.end();
|
|
4155
|
-
await defaultBatchProcessor.forceFlush();
|
|
4156
4164
|
}
|
|
4157
4165
|
});
|
|
4158
4166
|
}
|
|
@@ -4203,7 +4211,6 @@ var ResponseFormatter = class {
|
|
|
4203
4211
|
return { text: responseText };
|
|
4204
4212
|
} finally {
|
|
4205
4213
|
span.end();
|
|
4206
|
-
await defaultBatchProcessor.forceFlush();
|
|
4207
4214
|
}
|
|
4208
4215
|
});
|
|
4209
4216
|
}
|
|
@@ -7090,7 +7097,6 @@ var Agent = class {
|
|
|
7090
7097
|
requestContext: requestContext || {},
|
|
7091
7098
|
tenantId: this.config.tenantId
|
|
7092
7099
|
});
|
|
7093
|
-
await defaultBatchProcessor.forceFlush();
|
|
7094
7100
|
const contextWithBuiltins = {
|
|
7095
7101
|
...result.resolvedContext,
|
|
7096
7102
|
$now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -7629,7 +7635,6 @@ var Agent = class {
|
|
|
7629
7635
|
throw err;
|
|
7630
7636
|
} finally {
|
|
7631
7637
|
childSpan.end();
|
|
7632
|
-
await defaultBatchProcessor.forceFlush();
|
|
7633
7638
|
}
|
|
7634
7639
|
}
|
|
7635
7640
|
);
|
|
@@ -8060,7 +8065,6 @@ ${output}${structureHintsFormatted}`;
|
|
|
8060
8065
|
}
|
|
8061
8066
|
span.setStatus({ code: api.SpanStatusCode.OK });
|
|
8062
8067
|
span.end();
|
|
8063
|
-
await defaultBatchProcessor.forceFlush();
|
|
8064
8068
|
let formattedContent = response.formattedContent || null;
|
|
8065
8069
|
if (!formattedContent) {
|
|
8066
8070
|
const session = toolSessionManager.getSession(sessionId);
|
|
@@ -9626,7 +9630,6 @@ var ExecutionHandler = class {
|
|
|
9626
9630
|
throw error;
|
|
9627
9631
|
} finally {
|
|
9628
9632
|
span.end();
|
|
9629
|
-
await defaultBatchProcessor.forceFlush();
|
|
9630
9633
|
}
|
|
9631
9634
|
});
|
|
9632
9635
|
}
|
|
@@ -10153,7 +10156,6 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
10153
10156
|
dbClient: dbClient_default,
|
|
10154
10157
|
credentialStores
|
|
10155
10158
|
});
|
|
10156
|
-
await defaultBatchProcessor.forceFlush();
|
|
10157
10159
|
const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
|
|
10158
10160
|
const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
|
|
10159
10161
|
logger23.info({ userText, lastUserMessage }, "userText");
|
|
@@ -10961,19 +10963,19 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10961
10963
|
setupOpenAPIRoutes(app6);
|
|
10962
10964
|
app6.use("/tenants/*", async (_c, next) => {
|
|
10963
10965
|
await next();
|
|
10964
|
-
await
|
|
10966
|
+
await flushBatchProcessor();
|
|
10965
10967
|
});
|
|
10966
10968
|
app6.use("/agents/*", async (_c, next) => {
|
|
10967
10969
|
await next();
|
|
10968
|
-
await
|
|
10970
|
+
await flushBatchProcessor();
|
|
10969
10971
|
});
|
|
10970
10972
|
app6.use("/v1/*", async (_c, next) => {
|
|
10971
10973
|
await next();
|
|
10972
|
-
await
|
|
10974
|
+
await flushBatchProcessor();
|
|
10973
10975
|
});
|
|
10974
10976
|
app6.use("/api/*", async (_c, next) => {
|
|
10975
10977
|
await next();
|
|
10976
|
-
await
|
|
10978
|
+
await flushBatchProcessor();
|
|
10977
10979
|
});
|
|
10978
10980
|
const baseApp = new hono.Hono();
|
|
10979
10981
|
baseApp.route("/", app6);
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { flushBatchProcessor } from './chunk-XO4RG36I.js';
|
|
2
2
|
import { getLogger } from './chunk-A2S7GSHL.js';
|
|
3
|
-
import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-
|
|
4
|
-
import { dbClient_default
|
|
3
|
+
import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-5GUNCN5X.js';
|
|
4
|
+
import { dbClient_default } from './chunk-7IMXW4RD.js';
|
|
5
|
+
import { env } from './chunk-NZHNG4A3.js';
|
|
5
6
|
import { __publicField } from './chunk-PKBMQBKP.js';
|
|
6
7
|
import { getLogger as getLogger$1, getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentGraphWithDefaultAgent, contextValidationMiddleware, getFullGraph, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getAgentById, handleContextResolution, createMessage, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, getAgentGraphById, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getRelatedAgentsForGraph, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getContextConfigById, getFullGraphDefinition, TemplateEngine, graphHasArtifactComponents, MCPTransportType, getExternalAgent } from '@inkeep/agents-core';
|
|
7
8
|
import { otel } from '@hono/otel';
|
|
@@ -2709,7 +2710,6 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2709
2710
|
return { summaries: [] };
|
|
2710
2711
|
} finally {
|
|
2711
2712
|
span.end();
|
|
2712
|
-
await defaultBatchProcessor.forceFlush();
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
2715
|
);
|
|
@@ -3128,7 +3128,6 @@ Make it specific and relevant.`;
|
|
|
3128
3128
|
);
|
|
3129
3129
|
} finally {
|
|
3130
3130
|
span.end();
|
|
3131
|
-
await defaultBatchProcessor.forceFlush();
|
|
3132
3131
|
}
|
|
3133
3132
|
}
|
|
3134
3133
|
);
|
|
@@ -3684,7 +3683,6 @@ var ResponseFormatter = class {
|
|
|
3684
3683
|
};
|
|
3685
3684
|
} finally {
|
|
3686
3685
|
span.end();
|
|
3687
|
-
await defaultBatchProcessor.forceFlush();
|
|
3688
3686
|
}
|
|
3689
3687
|
});
|
|
3690
3688
|
}
|
|
@@ -3735,7 +3733,6 @@ var ResponseFormatter = class {
|
|
|
3735
3733
|
return { text: responseText };
|
|
3736
3734
|
} finally {
|
|
3737
3735
|
span.end();
|
|
3738
|
-
await defaultBatchProcessor.forceFlush();
|
|
3739
3736
|
}
|
|
3740
3737
|
});
|
|
3741
3738
|
}
|
|
@@ -6607,7 +6604,6 @@ var Agent = class {
|
|
|
6607
6604
|
requestContext: requestContext || {},
|
|
6608
6605
|
tenantId: this.config.tenantId
|
|
6609
6606
|
});
|
|
6610
|
-
await defaultBatchProcessor.forceFlush();
|
|
6611
6607
|
const contextWithBuiltins = {
|
|
6612
6608
|
...result.resolvedContext,
|
|
6613
6609
|
$now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -6777,7 +6773,7 @@ var Agent = class {
|
|
|
6777
6773
|
inputSchema: tool3.inputSchema || tool3.parameters || {},
|
|
6778
6774
|
usageGuidelines: name.startsWith("transfer_to_") || name.startsWith("delegate_to_") ? `Use this tool to ${name.startsWith("transfer_to_") ? "transfer" : "delegate"} to another agent when appropriate.` : "Use this tool when appropriate for the task at hand."
|
|
6779
6775
|
}));
|
|
6780
|
-
const { getConversationScopedArtifacts } = await import('./conversations-
|
|
6776
|
+
const { getConversationScopedArtifacts } = await import('./conversations-6HJ4FX5F.js');
|
|
6781
6777
|
const historyConfig = this.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
|
|
6782
6778
|
const referenceArtifacts = await getConversationScopedArtifacts({
|
|
6783
6779
|
tenantId: this.config.tenantId,
|
|
@@ -7146,7 +7142,6 @@ var Agent = class {
|
|
|
7146
7142
|
throw err;
|
|
7147
7143
|
} finally {
|
|
7148
7144
|
childSpan.end();
|
|
7149
|
-
await defaultBatchProcessor.forceFlush();
|
|
7150
7145
|
}
|
|
7151
7146
|
}
|
|
7152
7147
|
);
|
|
@@ -7577,7 +7572,6 @@ ${output}${structureHintsFormatted}`;
|
|
|
7577
7572
|
}
|
|
7578
7573
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
7579
7574
|
span.end();
|
|
7580
|
-
await defaultBatchProcessor.forceFlush();
|
|
7581
7575
|
let formattedContent = response.formattedContent || null;
|
|
7582
7576
|
if (!formattedContent) {
|
|
7583
7577
|
const session = toolSessionManager.getSession(sessionId);
|
|
@@ -9129,7 +9123,6 @@ var ExecutionHandler = class {
|
|
|
9129
9123
|
throw error;
|
|
9130
9124
|
} finally {
|
|
9131
9125
|
span.end();
|
|
9132
|
-
await defaultBatchProcessor.forceFlush();
|
|
9133
9126
|
}
|
|
9134
9127
|
});
|
|
9135
9128
|
}
|
|
@@ -9651,7 +9644,6 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
9651
9644
|
dbClient: dbClient_default,
|
|
9652
9645
|
credentialStores
|
|
9653
9646
|
});
|
|
9654
|
-
await defaultBatchProcessor.forceFlush();
|
|
9655
9647
|
const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
|
|
9656
9648
|
const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
|
|
9657
9649
|
logger22.info({ userText, lastUserMessage }, "userText");
|
|
@@ -10455,19 +10447,19 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10455
10447
|
setupOpenAPIRoutes(app6);
|
|
10456
10448
|
app6.use("/tenants/*", async (_c, next) => {
|
|
10457
10449
|
await next();
|
|
10458
|
-
await
|
|
10450
|
+
await flushBatchProcessor();
|
|
10459
10451
|
});
|
|
10460
10452
|
app6.use("/agents/*", async (_c, next) => {
|
|
10461
10453
|
await next();
|
|
10462
|
-
await
|
|
10454
|
+
await flushBatchProcessor();
|
|
10463
10455
|
});
|
|
10464
10456
|
app6.use("/v1/*", async (_c, next) => {
|
|
10465
10457
|
await next();
|
|
10466
|
-
await
|
|
10458
|
+
await flushBatchProcessor();
|
|
10467
10459
|
});
|
|
10468
10460
|
app6.use("/api/*", async (_c, next) => {
|
|
10469
10461
|
await next();
|
|
10470
|
-
await
|
|
10462
|
+
await flushBatchProcessor();
|
|
10471
10463
|
});
|
|
10472
10464
|
const baseApp = new Hono();
|
|
10473
10465
|
baseApp.route("/", app6);
|
package/dist/instrumentation.cjs
CHANGED
|
@@ -10,8 +10,41 @@ var sdkNode = require('@opentelemetry/sdk-node');
|
|
|
10
10
|
var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
11
11
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
12
12
|
var agentsCore = require('@inkeep/agents-core');
|
|
13
|
+
var zod = require('zod');
|
|
13
14
|
|
|
14
15
|
// src/instrumentation.ts
|
|
16
|
+
agentsCore.loadEnvironmentFiles();
|
|
17
|
+
var envSchema = zod.z.object({
|
|
18
|
+
NODE_ENV: zod.z.enum(["development", "production", "test"]).optional(),
|
|
19
|
+
ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
|
|
20
|
+
DB_FILE_NAME: zod.z.string().optional(),
|
|
21
|
+
TURSO_DATABASE_URL: zod.z.string().optional(),
|
|
22
|
+
TURSO_AUTH_TOKEN: zod.z.string().optional(),
|
|
23
|
+
AGENTS_RUN_API_URL: zod.z.string().optional().default("http://localhost:3003"),
|
|
24
|
+
LOG_LEVEL: zod.z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
|
|
25
|
+
NANGO_SECRET_KEY: zod.z.string().optional(),
|
|
26
|
+
OPENAI_API_KEY: zod.z.string().optional(),
|
|
27
|
+
ANTHROPIC_API_KEY: zod.z.string(),
|
|
28
|
+
INKEEP_AGENTS_RUN_API_BYPASS_SECRET: zod.z.string().optional(),
|
|
29
|
+
OTEL_BSP_SCHEDULE_DELAY: zod.z.coerce.number().optional().default(500),
|
|
30
|
+
OTEL_BSP_MAX_EXPORT_BATCH_SIZE: zod.z.coerce.number().optional().default(64)
|
|
31
|
+
});
|
|
32
|
+
var parseEnv = () => {
|
|
33
|
+
try {
|
|
34
|
+
const parsedEnv = envSchema.parse(process.env);
|
|
35
|
+
return parsedEnv;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof zod.z.ZodError) {
|
|
38
|
+
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
39
|
+
throw new Error(
|
|
40
|
+
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|
|
41
|
+
${error.message}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var env = parseEnv();
|
|
15
48
|
|
|
16
49
|
// src/instrumentation.ts
|
|
17
50
|
var otlpExporter = new exporterTraceOtlpHttp.OTLPTraceExporter();
|
|
@@ -19,7 +52,8 @@ var logger = agentsCore.getLogger("instrumentation");
|
|
|
19
52
|
function createSafeBatchProcessor() {
|
|
20
53
|
try {
|
|
21
54
|
return new sdkTraceBase.BatchSpanProcessor(otlpExporter, {
|
|
22
|
-
scheduledDelayMillis:
|
|
55
|
+
scheduledDelayMillis: env.OTEL_BSP_SCHEDULE_DELAY,
|
|
56
|
+
maxExportBatchSize: env.OTEL_BSP_MAX_EXPORT_BATCH_SIZE
|
|
23
57
|
});
|
|
24
58
|
} catch (error) {
|
|
25
59
|
logger.warn({ error }, "Failed to create batch processor");
|
|
@@ -67,6 +101,13 @@ var defaultSDK = new sdkNode.NodeSDK({
|
|
|
67
101
|
spanProcessors: defaultSpanProcessors,
|
|
68
102
|
instrumentations: defaultInstrumentations
|
|
69
103
|
});
|
|
104
|
+
async function flushBatchProcessor() {
|
|
105
|
+
try {
|
|
106
|
+
await defaultBatchProcessor.forceFlush();
|
|
107
|
+
} catch (error) {
|
|
108
|
+
logger.warn({ error }, "Failed to flush batch processor");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
70
111
|
|
|
71
112
|
exports.defaultBatchProcessor = defaultBatchProcessor;
|
|
72
113
|
exports.defaultContextManager = defaultContextManager;
|
|
@@ -75,3 +116,4 @@ exports.defaultResource = defaultResource;
|
|
|
75
116
|
exports.defaultSDK = defaultSDK;
|
|
76
117
|
exports.defaultSpanProcessors = defaultSpanProcessors;
|
|
77
118
|
exports.defaultTextMapPropagator = defaultTextMapPropagator;
|
|
119
|
+
exports.flushBatchProcessor = flushBatchProcessor;
|
|
@@ -11,5 +11,6 @@ declare const defaultSpanProcessors: SpanProcessor[];
|
|
|
11
11
|
declare const defaultContextManager: AsyncLocalStorageContextManager;
|
|
12
12
|
declare const defaultTextMapPropagator: CompositePropagator;
|
|
13
13
|
declare const defaultSDK: NodeSDK;
|
|
14
|
+
declare function flushBatchProcessor(): Promise<void>;
|
|
14
15
|
|
|
15
|
-
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator };
|
|
16
|
+
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator, flushBatchProcessor };
|
|
@@ -11,5 +11,6 @@ declare const defaultSpanProcessors: SpanProcessor[];
|
|
|
11
11
|
declare const defaultContextManager: AsyncLocalStorageContextManager;
|
|
12
12
|
declare const defaultTextMapPropagator: CompositePropagator;
|
|
13
13
|
declare const defaultSDK: NodeSDK;
|
|
14
|
+
declare function flushBatchProcessor(): Promise<void>;
|
|
14
15
|
|
|
15
|
-
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator };
|
|
16
|
+
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator, flushBatchProcessor };
|
package/dist/instrumentation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator } from './chunk-
|
|
1
|
+
export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator, flushBatchProcessor } from './chunk-XO4RG36I.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20251003220013",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"traverse": "^0.6.11",
|
|
52
52
|
"ts-pattern": "^5.7.1",
|
|
53
53
|
"zod": "^4.1.11",
|
|
54
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
54
|
+
"@inkeep/agents-core": "^0.0.0-dev-20251003220013"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
57
|
"keytar": "^7.9.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { dbClient_default as default } from './chunk-TWVQBIUL.js';
|