@inkeep/agents-run-api 0.22.8 → 0.22.11

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 (3) hide show
  1. package/dist/index.cjs +277 -98
  2. package/dist/index.js +270 -93
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { dbClient_default } from './chunk-IBMWBEXH.js';
4
4
  import { env } from './chunk-LHCIBW34.js';
5
5
  import { getLogger } from './chunk-A2S7GSHL.js';
6
6
  import { __publicField } from './chunk-PKBMQBKP.js';
7
- import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getAgentById, getRelatedAgentsForAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullAgentDefinition, TemplateEngine, agentHasArtifactComponents, MCPTransportType, SPAN_KEYS, getExternalAgent } from '@inkeep/agents-core';
7
+ import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, commonGetErrorResponses, loggerFactory, getDataComponent, getProject, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getAgentById, getRelatedAgentsForAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullAgentDefinition, TemplateEngine, agentHasArtifactComponents, MCPTransportType, SPAN_KEYS, getExternalAgent } from '@inkeep/agents-core';
8
8
  import { otel } from '@hono/otel';
9
9
  import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
10
10
  import { trace, propagation, context, SpanStatusCode } from '@opentelemetry/api';
@@ -17,7 +17,7 @@ import { swaggerUI } from '@hono/swagger-ui';
17
17
  import z5, { z } from 'zod';
18
18
  import { streamSSE, stream } from 'hono/streaming';
19
19
  import { nanoid } from 'nanoid';
20
- import { createUIMessageStream, JsonToSseTransformStream, parsePartialJson, generateObject, tool, streamText, generateText, streamObject } from 'ai';
20
+ import { createUIMessageStream, JsonToSseTransformStream, streamObject, parsePartialJson, generateObject, tool, streamText, generateText } from 'ai';
21
21
  import { createAnthropic, anthropic } from '@ai-sdk/anthropic';
22
22
  import { createGateway, gateway } from '@ai-sdk/gateway';
23
23
  import { createGoogleGenerativeAI, google } from '@ai-sdk/google';
@@ -187,10 +187,10 @@ var extractContextFromApiKey = async (apiKey, baseUrl) => {
187
187
  baseUrl
188
188
  });
189
189
  };
190
- function setupOpenAPIRoutes(app6) {
191
- app6.get("/openapi.json", (c) => {
190
+ function setupOpenAPIRoutes(app7) {
191
+ app7.get("/openapi.json", (c) => {
192
192
  try {
193
- const document = app6.getOpenAPIDocument({
193
+ const document = app7.getOpenAPIDocument({
194
194
  openapi: "3.0.0",
195
195
  info: {
196
196
  title: "Inkeep Agents Run API",
@@ -211,7 +211,7 @@ function setupOpenAPIRoutes(app6) {
211
211
  return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
212
212
  }
213
213
  });
214
- app6.get(
214
+ app7.get(
215
215
  "/docs",
216
216
  swaggerUI({
217
217
  url: "/openapi.json",
@@ -556,7 +556,7 @@ async function handleMessageStream(c, agent, request) {
556
556
  }
557
557
  }
558
558
  };
559
- return streamSSE(c, async (stream2) => {
559
+ return streamSSE(c, async (stream3) => {
560
560
  try {
561
561
  const initialTask = {
562
562
  id: task.id,
@@ -568,7 +568,7 @@ async function handleMessageStream(c, agent, request) {
568
568
  artifacts: [],
569
569
  kind: "task"
570
570
  };
571
- await stream2.writeSSE({
571
+ await stream3.writeSSE({
572
572
  data: JSON.stringify({
573
573
  jsonrpc: "2.0",
574
574
  result: initialTask,
@@ -586,7 +586,7 @@ async function handleMessageStream(c, agent, request) {
586
586
  (part) => part.kind === "data" && part.data && typeof part.data === "object" && part.data.type === "transfer"
587
587
  );
588
588
  if (transferPart && transferPart.kind === "data" && transferPart.data) {
589
- await stream2.writeSSE({
589
+ await stream3.writeSSE({
590
590
  data: JSON.stringify({
591
591
  jsonrpc: "2.0",
592
592
  result: {
@@ -620,7 +620,7 @@ async function handleMessageStream(c, agent, request) {
620
620
  contextId: params.message.contextId,
621
621
  kind: "message"
622
622
  };
623
- await stream2.writeSSE({
623
+ await stream3.writeSSE({
624
624
  data: JSON.stringify({
625
625
  jsonrpc: "2.0",
626
626
  result: messageResponse,
@@ -635,7 +635,7 @@ async function handleMessageStream(c, agent, request) {
635
635
  },
636
636
  artifacts: result.artifacts
637
637
  };
638
- await stream2.writeSSE({
638
+ await stream3.writeSSE({
639
639
  data: JSON.stringify({
640
640
  jsonrpc: "2.0",
641
641
  result: completedTask,
@@ -644,7 +644,7 @@ async function handleMessageStream(c, agent, request) {
644
644
  });
645
645
  } catch (error) {
646
646
  console.error("Error in stream execution:", error);
647
- await stream2.writeSSE({
647
+ await stream3.writeSSE({
648
648
  data: JSON.stringify({
649
649
  jsonrpc: "2.0",
650
650
  error: {
@@ -776,7 +776,7 @@ async function handleTasksResubscribe(c, agent, request) {
776
776
  id: request.id
777
777
  });
778
778
  }
779
- return streamSSE(c, async (stream2) => {
779
+ return streamSSE(c, async (stream3) => {
780
780
  try {
781
781
  const task = {
782
782
  id: params.taskId,
@@ -788,7 +788,7 @@ async function handleTasksResubscribe(c, agent, request) {
788
788
  artifacts: [],
789
789
  kind: "task"
790
790
  };
791
- await stream2.writeSSE({
791
+ await stream3.writeSSE({
792
792
  data: JSON.stringify({
793
793
  jsonrpc: "2.0",
794
794
  result: task,
@@ -797,7 +797,7 @@ async function handleTasksResubscribe(c, agent, request) {
797
797
  });
798
798
  } catch (error) {
799
799
  console.error("Error in task resubscription:", error);
800
- await stream2.writeSSE({
800
+ await stream3.writeSSE({
801
801
  data: JSON.stringify({
802
802
  jsonrpc: "2.0",
803
803
  error: {
@@ -9028,8 +9028,8 @@ async function executeTransfer({
9028
9028
  return { success: true, targetSubAgentId };
9029
9029
  }
9030
9030
  var SSEStreamHelper = class {
9031
- constructor(stream2, requestId2, timestamp) {
9032
- this.stream = stream2;
9031
+ constructor(stream3, requestId2, timestamp) {
9032
+ this.stream = stream3;
9033
9033
  this.requestId = requestId2;
9034
9034
  this.timestamp = timestamp;
9035
9035
  __publicField(this, "isTextStreaming", false);
@@ -9195,8 +9195,8 @@ ${errorMessage}`);
9195
9195
  await this.writeDone();
9196
9196
  }
9197
9197
  };
9198
- function createSSEStreamHelper(stream2, requestId2, timestamp) {
9199
- return new SSEStreamHelper(stream2, requestId2, timestamp);
9198
+ function createSSEStreamHelper(stream3, requestId2, timestamp) {
9199
+ return new SSEStreamHelper(stream3, requestId2, timestamp);
9200
9200
  }
9201
9201
  var _VercelDataStreamHelper = class _VercelDataStreamHelper {
9202
9202
  // 10 minutes max lifetime
@@ -9343,12 +9343,12 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
9343
9343
  async streamData(data) {
9344
9344
  await this.writeContent(JSON.stringify(data));
9345
9345
  }
9346
- async mergeStream(stream2) {
9346
+ async mergeStream(stream3) {
9347
9347
  if (this.isCompleted) {
9348
9348
  console.warn("Attempted to merge stream to completed stream");
9349
9349
  return;
9350
9350
  }
9351
- this.writer.merge(stream2);
9351
+ this.writer.merge(stream3);
9352
9352
  }
9353
9353
  /**
9354
9354
  * Clean up all memory allocations
@@ -10286,9 +10286,9 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10286
10286
  "database.operation": "insert"
10287
10287
  });
10288
10288
  }
10289
- return streamSSE(c, async (stream2) => {
10289
+ return streamSSE(c, async (stream3) => {
10290
10290
  try {
10291
- const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
10291
+ const sseHelper = createSSEStreamHelper(stream3, requestId2, timestamp);
10292
10292
  await sseHelper.writeRole();
10293
10293
  logger20.info({ subAgentId }, "Starting execution");
10294
10294
  const emitOperationsHeader = c.req.header("x-emit-operations");
@@ -10325,7 +10325,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10325
10325
  "Error during streaming execution"
10326
10326
  );
10327
10327
  try {
10328
- const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
10328
+ const sseHelper = createSSEStreamHelper(stream3, requestId2, timestamp);
10329
10329
  await sseHelper.writeOperation(
10330
10330
  errorOp(
10331
10331
  "Sorry, I was unable to process your request at this time. Please try again.",
@@ -10549,7 +10549,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10549
10549
  c.header("x-accel-buffering", "no");
10550
10550
  return stream(
10551
10551
  c,
10552
- (stream2) => stream2.pipe(
10552
+ (stream3) => stream3.pipe(
10553
10553
  dataStream.pipeThrough(new JsonToSseTransformStream()).pipeThrough(new TextEncoderStream())
10554
10554
  )
10555
10555
  );
@@ -10563,10 +10563,186 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10563
10563
  }
10564
10564
  });
10565
10565
  var chatDataStream_default = app3;
10566
+ var logger22 = getLogger("dataComponentPreview");
10567
+ var app4 = new OpenAPIHono();
10568
+ var generatePreviewRoute = createRoute({
10569
+ method: "post",
10570
+ path: "/:tenantId/projects/:projectId/data-components/:id/generate-preview",
10571
+ tags: ["Data Component Preview"],
10572
+ summary: "Generate Component Preview",
10573
+ description: "Generate a React/Tailwind component preview using AI based on the data component schema",
10574
+ request: {
10575
+ params: z.object({
10576
+ tenantId: z.string(),
10577
+ projectId: z.string(),
10578
+ id: z.string()
10579
+ })
10580
+ },
10581
+ responses: {
10582
+ 200: {
10583
+ description: "Streaming component code generation",
10584
+ headers: z.object({
10585
+ "Content-Type": z.string().default("text/plain; charset=utf-8"),
10586
+ "Cache-Control": z.string().default("no-cache"),
10587
+ Connection: z.string().default("keep-alive")
10588
+ }),
10589
+ content: {
10590
+ "text/plain": {
10591
+ schema: z.string().describe("Streaming generated component code")
10592
+ }
10593
+ }
10594
+ },
10595
+ ...commonGetErrorResponses
10596
+ }
10597
+ });
10598
+ app4.openapi(generatePreviewRoute, async (c) => {
10599
+ const { tenantId, projectId, id } = c.req.valid("param");
10600
+ logger22.info({ tenantId, projectId, dataComponentId: id }, "Generating component preview");
10601
+ const dataComponent = await getDataComponent(dbClient_default)({
10602
+ scopes: { tenantId, projectId },
10603
+ dataComponentId: id
10604
+ });
10605
+ if (!dataComponent) {
10606
+ throw createApiError({
10607
+ code: "not_found",
10608
+ message: "Data component not found"
10609
+ });
10610
+ }
10611
+ const project = await getProject(dbClient_default)({
10612
+ scopes: { tenantId, projectId }
10613
+ });
10614
+ if (!project?.models?.base) {
10615
+ throw createApiError({
10616
+ code: "bad_request",
10617
+ message: "Project base model configuration is required"
10618
+ });
10619
+ }
10620
+ const prompt = buildGenerationPrompt(dataComponent);
10621
+ try {
10622
+ const modelConfig = ModelFactory.prepareGenerationConfig(project.models.base);
10623
+ const previewSchema = z.object({
10624
+ code: z.string().describe("The React component code"),
10625
+ data: z.any().describe("Sample data matching the props schema")
10626
+ });
10627
+ const result = streamObject({
10628
+ ...modelConfig,
10629
+ prompt,
10630
+ schema: previewSchema,
10631
+ temperature: 0.7
10632
+ });
10633
+ c.header("Content-Type", "text/plain; charset=utf-8");
10634
+ c.header("Cache-Control", "no-cache");
10635
+ c.header("Connection", "keep-alive");
10636
+ return stream(c, async (stream3) => {
10637
+ try {
10638
+ for await (const partialObject of result.partialObjectStream) {
10639
+ await stream3.write(JSON.stringify(partialObject) + "\n");
10640
+ }
10641
+ } catch (error) {
10642
+ logger22.error(
10643
+ { error, tenantId, projectId, dataComponentId: id },
10644
+ "Error streaming preview generation"
10645
+ );
10646
+ await stream3.write(
10647
+ JSON.stringify({ code: "// Error generating component preview", data: {} }) + "\n"
10648
+ );
10649
+ }
10650
+ });
10651
+ } catch (error) {
10652
+ logger22.error(
10653
+ { error, tenantId, projectId, dataComponentId: id },
10654
+ "Error generating component preview"
10655
+ );
10656
+ throw createApiError({
10657
+ code: "internal_server_error",
10658
+ message: "Failed to generate component preview"
10659
+ });
10660
+ }
10661
+ });
10662
+ function buildGenerationPrompt(dataComponent) {
10663
+ const propsSchema = dataComponent.props || {};
10664
+ const propsJson = JSON.stringify(propsSchema, null, 2);
10665
+ const componentName = sanitizeComponentName(dataComponent.name);
10666
+ return `You are an expert React and Tailwind CSS developer. Generate a beautiful, modern React component for displaying data and sample data to preview it.
10667
+
10668
+ COMPONENT DETAILS:
10669
+ - Original Name: ${dataComponent.name}
10670
+ - Component Function Name: ${componentName}
10671
+ - Description: ${dataComponent.description}
10672
+ - Props Schema (JSON Schema): ${propsJson}
10673
+
10674
+ REQUIREMENTS:
10675
+ 1. Create a React functional component (JSX, not TypeScript)
10676
+ 2. Use Tailwind CSS SEMANTIC COLOR CLASSES (these automatically adapt to light/dark mode):
10677
+ - Background: bg-background, bg-card, bg-muted, bg-muted/40, bg-accent, bg-primary
10678
+ - Text: text-foreground, text-muted-foreground, text-card-foreground, text-primary-foreground
10679
+ - Borders: border-border, border-input, border-muted
10680
+ - DO NOT use direct colors like bg-white, bg-gray-800, text-gray-900, etc.
10681
+ - DO NOT use dark: prefix - semantic classes handle dark mode automatically
10682
+ 3. Make it balanced - comfortable but efficient:
10683
+ - Use moderate padding: p-4, px-4 py-3 (balanced, not cramped or excessive)
10684
+ - Use appropriate text sizes: text-sm for body, text-base for headings, text-xs for captions
10685
+ - Use balanced spacing: gap-2.5, gap-3, space-y-2, mt-2, mb-3
10686
+ - Aim for a clean, professional look with good readability
10687
+ 4. Design for embedding - this component blends into existing content:
10688
+ - DO NOT add redundant titles or headers unless they're part of the actual data schema
10689
+ - Focus on displaying the data directly and elegantly
10690
+ - Assume the component is part of a larger conversation or content flow
10691
+ - If the schema has a "title" or "name" property, display it as data, not as a wrapper heading
10692
+ 5. Use LUCIDE-REACT ICONS to enhance UI aesthetics:
10693
+ - Import icons from lucide-react: import { User, Mail, Clock } from 'lucide-react'
10694
+ - Use icons with size-4 or size-5 classes for balanced visibility
10695
+ - Place icons inline with text or as visual indicators
10696
+ - Example: <User className="size-4" /> or <Mail className="size-4 text-muted-foreground" />
10697
+ - Common useful icons: User, Mail, Calendar, Clock, Check, X, Star, Heart, Settings, Search, etc.
10698
+ 6. The component should accept props that match the JSON Schema properties
10699
+ 7. Make it visually appealing and professional - clean with good whitespace
10700
+ 8. Use semantic HTML elements
10701
+ 9. Make it responsive and accessible
10702
+ 10. You can import icons from 'lucide-react' at the top
10703
+ 11. DO NOT include export statements - just the imports and function
10704
+ 12. DO NOT include TypeScript type annotations
10705
+ 13. Component name should be exactly: ${componentName}
10706
+
10707
+ AVAILABLE SEMANTIC COLOR CLASSES:
10708
+ - Backgrounds: bg-background, bg-foreground, bg-card, bg-popover, bg-primary, bg-secondary, bg-muted, bg-accent, bg-destructive
10709
+ - Text: text-foreground, text-background, text-card-foreground, text-popover-foreground, text-primary-foreground, text-secondary-foreground, text-muted-foreground, text-accent-foreground, text-destructive
10710
+ - Borders: border-border, border-input, border-ring
10711
+ - You can use opacity modifiers: bg-muted/40, bg-accent/10, etc.
10712
+
10713
+ OUTPUT FORMAT:
10714
+ You need to generate two things:
10715
+ 1. "code": The complete React component code as a string
10716
+ 2. "data": Realistic sample data that matches the props schema (as a JSON object)
10717
+
10718
+ EXAMPLE OUTPUT (for a user profile schema with name, email, role):
10719
+ {
10720
+ "code": "import { Mail, User } from 'lucide-react';\\n\\nfunction ${componentName}(props) {\\n return (\\n <div className=\\"p-4 rounded-lg border border-border bg-card\\">\\n <div className=\\"flex items-center gap-2.5 mb-2\\">\\n <User className=\\"size-4 text-muted-foreground\\" />\\n <span className=\\"text-base font-medium text-foreground\\">{props.name}</span>\\n </div>\\n <div className=\\"flex items-center gap-2 text-sm text-muted-foreground\\">\\n <Mail className=\\"size-4\\" />\\n <span>{props.email}</span>\\n </div>\\n <div className=\\"text-xs text-muted-foreground mt-2\\">Role: {props.role}</div>\\n </div>\\n );\\n}",
10721
+ "data": {
10722
+ "name": "Sarah Chen",
10723
+ "email": "sarah.chen@example.com",
10724
+ "role": "Product Manager"
10725
+ }
10726
+ }
10727
+
10728
+ REMEMBER:
10729
+ - ONLY use semantic color classes (bg-card, text-foreground, etc.)
10730
+ - NO direct colors (bg-white, text-gray-900, etc.)
10731
+ - NO dark: prefix needed - semantic classes adapt automatically
10732
+ - Use balanced spacing (p-4, gap-2.5/gap-3, text-sm for body, text-base for headings)
10733
+ - Use lucide-react icons where appropriate for better UI
10734
+ - NO redundant titles - just display the actual data from props
10735
+ - Design for embedding - this blends into existing content, not a standalone card
10736
+ - Make the sample data realistic and useful for previewing the component`;
10737
+ }
10738
+ function sanitizeComponentName(name) {
10739
+ return name.split(/\s+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("").replace(/[^a-zA-Z0-9]/g, "");
10740
+ }
10741
+ var dataComponentPreview_default = app4;
10566
10742
  function createMCPSchema(schema) {
10567
10743
  return schema;
10568
10744
  }
10569
- var logger22 = getLogger("mcp");
10745
+ var logger23 = getLogger("mcp");
10570
10746
  var _MockResponseSingleton = class _MockResponseSingleton {
10571
10747
  constructor() {
10572
10748
  __publicField(this, "mockRes");
@@ -10621,21 +10797,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
10621
10797
  id: 0
10622
10798
  });
10623
10799
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
10624
- logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
10800
+ logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
10625
10801
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
10626
10802
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
10627
10803
  try {
10628
10804
  await transport.handleRequest(req, mockRes, spoofInitMessage);
10629
- logger22.info({ sessionId }, "Successfully spoofed initialization");
10805
+ logger23.info({ sessionId }, "Successfully spoofed initialization");
10630
10806
  } catch (spoofError) {
10631
- logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10807
+ logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10632
10808
  }
10633
10809
  };
10634
10810
  var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
10635
10811
  const sessionId = req.headers["mcp-session-id"];
10636
- logger22.info({ sessionId }, "Received MCP session ID");
10812
+ logger23.info({ sessionId }, "Received MCP session ID");
10637
10813
  if (!sessionId) {
10638
- logger22.info({ body }, "Missing session ID");
10814
+ logger23.info({ body }, "Missing session ID");
10639
10815
  res.writeHead(400).end(
10640
10816
  JSON.stringify({
10641
10817
  jsonrpc: "2.0",
@@ -10661,7 +10837,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
10661
10837
  scopes: { tenantId, projectId },
10662
10838
  conversationId: sessionId
10663
10839
  });
10664
- logger22.info(
10840
+ logger23.info(
10665
10841
  {
10666
10842
  sessionId,
10667
10843
  conversationFound: !!conversation,
@@ -10672,7 +10848,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
10672
10848
  "Conversation lookup result"
10673
10849
  );
10674
10850
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.agentId !== agentId) {
10675
- logger22.info(
10851
+ logger23.info(
10676
10852
  { sessionId, conversationId: conversation?.id },
10677
10853
  "MCP session not found or invalid"
10678
10854
  );
@@ -10733,7 +10909,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultS
10733
10909
  requestId: requestId2,
10734
10910
  sseHelper: mcpStreamHelper
10735
10911
  });
10736
- logger22.info(
10912
+ logger23.info(
10737
10913
  { result },
10738
10914
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
10739
10915
  );
@@ -10817,7 +10993,7 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
10817
10993
  dbClient: dbClient_default,
10818
10994
  credentialStores
10819
10995
  });
10820
- logger22.info(
10996
+ logger23.info(
10821
10997
  {
10822
10998
  tenantId,
10823
10999
  projectId,
@@ -10846,8 +11022,8 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
10846
11022
  );
10847
11023
  return server;
10848
11024
  };
10849
- var app4 = new OpenAPIHono();
10850
- app4.use("/", async (c, next) => {
11025
+ var app5 = new OpenAPIHono();
11026
+ app5.use("/", async (c, next) => {
10851
11027
  if (c.req.method === "POST") {
10852
11028
  return contextValidationMiddleware(dbClient_default)(c, next);
10853
11029
  }
@@ -10879,7 +11055,7 @@ var validateRequestParameters = (c) => {
10879
11055
  };
10880
11056
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
10881
11057
  const { tenantId, projectId, agentId } = executionContext;
10882
- logger22.info({ body }, "Received initialization request");
11058
+ logger23.info({ body }, "Received initialization request");
10883
11059
  const sessionId = getConversationId();
10884
11060
  const activeSpan = trace.getActiveSpan();
10885
11061
  if (activeSpan) {
@@ -10935,7 +11111,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10935
11111
  }
10936
11112
  }
10937
11113
  });
10938
- logger22.info(
11114
+ logger23.info(
10939
11115
  { sessionId, conversationId: conversation.id },
10940
11116
  "Created MCP session as conversation"
10941
11117
  );
@@ -10944,9 +11120,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10944
11120
  });
10945
11121
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
10946
11122
  await server.connect(transport);
10947
- logger22.info({ sessionId }, "Server connected for initialization");
11123
+ logger23.info({ sessionId }, "Server connected for initialization");
10948
11124
  res.setHeader("Mcp-Session-Id", sessionId);
10949
- logger22.info(
11125
+ logger23.info(
10950
11126
  {
10951
11127
  sessionId,
10952
11128
  bodyMethod: body?.method,
@@ -10955,7 +11131,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10955
11131
  "About to handle initialization request"
10956
11132
  );
10957
11133
  await transport.handleRequest(req, res, body);
10958
- logger22.info({ sessionId }, "Successfully handled initialization request");
11134
+ logger23.info({ sessionId }, "Successfully handled initialization request");
10959
11135
  return toFetchResponse(res);
10960
11136
  });
10961
11137
  };
@@ -10982,8 +11158,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10982
11158
  sessionId,
10983
11159
  conversation.metadata?.session_data?.mcpProtocolVersion
10984
11160
  );
10985
- logger22.info({ sessionId }, "Server connected and transport initialized");
10986
- logger22.info(
11161
+ logger23.info({ sessionId }, "Server connected and transport initialized");
11162
+ logger23.info(
10987
11163
  {
10988
11164
  sessionId,
10989
11165
  bodyKeys: Object.keys(body || {}),
@@ -10997,9 +11173,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10997
11173
  );
10998
11174
  try {
10999
11175
  await transport.handleRequest(req, res, body);
11000
- logger22.info({ sessionId }, "Successfully handled MCP request");
11176
+ logger23.info({ sessionId }, "Successfully handled MCP request");
11001
11177
  } catch (transportError) {
11002
- logger22.error(
11178
+ logger23.error(
11003
11179
  {
11004
11180
  sessionId,
11005
11181
  error: transportError,
@@ -11016,7 +11192,7 @@ var createErrorResponse = (code, message, id = null) => ({
11016
11192
  error: { code, message },
11017
11193
  id
11018
11194
  });
11019
- app4.openapi(
11195
+ app5.openapi(
11020
11196
  createRoute({
11021
11197
  method: "post",
11022
11198
  path: "/",
@@ -11050,13 +11226,13 @@ app4.openapi(
11050
11226
  }
11051
11227
  const { executionContext } = paramValidation;
11052
11228
  const body = c.get("requestBody") || {};
11053
- logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
11229
+ logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
11054
11230
  const isInitRequest = body.method === "initialize";
11055
11231
  const { req, res } = toReqRes(c.req.raw);
11056
11232
  const validatedContext = c.get("validatedContext") || {};
11057
11233
  const credentialStores = c.get("credentialStores");
11058
- logger22.info({ validatedContext }, "Validated context");
11059
- logger22.info({ req }, "request");
11234
+ logger23.info({ validatedContext }, "Validated context");
11235
+ logger23.info({ req }, "request");
11060
11236
  if (isInitRequest) {
11061
11237
  return await handleInitializationRequest(
11062
11238
  body,
@@ -11078,7 +11254,7 @@ app4.openapi(
11078
11254
  );
11079
11255
  }
11080
11256
  } catch (e) {
11081
- logger22.error(
11257
+ logger23.error(
11082
11258
  {
11083
11259
  error: e instanceof Error ? e.message : e,
11084
11260
  stack: e instanceof Error ? e.stack : void 0
@@ -11089,8 +11265,8 @@ app4.openapi(
11089
11265
  }
11090
11266
  }
11091
11267
  );
11092
- app4.get("/", async (c) => {
11093
- logger22.info({}, "Received GET MCP request");
11268
+ app5.get("/", async (c) => {
11269
+ logger23.info({}, "Received GET MCP request");
11094
11270
  return c.json(
11095
11271
  {
11096
11272
  jsonrpc: "2.0",
@@ -11103,8 +11279,8 @@ app4.get("/", async (c) => {
11103
11279
  { status: 405 }
11104
11280
  );
11105
11281
  });
11106
- app4.delete("/", async (c) => {
11107
- logger22.info({}, "Received DELETE MCP request");
11282
+ app5.delete("/", async (c) => {
11283
+ logger23.info({}, "Received DELETE MCP request");
11108
11284
  return c.json(
11109
11285
  {
11110
11286
  jsonrpc: "2.0",
@@ -11114,15 +11290,15 @@ app4.delete("/", async (c) => {
11114
11290
  { status: 405 }
11115
11291
  );
11116
11292
  });
11117
- var mcp_default = app4;
11293
+ var mcp_default = app5;
11118
11294
 
11119
11295
  // src/app.ts
11120
- var logger23 = getLogger("agents-run-api");
11296
+ var logger24 = getLogger("agents-run-api");
11121
11297
  function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11122
- const app6 = new OpenAPIHono();
11123
- app6.use("*", otel());
11124
- app6.use("*", requestId());
11125
- app6.use("*", async (c, next) => {
11298
+ const app7 = new OpenAPIHono();
11299
+ app7.use("*", otel());
11300
+ app7.use("*", requestId());
11301
+ app7.use("*", async (c, next) => {
11126
11302
  c.set("serverConfig", serverConfig);
11127
11303
  c.set("credentialStores", credentialStores);
11128
11304
  if (sandboxConfig) {
@@ -11130,18 +11306,18 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11130
11306
  }
11131
11307
  return next();
11132
11308
  });
11133
- app6.use("*", async (c, next) => {
11309
+ app7.use("*", async (c, next) => {
11134
11310
  if (c.req.header("content-type")?.includes("application/json")) {
11135
11311
  try {
11136
11312
  const body = await c.req.json();
11137
11313
  c.set("requestBody", body);
11138
11314
  } catch (error) {
11139
- logger23.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
11315
+ logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
11140
11316
  }
11141
11317
  }
11142
11318
  return next();
11143
11319
  });
11144
- app6.use("*", async (c, next) => {
11320
+ app7.use("*", async (c, next) => {
11145
11321
  const reqId = c.get("requestId");
11146
11322
  let bag = propagation.getBaggage(context.active());
11147
11323
  if (!bag) {
@@ -11154,7 +11330,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11154
11330
  }
11155
11331
  return next();
11156
11332
  });
11157
- app6.onError(async (err, c) => {
11333
+ app7.onError(async (err, c) => {
11158
11334
  const isExpectedError = err instanceof HTTPException;
11159
11335
  const status = isExpectedError ? err.status : 500;
11160
11336
  const requestId2 = c.get("requestId") || "unknown";
@@ -11187,8 +11363,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11187
11363
  if (!isExpectedError) {
11188
11364
  const errorMessage = err instanceof Error ? err.message : String(err);
11189
11365
  const errorStack = err instanceof Error ? err.stack : void 0;
11190
- if (logger23) {
11191
- logger23.error(
11366
+ if (logger24) {
11367
+ logger24.error(
11192
11368
  {
11193
11369
  error: err,
11194
11370
  message: errorMessage,
@@ -11200,8 +11376,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11200
11376
  );
11201
11377
  }
11202
11378
  } else {
11203
- if (logger23) {
11204
- logger23.error(
11379
+ if (logger24) {
11380
+ logger24.error(
11205
11381
  {
11206
11382
  error: err,
11207
11383
  path: c.req.path,
@@ -11218,8 +11394,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11218
11394
  const response = err.getResponse();
11219
11395
  return response;
11220
11396
  } catch (responseError) {
11221
- if (logger23) {
11222
- logger23.error({ error: responseError }, "Error while handling HTTPException response");
11397
+ if (logger24) {
11398
+ logger24.error({ error: responseError }, "Error while handling HTTPException response");
11223
11399
  }
11224
11400
  }
11225
11401
  }
@@ -11235,7 +11411,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11235
11411
  ...instance && { instance }
11236
11412
  });
11237
11413
  });
11238
- app6.use(
11414
+ app7.use(
11239
11415
  "*",
11240
11416
  cors({
11241
11417
  origin: "*",
@@ -11246,14 +11422,14 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11246
11422
  maxAge: 86400
11247
11423
  })
11248
11424
  );
11249
- app6.use("/tenants/*", apiKeyAuth());
11250
- app6.use("/agents/*", apiKeyAuth());
11251
- app6.use("/v1/*", apiKeyAuth());
11252
- app6.use("/api/*", apiKeyAuth());
11253
- app6.use("*", async (c, next) => {
11425
+ app7.use("/tenants/*", apiKeyAuth());
11426
+ app7.use("/agents/*", apiKeyAuth());
11427
+ app7.use("/v1/*", apiKeyAuth());
11428
+ app7.use("/api/*", apiKeyAuth());
11429
+ app7.use("*", async (c, next) => {
11254
11430
  const executionContext = c.get("executionContext");
11255
11431
  if (!executionContext) {
11256
- logger23.debug({}, "Empty execution context");
11432
+ logger24.debug({}, "Empty execution context");
11257
11433
  return next();
11258
11434
  }
11259
11435
  const { tenantId, projectId, agentId } = executionContext;
@@ -11262,7 +11438,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11262
11438
  if (requestBody) {
11263
11439
  conversationId = requestBody.conversationId;
11264
11440
  if (!conversationId) {
11265
- logger23.debug({ requestBody }, "No conversation ID found in request body");
11441
+ logger24.debug({ requestBody }, "No conversation ID found in request body");
11266
11442
  }
11267
11443
  }
11268
11444
  const entries = Object.fromEntries(
@@ -11277,7 +11453,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11277
11453
  })
11278
11454
  );
11279
11455
  if (!Object.keys(entries).length) {
11280
- logger23.debug({}, "Empty entries for baggage");
11456
+ logger24.debug({}, "Empty entries for baggage");
11281
11457
  return next();
11282
11458
  }
11283
11459
  const bag = Object.entries(entries).reduce(
@@ -11287,7 +11463,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11287
11463
  const ctxWithBag = propagation.setBaggage(context.active(), bag);
11288
11464
  return await context.with(ctxWithBag, async () => await next());
11289
11465
  });
11290
- app6.openapi(
11466
+ app7.openapi(
11291
11467
  createRoute({
11292
11468
  method: "get",
11293
11469
  path: "/health",
@@ -11304,29 +11480,30 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11304
11480
  return c.body(null, 204);
11305
11481
  }
11306
11482
  );
11307
- app6.route("/v1/chat", chat_default);
11308
- app6.route("/api", chatDataStream_default);
11309
- app6.route("/v1/mcp", mcp_default);
11310
- app6.route("/agents", agents_default);
11311
- setupOpenAPIRoutes(app6);
11312
- app6.use("/tenants/*", async (_c, next) => {
11483
+ app7.route("/v1/chat", chat_default);
11484
+ app7.route("/api", chatDataStream_default);
11485
+ app7.route("/v1/mcp", mcp_default);
11486
+ app7.route("/agents", agents_default);
11487
+ app7.route("/v1", dataComponentPreview_default);
11488
+ setupOpenAPIRoutes(app7);
11489
+ app7.use("/tenants/*", async (_c, next) => {
11313
11490
  await next();
11314
11491
  await flushBatchProcessor();
11315
11492
  });
11316
- app6.use("/agents/*", async (_c, next) => {
11493
+ app7.use("/agents/*", async (_c, next) => {
11317
11494
  await next();
11318
11495
  await flushBatchProcessor();
11319
11496
  });
11320
- app6.use("/v1/*", async (_c, next) => {
11497
+ app7.use("/v1/*", async (_c, next) => {
11321
11498
  await next();
11322
11499
  await flushBatchProcessor();
11323
11500
  });
11324
- app6.use("/api/*", async (_c, next) => {
11501
+ app7.use("/api/*", async (_c, next) => {
11325
11502
  await next();
11326
11503
  await flushBatchProcessor();
11327
11504
  });
11328
11505
  const baseApp = new Hono();
11329
- baseApp.route("/", app6);
11506
+ baseApp.route("/", app7);
11330
11507
  return baseApp;
11331
11508
  }
11332
11509
 
@@ -11342,8 +11519,8 @@ var defaultConfig = {
11342
11519
  };
11343
11520
  var defaultStores = createDefaultCredentialStores();
11344
11521
  var defaultRegistry = new CredentialStoreRegistry(defaultStores);
11345
- var app5 = createExecutionHono(defaultConfig, defaultRegistry);
11346
- var index_default = app5;
11522
+ var app6 = createExecutionHono(defaultConfig, defaultRegistry);
11523
+ var index_default = app6;
11347
11524
  function createExecutionApp(config) {
11348
11525
  const serverConfig = config?.serverConfig ?? defaultConfig;
11349
11526
  const stores = config?.credentialStores ?? defaultStores;