@inkeep/agents-run-api 0.0.0-dev-20250910233133 → 0.0.0-dev-20250910233441
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-3COYP2VE.js +70 -0
- package/dist/chunk-JIWNRFDU.js +236 -0
- package/dist/chunk-PKBMQBKP.js +5 -0
- package/dist/conversations-YTJWHN67.js +1 -0
- package/dist/index.cjs +9060 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +13 -9
- package/dist/index.js +8633 -27
- package/dist/instrumentation-KKYHA3A3.js +1 -0
- package/package.json +3 -3
- package/dist/__tests__/setup.d.ts +0 -4
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/setup.js +0 -80
- package/dist/__tests__/utils/testProject.d.ts +0 -18
- package/dist/__tests__/utils/testProject.d.ts.map +0 -1
- package/dist/__tests__/utils/testProject.js +0 -26
- package/dist/__tests__/utils/testRequest.d.ts +0 -8
- package/dist/__tests__/utils/testRequest.d.ts.map +0 -1
- package/dist/__tests__/utils/testRequest.js +0 -32
- package/dist/__tests__/utils/testTenant.d.ts +0 -64
- package/dist/__tests__/utils/testTenant.d.ts.map +0 -1
- package/dist/__tests__/utils/testTenant.js +0 -71
- package/dist/a2a/client.d.ts +0 -182
- package/dist/a2a/client.d.ts.map +0 -1
- package/dist/a2a/client.js +0 -645
- package/dist/a2a/handlers.d.ts +0 -4
- package/dist/a2a/handlers.d.ts.map +0 -1
- package/dist/a2a/handlers.js +0 -656
- package/dist/a2a/transfer.d.ts +0 -18
- package/dist/a2a/transfer.d.ts.map +0 -1
- package/dist/a2a/transfer.js +0 -22
- package/dist/a2a/types.d.ts +0 -63
- package/dist/a2a/types.d.ts.map +0 -1
- package/dist/a2a/types.js +0 -1
- package/dist/agents/Agent.d.ts +0 -151
- package/dist/agents/Agent.d.ts.map +0 -1
- package/dist/agents/Agent.js +0 -1164
- package/dist/agents/ModelFactory.d.ts +0 -62
- package/dist/agents/ModelFactory.d.ts.map +0 -1
- package/dist/agents/ModelFactory.js +0 -208
- package/dist/agents/SystemPromptBuilder.d.ts +0 -14
- package/dist/agents/SystemPromptBuilder.d.ts.map +0 -1
- package/dist/agents/SystemPromptBuilder.js +0 -62
- package/dist/agents/ToolSessionManager.d.ts +0 -53
- package/dist/agents/ToolSessionManager.d.ts.map +0 -1
- package/dist/agents/ToolSessionManager.js +0 -106
- package/dist/agents/artifactTools.d.ts +0 -30
- package/dist/agents/artifactTools.d.ts.map +0 -1
- package/dist/agents/artifactTools.js +0 -463
- package/dist/agents/generateTaskHandler.d.ts +0 -41
- package/dist/agents/generateTaskHandler.d.ts.map +0 -1
- package/dist/agents/generateTaskHandler.js +0 -350
- package/dist/agents/relationTools.d.ts +0 -35
- package/dist/agents/relationTools.d.ts.map +0 -1
- package/dist/agents/relationTools.js +0 -246
- package/dist/agents/types.d.ts +0 -23
- package/dist/agents/types.d.ts.map +0 -1
- package/dist/agents/types.js +0 -1
- package/dist/agents/versions/V1Config.d.ts +0 -21
- package/dist/agents/versions/V1Config.d.ts.map +0 -1
- package/dist/agents/versions/V1Config.js +0 -285
- package/dist/app.d.ts +0 -5
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -219
- package/dist/data/agentGraph.d.ts +0 -4
- package/dist/data/agentGraph.d.ts.map +0 -1
- package/dist/data/agentGraph.js +0 -73
- package/dist/data/agents.d.ts +0 -4
- package/dist/data/agents.d.ts.map +0 -1
- package/dist/data/agents.js +0 -78
- package/dist/data/conversations.d.ts +0 -59
- package/dist/data/conversations.d.ts.map +0 -1
- package/dist/data/conversations.js +0 -216
- package/dist/data/db/clean.d.ts +0 -6
- package/dist/data/db/clean.d.ts.map +0 -1
- package/dist/data/db/clean.js +0 -77
- package/dist/data/db/dbClient.d.ts +0 -3
- package/dist/data/db/dbClient.d.ts.map +0 -1
- package/dist/data/db/dbClient.js +0 -13
- package/dist/env.d.ts +0 -45
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -64
- package/dist/handlers/executionHandler.d.ts +0 -36
- package/dist/handlers/executionHandler.d.ts.map +0 -1
- package/dist/handlers/executionHandler.js +0 -415
- package/dist/index.d.ts.map +0 -1
- package/dist/instrumentation.d.ts +0 -13
- package/dist/instrumentation.d.ts.map +0 -1
- package/dist/instrumentation.js +0 -66
- package/dist/logger.d.ts +0 -4
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -32
- package/dist/middleware/api-key-auth.d.ts +0 -22
- package/dist/middleware/api-key-auth.d.ts.map +0 -1
- package/dist/middleware/api-key-auth.js +0 -162
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/index.js +0 -1
- package/dist/openapi.d.ts +0 -2
- package/dist/openapi.d.ts.map +0 -1
- package/dist/openapi.js +0 -36
- package/dist/routes/agents.d.ts +0 -10
- package/dist/routes/agents.d.ts.map +0 -1
- package/dist/routes/agents.js +0 -158
- package/dist/routes/chat.d.ts +0 -10
- package/dist/routes/chat.d.ts.map +0 -1
- package/dist/routes/chat.js +0 -307
- package/dist/routes/chatDataStream.d.ts +0 -10
- package/dist/routes/chatDataStream.d.ts.map +0 -1
- package/dist/routes/chatDataStream.js +0 -185
- package/dist/routes/mcp.d.ts +0 -10
- package/dist/routes/mcp.d.ts.map +0 -1
- package/dist/routes/mcp.js +0 -500
- package/dist/tracer.d.ts +0 -24
- package/dist/tracer.d.ts.map +0 -1
- package/dist/tracer.js +0 -107
- package/dist/types/chat.d.ts +0 -25
- package/dist/types/chat.d.ts.map +0 -1
- package/dist/types/chat.js +0 -1
- package/dist/types/execution-context.d.ts +0 -14
- package/dist/types/execution-context.d.ts.map +0 -1
- package/dist/types/execution-context.js +0 -14
- package/dist/utils/agent-operations.d.ts +0 -93
- package/dist/utils/agent-operations.d.ts.map +0 -1
- package/dist/utils/agent-operations.js +0 -78
- package/dist/utils/artifact-component-schema.d.ts +0 -29
- package/dist/utils/artifact-component-schema.d.ts.map +0 -1
- package/dist/utils/artifact-component-schema.js +0 -119
- package/dist/utils/artifact-parser.d.ts +0 -71
- package/dist/utils/artifact-parser.d.ts.map +0 -1
- package/dist/utils/artifact-parser.js +0 -253
- package/dist/utils/cleanup.d.ts +0 -19
- package/dist/utils/cleanup.d.ts.map +0 -1
- package/dist/utils/cleanup.js +0 -66
- package/dist/utils/data-component-schema.d.ts +0 -6
- package/dist/utils/data-component-schema.d.ts.map +0 -1
- package/dist/utils/data-component-schema.js +0 -43
- package/dist/utils/graph-session.d.ts +0 -230
- package/dist/utils/graph-session.d.ts.map +0 -1
- package/dist/utils/graph-session.js +0 -1199
- package/dist/utils/incremental-stream-parser.d.ts +0 -62
- package/dist/utils/incremental-stream-parser.d.ts.map +0 -1
- package/dist/utils/incremental-stream-parser.js +0 -330
- package/dist/utils/response-formatter.d.ts +0 -26
- package/dist/utils/response-formatter.d.ts.map +0 -1
- package/dist/utils/response-formatter.js +0 -158
- package/dist/utils/stream-helpers.d.ts +0 -186
- package/dist/utils/stream-helpers.d.ts.map +0 -1
- package/dist/utils/stream-helpers.js +0 -603
- package/dist/utils/stream-registry.d.ts +0 -18
- package/dist/utils/stream-registry.d.ts.map +0 -1
- package/dist/utils/stream-registry.js +0 -33
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
2
|
+
import { BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS } from '@opentelemetry/baggage-span-processor';
|
|
3
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
|
4
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
5
|
+
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';
|
|
6
|
+
|
|
7
|
+
// src/instrumentation.ts
|
|
8
|
+
var otlpUrl = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:14318/v1/traces";
|
|
9
|
+
var otlpExporter = new OTLPTraceExporter({ url: otlpUrl });
|
|
10
|
+
var FanOutSpanProcessor = class {
|
|
11
|
+
constructor(inner) {
|
|
12
|
+
this.inner = inner;
|
|
13
|
+
}
|
|
14
|
+
onStart(span, parent) {
|
|
15
|
+
this.inner.forEach((p) => p.onStart(span, parent));
|
|
16
|
+
}
|
|
17
|
+
onEnd(span) {
|
|
18
|
+
this.inner.forEach((p) => p.onEnd(span));
|
|
19
|
+
}
|
|
20
|
+
forceFlush() {
|
|
21
|
+
return Promise.all(this.inner.map((p) => p.forceFlush?.())).then(() => {
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
shutdown() {
|
|
25
|
+
return Promise.all(this.inner.map((p) => p.shutdown?.())).then(() => {
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var spanProcessor = new FanOutSpanProcessor([
|
|
30
|
+
new BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS),
|
|
31
|
+
new BatchSpanProcessor(otlpExporter, {
|
|
32
|
+
maxExportBatchSize: 1,
|
|
33
|
+
// Send immediately (vs 512)
|
|
34
|
+
scheduledDelayMillis: 100,
|
|
35
|
+
// 100ms delay (vs 5000ms)
|
|
36
|
+
exportTimeoutMillis: 5e3,
|
|
37
|
+
// 5s timeout (vs 30s)
|
|
38
|
+
maxQueueSize: 512
|
|
39
|
+
// Smaller queue
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
42
|
+
var sdk = new NodeSDK({
|
|
43
|
+
serviceName: "inkeep-chat",
|
|
44
|
+
spanProcessor,
|
|
45
|
+
instrumentations: [
|
|
46
|
+
getNodeAutoInstrumentations({
|
|
47
|
+
"@opentelemetry/instrumentation-http": {
|
|
48
|
+
enabled: true,
|
|
49
|
+
requestHook: (span, request) => {
|
|
50
|
+
const url = request?.url ?? request?.path;
|
|
51
|
+
if (!url) return;
|
|
52
|
+
const u = new URL(url, "http://localhost");
|
|
53
|
+
span.updateName(`${request?.method || "UNKNOWN"} ${u.pathname}`);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"@opentelemetry/instrumentation-undici": {
|
|
57
|
+
requestHook: (span) => {
|
|
58
|
+
const method = span.attributes?.["http.request.method"];
|
|
59
|
+
const host = span.attributes?.["server.address"];
|
|
60
|
+
const path = span.attributes?.["url.path"];
|
|
61
|
+
if (method && path)
|
|
62
|
+
span.updateName(host ? `${method} ${host}${path}` : `${method} ${path}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
sdk.start();
|
|
69
|
+
|
|
70
|
+
export { sdk, spanProcessor };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { createDatabaseClient, createMessage, getConversationHistory } from '@inkeep/agents-core';
|
|
2
|
+
import { nanoid } from 'nanoid';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import * as dotenv from 'dotenv';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
// src/data/conversations.ts
|
|
9
|
+
dotenv.config({ quiet: true });
|
|
10
|
+
z.enum(["development", "production"]).default("development");
|
|
11
|
+
var environmentSchema = z.enum(["development", "pentest", "production", "test"]);
|
|
12
|
+
var criticalEnv = z.object({
|
|
13
|
+
ENVIRONMENT: environmentSchema
|
|
14
|
+
}).parse(process.env);
|
|
15
|
+
var loadEnvFile = () => {
|
|
16
|
+
const envPath = path.resolve(process.cwd(), `.env.${criticalEnv.ENVIRONMENT}.nonsecret`);
|
|
17
|
+
if (fs.existsSync(envPath)) {
|
|
18
|
+
const envConfig = dotenv.parse(fs.readFileSync(envPath));
|
|
19
|
+
for (const k in envConfig) {
|
|
20
|
+
if (!(k in process.env)) {
|
|
21
|
+
process.env[k] = envConfig[k];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
loadEnvFile();
|
|
27
|
+
var envSchema = z.object({
|
|
28
|
+
NODE_ENV: z.enum(["development", "production", "test"]).optional(),
|
|
29
|
+
ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
|
|
30
|
+
DB_FILE_NAME: z.string().default("file:../local.db"),
|
|
31
|
+
PORT: z.coerce.number().optional().default(3003),
|
|
32
|
+
AGENT_BASE_URL: z.string().optional(),
|
|
33
|
+
LOG_LEVEL: z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
|
|
34
|
+
NANGO_SECRET_KEY: z.string().optional(),
|
|
35
|
+
OPENAI_API_KEY: z.string().optional(),
|
|
36
|
+
ANTHROPIC_API_KEY: z.string(),
|
|
37
|
+
INKEEP_AGENTS_RUN_BYPASS_SECRET: z.string().optional(),
|
|
38
|
+
OTEL_TRACES_FORCE_FLUSH_ENABLED: z.stringbool().optional()
|
|
39
|
+
});
|
|
40
|
+
var parseEnv = () => {
|
|
41
|
+
try {
|
|
42
|
+
const parsedEnv = envSchema.parse(process.env);
|
|
43
|
+
if (!parsedEnv.AGENT_BASE_URL) {
|
|
44
|
+
parsedEnv.AGENT_BASE_URL = `http://localhost:${parsedEnv.PORT}`;
|
|
45
|
+
}
|
|
46
|
+
return parsedEnv;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error instanceof z.ZodError) {
|
|
49
|
+
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
50
|
+
throw new Error(
|
|
51
|
+
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|
|
52
|
+
${error.message}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var env = parseEnv();
|
|
59
|
+
|
|
60
|
+
// src/data/db/dbClient.ts
|
|
61
|
+
var getDbUrl = () => {
|
|
62
|
+
if (env.ENVIRONMENT === "test") {
|
|
63
|
+
return ":memory:";
|
|
64
|
+
}
|
|
65
|
+
return env.DB_FILE_NAME;
|
|
66
|
+
};
|
|
67
|
+
var dbClient = createDatabaseClient({ url: getDbUrl() });
|
|
68
|
+
var dbClient_default = dbClient;
|
|
69
|
+
|
|
70
|
+
// src/data/conversations.ts
|
|
71
|
+
function createDefaultConversationHistoryConfig(mode = "full") {
|
|
72
|
+
return {
|
|
73
|
+
mode,
|
|
74
|
+
limit: 50,
|
|
75
|
+
includeInternal: true,
|
|
76
|
+
messageTypes: ["chat"],
|
|
77
|
+
maxOutputTokens: 4e3
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function extractA2AMessageText(parts) {
|
|
81
|
+
return parts.filter((part) => part.kind === "text" && part.text).map((part) => part.text).join("");
|
|
82
|
+
}
|
|
83
|
+
async function saveA2AMessageResponse(response, params) {
|
|
84
|
+
if (response.error) {
|
|
85
|
+
throw new Error(response.error.message);
|
|
86
|
+
}
|
|
87
|
+
let messageText = "";
|
|
88
|
+
if (response.result.kind === "message") {
|
|
89
|
+
messageText = extractA2AMessageText(response.result.parts);
|
|
90
|
+
} else if (response.result.kind === "task") {
|
|
91
|
+
if (response.result.artifacts && response.result.artifacts.length > 0) {
|
|
92
|
+
const firstArtifact = response.result.artifacts[0];
|
|
93
|
+
if (firstArtifact.parts) {
|
|
94
|
+
messageText = extractA2AMessageText(firstArtifact.parts);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} else if (typeof response.result === "string") {
|
|
98
|
+
messageText = response.result;
|
|
99
|
+
}
|
|
100
|
+
if (!messageText || messageText.trim() === "") {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return await createMessage(dbClient_default)({
|
|
104
|
+
id: nanoid(),
|
|
105
|
+
tenantId: params.tenantId,
|
|
106
|
+
projectId: params.projectId,
|
|
107
|
+
conversationId: params.conversationId,
|
|
108
|
+
role: "agent",
|
|
109
|
+
content: {
|
|
110
|
+
text: messageText
|
|
111
|
+
},
|
|
112
|
+
visibility: params.visibility,
|
|
113
|
+
messageType: params.messageType,
|
|
114
|
+
fromAgentId: params.fromAgentId,
|
|
115
|
+
toAgentId: params.toAgentId,
|
|
116
|
+
fromExternalAgentId: params.fromExternalAgentId,
|
|
117
|
+
toExternalAgentId: params.toExternalAgentId,
|
|
118
|
+
a2aTaskId: params.a2aTaskId,
|
|
119
|
+
a2aSessionId: params.a2aSessionId,
|
|
120
|
+
metadata: params.metadata
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async function getScopedHistory({
|
|
124
|
+
tenantId,
|
|
125
|
+
projectId,
|
|
126
|
+
conversationId,
|
|
127
|
+
filters,
|
|
128
|
+
options
|
|
129
|
+
}) {
|
|
130
|
+
try {
|
|
131
|
+
const messages = await getConversationHistory(dbClient_default)({
|
|
132
|
+
scopes: { tenantId, projectId },
|
|
133
|
+
conversationId,
|
|
134
|
+
options
|
|
135
|
+
});
|
|
136
|
+
if (!filters || !filters.agentId && !filters.taskId) {
|
|
137
|
+
return messages;
|
|
138
|
+
}
|
|
139
|
+
const relevantMessages = messages.filter((msg) => {
|
|
140
|
+
if (msg.role === "user") return true;
|
|
141
|
+
let matchesAgent = true;
|
|
142
|
+
let matchesTask = true;
|
|
143
|
+
if (filters.agentId) {
|
|
144
|
+
matchesAgent = msg.role === "agent" && msg.visibility === "user-facing" || msg.toAgentId === filters.agentId || msg.fromAgentId === filters.agentId;
|
|
145
|
+
}
|
|
146
|
+
if (filters.taskId) {
|
|
147
|
+
matchesTask = msg.taskId === filters.taskId || msg.a2aTaskId === filters.taskId;
|
|
148
|
+
}
|
|
149
|
+
if (filters.agentId && filters.taskId) {
|
|
150
|
+
return matchesAgent && matchesTask;
|
|
151
|
+
}
|
|
152
|
+
if (filters.agentId) {
|
|
153
|
+
return matchesAgent;
|
|
154
|
+
}
|
|
155
|
+
if (filters.taskId) {
|
|
156
|
+
return matchesTask;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
});
|
|
160
|
+
return relevantMessages;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.error("Failed to fetch scoped messages:", error);
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function getUserFacingHistory(tenantId, projectId, conversationId, limit = 50) {
|
|
167
|
+
return await getConversationHistory(dbClient_default)({
|
|
168
|
+
scopes: { tenantId, projectId },
|
|
169
|
+
conversationId,
|
|
170
|
+
options: {
|
|
171
|
+
limit,
|
|
172
|
+
includeInternal: false,
|
|
173
|
+
messageTypes: ["chat"]
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
async function getFullConversationContext(tenantId, projectId, conversationId, maxTokens) {
|
|
178
|
+
return await getConversationHistory(dbClient_default)({
|
|
179
|
+
scopes: { tenantId, projectId },
|
|
180
|
+
conversationId,
|
|
181
|
+
options: {
|
|
182
|
+
limit: 100,
|
|
183
|
+
includeInternal: true,
|
|
184
|
+
maxOutputTokens: maxTokens
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
async function getFormattedConversationHistory({
|
|
189
|
+
tenantId,
|
|
190
|
+
projectId,
|
|
191
|
+
conversationId,
|
|
192
|
+
currentMessage,
|
|
193
|
+
options,
|
|
194
|
+
filters
|
|
195
|
+
}) {
|
|
196
|
+
const historyOptions = options ?? { includeInternal: true };
|
|
197
|
+
const conversationHistory = await getScopedHistory({
|
|
198
|
+
tenantId,
|
|
199
|
+
projectId,
|
|
200
|
+
conversationId,
|
|
201
|
+
filters,
|
|
202
|
+
options: historyOptions
|
|
203
|
+
});
|
|
204
|
+
let messagesToFormat = conversationHistory;
|
|
205
|
+
if (currentMessage && conversationHistory.length > 0) {
|
|
206
|
+
const lastMessage = conversationHistory[conversationHistory.length - 1];
|
|
207
|
+
if (lastMessage.content.text === currentMessage) {
|
|
208
|
+
messagesToFormat = conversationHistory.slice(0, -1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (!messagesToFormat.length) {
|
|
212
|
+
return "";
|
|
213
|
+
}
|
|
214
|
+
const formattedHistory = messagesToFormat.map((msg) => {
|
|
215
|
+
let roleLabel;
|
|
216
|
+
if (msg.role === "user") {
|
|
217
|
+
roleLabel = "user";
|
|
218
|
+
} else if (msg.role === "agent" && (msg.messageType === "a2a-request" || msg.messageType === "a2a-response")) {
|
|
219
|
+
const fromAgent = msg.fromAgentId || msg.fromExternalAgentId || "unknown";
|
|
220
|
+
const toAgent = msg.toAgentId || msg.toExternalAgentId || "unknown";
|
|
221
|
+
roleLabel = `${fromAgent} to ${toAgent}`;
|
|
222
|
+
} else if (msg.role === "agent" && msg.messageType === "chat") {
|
|
223
|
+
const fromAgent = msg.fromAgentId || "unknown";
|
|
224
|
+
roleLabel = `${fromAgent} to User`;
|
|
225
|
+
} else {
|
|
226
|
+
roleLabel = msg.role || "system";
|
|
227
|
+
}
|
|
228
|
+
return `${roleLabel}: """${msg.content.text}"""`;
|
|
229
|
+
}).join("\n");
|
|
230
|
+
return `<conversation_history>
|
|
231
|
+
${formattedHistory}
|
|
232
|
+
</conversation_history>
|
|
233
|
+
`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { createDefaultConversationHistoryConfig, dbClient_default, env, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
export { __publicField };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDefaultConversationHistoryConfig, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse } from './chunk-JIWNRFDU.js';
|