@inkeep/agents-run-api 0.22.9 → 0.22.12

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.cjs CHANGED
@@ -357,8 +357,8 @@ async function getConversationScopedArtifacts(params) {
357
357
  });
358
358
  referenceArtifacts.push(...artifacts);
359
359
  }
360
- const logger28 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
361
- logger28.debug(
360
+ const logger29 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
361
+ logger29.debug(
362
362
  {
363
363
  conversationId,
364
364
  visibleMessages: visibleMessages.length,
@@ -370,8 +370,8 @@ async function getConversationScopedArtifacts(params) {
370
370
  );
371
371
  return referenceArtifacts;
372
372
  } catch (error) {
373
- const logger28 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
374
- logger28.error(
373
+ const logger29 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
374
+ logger29.error(
375
375
  {
376
376
  error: error instanceof Error ? error.message : "Unknown error",
377
377
  conversationId
@@ -412,14 +412,14 @@ const execute = ${executeCode}
412
412
  })();
413
413
  `;
414
414
  }
415
- function parseExecutionResult(stdout, functionId, logger28) {
415
+ function parseExecutionResult(stdout, functionId, logger29) {
416
416
  try {
417
417
  const outputLines = stdout.split("\n").filter((line) => line.trim());
418
418
  const resultLine = outputLines[outputLines.length - 1];
419
419
  return JSON.parse(resultLine);
420
420
  } catch (parseError) {
421
- if (logger28) {
422
- logger28.warn(
421
+ if (logger29) {
422
+ logger29.warn(
423
423
  {
424
424
  functionId,
425
425
  stdout,
@@ -1391,10 +1391,10 @@ var extractContextFromApiKey = async (apiKey, baseUrl) => {
1391
1391
 
1392
1392
  // src/openapi.ts
1393
1393
  init_env();
1394
- function setupOpenAPIRoutes(app6) {
1395
- app6.get("/openapi.json", (c) => {
1394
+ function setupOpenAPIRoutes(app7) {
1395
+ app7.get("/openapi.json", (c) => {
1396
1396
  try {
1397
- const document = app6.getOpenAPIDocument({
1397
+ const document = app7.getOpenAPIDocument({
1398
1398
  openapi: "3.0.0",
1399
1399
  info: {
1400
1400
  title: "Inkeep Agents Run API",
@@ -1415,7 +1415,7 @@ function setupOpenAPIRoutes(app6) {
1415
1415
  return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
1416
1416
  }
1417
1417
  });
1418
- app6.get(
1418
+ app7.get(
1419
1419
  "/docs",
1420
1420
  swaggerUi.swaggerUI({
1421
1421
  url: "/openapi.json",
@@ -1764,7 +1764,7 @@ async function handleMessageStream(c, agent, request) {
1764
1764
  }
1765
1765
  }
1766
1766
  };
1767
- return streaming.streamSSE(c, async (stream2) => {
1767
+ return streaming.streamSSE(c, async (stream3) => {
1768
1768
  try {
1769
1769
  const initialTask = {
1770
1770
  id: task.id,
@@ -1776,7 +1776,7 @@ async function handleMessageStream(c, agent, request) {
1776
1776
  artifacts: [],
1777
1777
  kind: "task"
1778
1778
  };
1779
- await stream2.writeSSE({
1779
+ await stream3.writeSSE({
1780
1780
  data: JSON.stringify({
1781
1781
  jsonrpc: "2.0",
1782
1782
  result: initialTask,
@@ -1794,7 +1794,7 @@ async function handleMessageStream(c, agent, request) {
1794
1794
  (part) => part.kind === "data" && part.data && typeof part.data === "object" && part.data.type === "transfer"
1795
1795
  );
1796
1796
  if (transferPart && transferPart.kind === "data" && transferPart.data) {
1797
- await stream2.writeSSE({
1797
+ await stream3.writeSSE({
1798
1798
  data: JSON.stringify({
1799
1799
  jsonrpc: "2.0",
1800
1800
  result: {
@@ -1828,7 +1828,7 @@ async function handleMessageStream(c, agent, request) {
1828
1828
  contextId: params.message.contextId,
1829
1829
  kind: "message"
1830
1830
  };
1831
- await stream2.writeSSE({
1831
+ await stream3.writeSSE({
1832
1832
  data: JSON.stringify({
1833
1833
  jsonrpc: "2.0",
1834
1834
  result: messageResponse,
@@ -1843,7 +1843,7 @@ async function handleMessageStream(c, agent, request) {
1843
1843
  },
1844
1844
  artifacts: result.artifacts
1845
1845
  };
1846
- await stream2.writeSSE({
1846
+ await stream3.writeSSE({
1847
1847
  data: JSON.stringify({
1848
1848
  jsonrpc: "2.0",
1849
1849
  result: completedTask,
@@ -1852,7 +1852,7 @@ async function handleMessageStream(c, agent, request) {
1852
1852
  });
1853
1853
  } catch (error) {
1854
1854
  console.error("Error in stream execution:", error);
1855
- await stream2.writeSSE({
1855
+ await stream3.writeSSE({
1856
1856
  data: JSON.stringify({
1857
1857
  jsonrpc: "2.0",
1858
1858
  error: {
@@ -1984,7 +1984,7 @@ async function handleTasksResubscribe(c, agent, request) {
1984
1984
  id: request.id
1985
1985
  });
1986
1986
  }
1987
- return streaming.streamSSE(c, async (stream2) => {
1987
+ return streaming.streamSSE(c, async (stream3) => {
1988
1988
  try {
1989
1989
  const task = {
1990
1990
  id: params.taskId,
@@ -1996,7 +1996,7 @@ async function handleTasksResubscribe(c, agent, request) {
1996
1996
  artifacts: [],
1997
1997
  kind: "task"
1998
1998
  };
1999
- await stream2.writeSSE({
1999
+ await stream3.writeSSE({
2000
2000
  data: JSON.stringify({
2001
2001
  jsonrpc: "2.0",
2002
2002
  result: task,
@@ -2005,7 +2005,7 @@ async function handleTasksResubscribe(c, agent, request) {
2005
2005
  });
2006
2006
  } catch (error) {
2007
2007
  console.error("Error in task resubscription:", error);
2008
- await stream2.writeSSE({
2008
+ await stream3.writeSSE({
2009
2009
  data: JSON.stringify({
2010
2010
  jsonrpc: "2.0",
2011
2011
  error: {
@@ -10296,8 +10296,8 @@ async function executeTransfer({
10296
10296
  init_dbClient();
10297
10297
  init_logger();
10298
10298
  var SSEStreamHelper = class {
10299
- constructor(stream2, requestId2, timestamp) {
10300
- this.stream = stream2;
10299
+ constructor(stream3, requestId2, timestamp) {
10300
+ this.stream = stream3;
10301
10301
  this.requestId = requestId2;
10302
10302
  this.timestamp = timestamp;
10303
10303
  __publicField(this, "isTextStreaming", false);
@@ -10463,8 +10463,8 @@ ${errorMessage}`);
10463
10463
  await this.writeDone();
10464
10464
  }
10465
10465
  };
10466
- function createSSEStreamHelper(stream2, requestId2, timestamp) {
10467
- return new SSEStreamHelper(stream2, requestId2, timestamp);
10466
+ function createSSEStreamHelper(stream3, requestId2, timestamp) {
10467
+ return new SSEStreamHelper(stream3, requestId2, timestamp);
10468
10468
  }
10469
10469
  var _VercelDataStreamHelper = class _VercelDataStreamHelper {
10470
10470
  // 10 minutes max lifetime
@@ -10611,12 +10611,12 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
10611
10611
  async streamData(data) {
10612
10612
  await this.writeContent(JSON.stringify(data));
10613
10613
  }
10614
- async mergeStream(stream2) {
10614
+ async mergeStream(stream3) {
10615
10615
  if (this.isCompleted) {
10616
10616
  console.warn("Attempted to merge stream to completed stream");
10617
10617
  return;
10618
10618
  }
10619
- this.writer.merge(stream2);
10619
+ this.writer.merge(stream3);
10620
10620
  }
10621
10621
  /**
10622
10622
  * Clean up all memory allocations
@@ -11555,9 +11555,9 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11555
11555
  "database.operation": "insert"
11556
11556
  });
11557
11557
  }
11558
- return streaming.streamSSE(c, async (stream2) => {
11558
+ return streaming.streamSSE(c, async (stream3) => {
11559
11559
  try {
11560
- const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
11560
+ const sseHelper = createSSEStreamHelper(stream3, requestId2, timestamp);
11561
11561
  await sseHelper.writeRole();
11562
11562
  logger24.info({ subAgentId }, "Starting execution");
11563
11563
  const emitOperationsHeader = c.req.header("x-emit-operations");
@@ -11594,7 +11594,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11594
11594
  "Error during streaming execution"
11595
11595
  );
11596
11596
  try {
11597
- const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
11597
+ const sseHelper = createSSEStreamHelper(stream3, requestId2, timestamp);
11598
11598
  await sseHelper.writeOperation(
11599
11599
  errorOp(
11600
11600
  "Sorry, I was unable to process your request at this time. Please try again.",
@@ -11822,7 +11822,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
11822
11822
  c.header("x-accel-buffering", "no");
11823
11823
  return streaming.stream(
11824
11824
  c,
11825
- (stream2) => stream2.pipe(
11825
+ (stream3) => stream3.pipe(
11826
11826
  dataStream.pipeThrough(new ai.JsonToSseTransformStream()).pipeThrough(new TextEncoderStream())
11827
11827
  )
11828
11828
  );
@@ -11836,6 +11836,184 @@ app3.openapi(chatDataStreamRoute, async (c) => {
11836
11836
  }
11837
11837
  });
11838
11838
  var chatDataStream_default = app3;
11839
+ init_dbClient();
11840
+ init_logger();
11841
+ var logger26 = agentsCore.getLogger("dataComponentPreview");
11842
+ var app4 = new zodOpenapi.OpenAPIHono();
11843
+ var generatePreviewRoute = zodOpenapi.createRoute({
11844
+ method: "post",
11845
+ path: "/:tenantId/projects/:projectId/data-components/:id/generate-preview",
11846
+ tags: ["Data Component Preview"],
11847
+ summary: "Generate Component Preview",
11848
+ description: "Generate a React/Tailwind component preview using AI based on the data component schema",
11849
+ request: {
11850
+ params: z6.z.object({
11851
+ tenantId: z6.z.string(),
11852
+ projectId: z6.z.string(),
11853
+ id: z6.z.string()
11854
+ })
11855
+ },
11856
+ responses: {
11857
+ 200: {
11858
+ description: "Streaming component code generation",
11859
+ headers: z6.z.object({
11860
+ "Content-Type": z6.z.string().default("text/plain; charset=utf-8"),
11861
+ "Cache-Control": z6.z.string().default("no-cache"),
11862
+ Connection: z6.z.string().default("keep-alive")
11863
+ }),
11864
+ content: {
11865
+ "text/plain": {
11866
+ schema: z6.z.string().describe("Streaming generated component code")
11867
+ }
11868
+ }
11869
+ },
11870
+ ...agentsCore.commonGetErrorResponses
11871
+ }
11872
+ });
11873
+ app4.openapi(generatePreviewRoute, async (c) => {
11874
+ const { tenantId, projectId, id } = c.req.valid("param");
11875
+ logger26.info({ tenantId, projectId, dataComponentId: id }, "Generating component preview");
11876
+ const dataComponent = await agentsCore.getDataComponent(dbClient_default)({
11877
+ scopes: { tenantId, projectId },
11878
+ dataComponentId: id
11879
+ });
11880
+ if (!dataComponent) {
11881
+ throw agentsCore.createApiError({
11882
+ code: "not_found",
11883
+ message: "Data component not found"
11884
+ });
11885
+ }
11886
+ const project = await agentsCore.getProject(dbClient_default)({
11887
+ scopes: { tenantId, projectId }
11888
+ });
11889
+ if (!project?.models?.base) {
11890
+ throw agentsCore.createApiError({
11891
+ code: "bad_request",
11892
+ message: "Project base model configuration is required"
11893
+ });
11894
+ }
11895
+ const prompt = buildGenerationPrompt(dataComponent);
11896
+ try {
11897
+ const modelConfig = ModelFactory.prepareGenerationConfig(project.models.base);
11898
+ const previewSchema = z6.z.object({
11899
+ code: z6.z.string().describe("The React component code"),
11900
+ data: z6.z.any().describe("Sample data matching the props schema")
11901
+ });
11902
+ const result = ai.streamObject({
11903
+ ...modelConfig,
11904
+ prompt,
11905
+ schema: previewSchema,
11906
+ temperature: 0.7
11907
+ });
11908
+ c.header("Content-Type", "text/plain; charset=utf-8");
11909
+ c.header("Cache-Control", "no-cache");
11910
+ c.header("Connection", "keep-alive");
11911
+ return streaming.stream(c, async (stream3) => {
11912
+ try {
11913
+ for await (const partialObject of result.partialObjectStream) {
11914
+ await stream3.write(JSON.stringify(partialObject) + "\n");
11915
+ }
11916
+ } catch (error) {
11917
+ logger26.error(
11918
+ { error, tenantId, projectId, dataComponentId: id },
11919
+ "Error streaming preview generation"
11920
+ );
11921
+ await stream3.write(
11922
+ JSON.stringify({ code: "// Error generating component preview", data: {} }) + "\n"
11923
+ );
11924
+ }
11925
+ });
11926
+ } catch (error) {
11927
+ logger26.error(
11928
+ { error, tenantId, projectId, dataComponentId: id },
11929
+ "Error generating component preview"
11930
+ );
11931
+ throw agentsCore.createApiError({
11932
+ code: "internal_server_error",
11933
+ message: "Failed to generate component preview"
11934
+ });
11935
+ }
11936
+ });
11937
+ function buildGenerationPrompt(dataComponent) {
11938
+ const propsSchema = dataComponent.props || {};
11939
+ const propsJson = JSON.stringify(propsSchema, null, 2);
11940
+ const componentName = sanitizeComponentName(dataComponent.name);
11941
+ 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.
11942
+
11943
+ COMPONENT DETAILS:
11944
+ - Original Name: ${dataComponent.name}
11945
+ - Component Function Name: ${componentName}
11946
+ - Description: ${dataComponent.description}
11947
+ - Props Schema (JSON Schema): ${propsJson}
11948
+
11949
+ REQUIREMENTS:
11950
+ 1. Create a React functional component (JSX, not TypeScript)
11951
+ 2. Use Tailwind CSS SEMANTIC COLOR CLASSES (these automatically adapt to light/dark mode):
11952
+ - Background: bg-background, bg-card, bg-muted, bg-muted/40, bg-accent, bg-primary
11953
+ - Text: text-foreground, text-muted-foreground, text-card-foreground, text-primary-foreground
11954
+ - Borders: border-border, border-input, border-muted
11955
+ - DO NOT use direct colors like bg-white, bg-gray-800, text-gray-900, etc.
11956
+ - DO NOT use dark: prefix - semantic classes handle dark mode automatically
11957
+ 3. Make it balanced - comfortable but efficient:
11958
+ - Use moderate padding: p-4, px-4 py-3 (balanced, not cramped or excessive)
11959
+ - Use appropriate text sizes: text-sm for body, text-base for headings, text-xs for captions
11960
+ - Use balanced spacing: gap-2.5, gap-3, space-y-2, mt-2, mb-3
11961
+ - Aim for a clean, professional look with good readability
11962
+ 4. Design for embedding - this component blends into existing content:
11963
+ - DO NOT add redundant titles or headers unless they're part of the actual data schema
11964
+ - Focus on displaying the data directly and elegantly
11965
+ - Assume the component is part of a larger conversation or content flow
11966
+ - If the schema has a "title" or "name" property, display it as data, not as a wrapper heading
11967
+ 5. Use LUCIDE-REACT ICONS to enhance UI aesthetics:
11968
+ - Import icons from lucide-react: import { User, Mail, Clock } from 'lucide-react'
11969
+ - Use icons with size-4 or size-5 classes for balanced visibility
11970
+ - Place icons inline with text or as visual indicators
11971
+ - Example: <User className="size-4" /> or <Mail className="size-4 text-muted-foreground" />
11972
+ - Common useful icons: User, Mail, Calendar, Clock, Check, X, Star, Heart, Settings, Search, etc.
11973
+ 6. The component should accept props that match the JSON Schema properties
11974
+ 7. Make it visually appealing and professional - clean with good whitespace
11975
+ 8. Use semantic HTML elements
11976
+ 9. Make it responsive and accessible
11977
+ 10. You can import icons from 'lucide-react' at the top
11978
+ 11. DO NOT include export statements - just the imports and function
11979
+ 12. DO NOT include TypeScript type annotations
11980
+ 13. Component name should be exactly: ${componentName}
11981
+
11982
+ AVAILABLE SEMANTIC COLOR CLASSES:
11983
+ - Backgrounds: bg-background, bg-foreground, bg-card, bg-popover, bg-primary, bg-secondary, bg-muted, bg-accent, bg-destructive
11984
+ - 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
11985
+ - Borders: border-border, border-input, border-ring
11986
+ - You can use opacity modifiers: bg-muted/40, bg-accent/10, etc.
11987
+
11988
+ OUTPUT FORMAT:
11989
+ You need to generate two things:
11990
+ 1. "code": The complete React component code as a string
11991
+ 2. "data": Realistic sample data that matches the props schema (as a JSON object)
11992
+
11993
+ EXAMPLE OUTPUT (for a user profile schema with name, email, role):
11994
+ {
11995
+ "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}",
11996
+ "data": {
11997
+ "name": "Sarah Chen",
11998
+ "email": "sarah.chen@example.com",
11999
+ "role": "Product Manager"
12000
+ }
12001
+ }
12002
+
12003
+ REMEMBER:
12004
+ - ONLY use semantic color classes (bg-card, text-foreground, etc.)
12005
+ - NO direct colors (bg-white, text-gray-900, etc.)
12006
+ - NO dark: prefix needed - semantic classes adapt automatically
12007
+ - Use balanced spacing (p-4, gap-2.5/gap-3, text-sm for body, text-base for headings)
12008
+ - Use lucide-react icons where appropriate for better UI
12009
+ - NO redundant titles - just display the actual data from props
12010
+ - Design for embedding - this blends into existing content, not a standalone card
12011
+ - Make the sample data realistic and useful for previewing the component`;
12012
+ }
12013
+ function sanitizeComponentName(name) {
12014
+ return name.split(/\s+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("").replace(/[^a-zA-Z0-9]/g, "");
12015
+ }
12016
+ var dataComponentPreview_default = app4;
11839
12017
 
11840
12018
  // src/routes/mcp.ts
11841
12019
  init_dbClient();
@@ -11843,7 +12021,7 @@ init_logger();
11843
12021
  function createMCPSchema(schema) {
11844
12022
  return schema;
11845
12023
  }
11846
- var logger26 = agentsCore.getLogger("mcp");
12024
+ var logger27 = agentsCore.getLogger("mcp");
11847
12025
  var _MockResponseSingleton = class _MockResponseSingleton {
11848
12026
  constructor() {
11849
12027
  __publicField(this, "mockRes");
@@ -11898,21 +12076,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
11898
12076
  id: 0
11899
12077
  });
11900
12078
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
11901
- logger26.info({ sessionId }, "Spoofing initialization message to set transport state");
12079
+ logger27.info({ sessionId }, "Spoofing initialization message to set transport state");
11902
12080
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
11903
12081
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
11904
12082
  try {
11905
12083
  await transport.handleRequest(req, mockRes, spoofInitMessage);
11906
- logger26.info({ sessionId }, "Successfully spoofed initialization");
12084
+ logger27.info({ sessionId }, "Successfully spoofed initialization");
11907
12085
  } catch (spoofError) {
11908
- logger26.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
12086
+ logger27.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
11909
12087
  }
11910
12088
  };
11911
12089
  var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
11912
12090
  const sessionId = req.headers["mcp-session-id"];
11913
- logger26.info({ sessionId }, "Received MCP session ID");
12091
+ logger27.info({ sessionId }, "Received MCP session ID");
11914
12092
  if (!sessionId) {
11915
- logger26.info({ body }, "Missing session ID");
12093
+ logger27.info({ body }, "Missing session ID");
11916
12094
  res.writeHead(400).end(
11917
12095
  JSON.stringify({
11918
12096
  jsonrpc: "2.0",
@@ -11938,7 +12116,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
11938
12116
  scopes: { tenantId, projectId },
11939
12117
  conversationId: sessionId
11940
12118
  });
11941
- logger26.info(
12119
+ logger27.info(
11942
12120
  {
11943
12121
  sessionId,
11944
12122
  conversationFound: !!conversation,
@@ -11949,7 +12127,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
11949
12127
  "Conversation lookup result"
11950
12128
  );
11951
12129
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.agentId !== agentId) {
11952
- logger26.info(
12130
+ logger27.info(
11953
12131
  { sessionId, conversationId: conversation?.id },
11954
12132
  "MCP session not found or invalid"
11955
12133
  );
@@ -12010,7 +12188,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultS
12010
12188
  requestId: requestId2,
12011
12189
  sseHelper: mcpStreamHelper
12012
12190
  });
12013
- logger26.info(
12191
+ logger27.info(
12014
12192
  { result },
12015
12193
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
12016
12194
  );
@@ -12094,7 +12272,7 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
12094
12272
  dbClient: dbClient_default,
12095
12273
  credentialStores
12096
12274
  });
12097
- logger26.info(
12275
+ logger27.info(
12098
12276
  {
12099
12277
  tenantId,
12100
12278
  projectId,
@@ -12123,8 +12301,8 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
12123
12301
  );
12124
12302
  return server;
12125
12303
  };
12126
- var app4 = new zodOpenapi.OpenAPIHono();
12127
- app4.use("/", async (c, next) => {
12304
+ var app5 = new zodOpenapi.OpenAPIHono();
12305
+ app5.use("/", async (c, next) => {
12128
12306
  if (c.req.method === "POST") {
12129
12307
  return agentsCore.contextValidationMiddleware(dbClient_default)(c, next);
12130
12308
  }
@@ -12156,7 +12334,7 @@ var validateRequestParameters = (c) => {
12156
12334
  };
12157
12335
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
12158
12336
  const { tenantId, projectId, agentId } = executionContext;
12159
- logger26.info({ body }, "Received initialization request");
12337
+ logger27.info({ body }, "Received initialization request");
12160
12338
  const sessionId = agentsCore.getConversationId();
12161
12339
  const activeSpan = api.trace.getActiveSpan();
12162
12340
  if (activeSpan) {
@@ -12212,7 +12390,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
12212
12390
  }
12213
12391
  }
12214
12392
  });
12215
- logger26.info(
12393
+ logger27.info(
12216
12394
  { sessionId, conversationId: conversation.id },
12217
12395
  "Created MCP session as conversation"
12218
12396
  );
@@ -12221,9 +12399,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
12221
12399
  });
12222
12400
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
12223
12401
  await server.connect(transport);
12224
- logger26.info({ sessionId }, "Server connected for initialization");
12402
+ logger27.info({ sessionId }, "Server connected for initialization");
12225
12403
  res.setHeader("Mcp-Session-Id", sessionId);
12226
- logger26.info(
12404
+ logger27.info(
12227
12405
  {
12228
12406
  sessionId,
12229
12407
  bodyMethod: body?.method,
@@ -12232,7 +12410,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
12232
12410
  "About to handle initialization request"
12233
12411
  );
12234
12412
  await transport.handleRequest(req, res, body);
12235
- logger26.info({ sessionId }, "Successfully handled initialization request");
12413
+ logger27.info({ sessionId }, "Successfully handled initialization request");
12236
12414
  return fetchToNode.toFetchResponse(res);
12237
12415
  });
12238
12416
  };
@@ -12259,8 +12437,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
12259
12437
  sessionId,
12260
12438
  conversation.metadata?.session_data?.mcpProtocolVersion
12261
12439
  );
12262
- logger26.info({ sessionId }, "Server connected and transport initialized");
12263
- logger26.info(
12440
+ logger27.info({ sessionId }, "Server connected and transport initialized");
12441
+ logger27.info(
12264
12442
  {
12265
12443
  sessionId,
12266
12444
  bodyKeys: Object.keys(body || {}),
@@ -12274,9 +12452,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
12274
12452
  );
12275
12453
  try {
12276
12454
  await transport.handleRequest(req, res, body);
12277
- logger26.info({ sessionId }, "Successfully handled MCP request");
12455
+ logger27.info({ sessionId }, "Successfully handled MCP request");
12278
12456
  } catch (transportError) {
12279
- logger26.error(
12457
+ logger27.error(
12280
12458
  {
12281
12459
  sessionId,
12282
12460
  error: transportError,
@@ -12293,7 +12471,7 @@ var createErrorResponse = (code, message, id = null) => ({
12293
12471
  error: { code, message },
12294
12472
  id
12295
12473
  });
12296
- app4.openapi(
12474
+ app5.openapi(
12297
12475
  zodOpenapi.createRoute({
12298
12476
  method: "post",
12299
12477
  path: "/",
@@ -12327,13 +12505,13 @@ app4.openapi(
12327
12505
  }
12328
12506
  const { executionContext } = paramValidation;
12329
12507
  const body = c.get("requestBody") || {};
12330
- logger26.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
12508
+ logger27.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
12331
12509
  const isInitRequest = body.method === "initialize";
12332
12510
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
12333
12511
  const validatedContext = c.get("validatedContext") || {};
12334
12512
  const credentialStores = c.get("credentialStores");
12335
- logger26.info({ validatedContext }, "Validated context");
12336
- logger26.info({ req }, "request");
12513
+ logger27.info({ validatedContext }, "Validated context");
12514
+ logger27.info({ req }, "request");
12337
12515
  if (isInitRequest) {
12338
12516
  return await handleInitializationRequest(
12339
12517
  body,
@@ -12355,7 +12533,7 @@ app4.openapi(
12355
12533
  );
12356
12534
  }
12357
12535
  } catch (e) {
12358
- logger26.error(
12536
+ logger27.error(
12359
12537
  {
12360
12538
  error: e instanceof Error ? e.message : e,
12361
12539
  stack: e instanceof Error ? e.stack : void 0
@@ -12366,8 +12544,8 @@ app4.openapi(
12366
12544
  }
12367
12545
  }
12368
12546
  );
12369
- app4.get("/", async (c) => {
12370
- logger26.info({}, "Received GET MCP request");
12547
+ app5.get("/", async (c) => {
12548
+ logger27.info({}, "Received GET MCP request");
12371
12549
  return c.json(
12372
12550
  {
12373
12551
  jsonrpc: "2.0",
@@ -12380,8 +12558,8 @@ app4.get("/", async (c) => {
12380
12558
  { status: 405 }
12381
12559
  );
12382
12560
  });
12383
- app4.delete("/", async (c) => {
12384
- logger26.info({}, "Received DELETE MCP request");
12561
+ app5.delete("/", async (c) => {
12562
+ logger27.info({}, "Received DELETE MCP request");
12385
12563
  return c.json(
12386
12564
  {
12387
12565
  jsonrpc: "2.0",
@@ -12391,15 +12569,15 @@ app4.delete("/", async (c) => {
12391
12569
  { status: 405 }
12392
12570
  );
12393
12571
  });
12394
- var mcp_default = app4;
12572
+ var mcp_default = app5;
12395
12573
 
12396
12574
  // src/app.ts
12397
- var logger27 = agentsCore.getLogger("agents-run-api");
12575
+ var logger28 = agentsCore.getLogger("agents-run-api");
12398
12576
  function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12399
- const app6 = new zodOpenapi.OpenAPIHono();
12400
- app6.use("*", otel.otel());
12401
- app6.use("*", requestId.requestId());
12402
- app6.use("*", async (c, next) => {
12577
+ const app7 = new zodOpenapi.OpenAPIHono();
12578
+ app7.use("*", otel.otel());
12579
+ app7.use("*", requestId.requestId());
12580
+ app7.use("*", async (c, next) => {
12403
12581
  c.set("serverConfig", serverConfig);
12404
12582
  c.set("credentialStores", credentialStores);
12405
12583
  if (sandboxConfig) {
@@ -12407,18 +12585,18 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12407
12585
  }
12408
12586
  return next();
12409
12587
  });
12410
- app6.use("*", async (c, next) => {
12588
+ app7.use("*", async (c, next) => {
12411
12589
  if (c.req.header("content-type")?.includes("application/json")) {
12412
12590
  try {
12413
12591
  const body = await c.req.json();
12414
12592
  c.set("requestBody", body);
12415
12593
  } catch (error) {
12416
- logger27.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
12594
+ logger28.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
12417
12595
  }
12418
12596
  }
12419
12597
  return next();
12420
12598
  });
12421
- app6.use("*", async (c, next) => {
12599
+ app7.use("*", async (c, next) => {
12422
12600
  const reqId = c.get("requestId");
12423
12601
  let bag = api.propagation.getBaggage(api.context.active());
12424
12602
  if (!bag) {
@@ -12431,7 +12609,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12431
12609
  }
12432
12610
  return next();
12433
12611
  });
12434
- app6.onError(async (err, c) => {
12612
+ app7.onError(async (err, c) => {
12435
12613
  const isExpectedError = err instanceof httpException.HTTPException;
12436
12614
  const status = isExpectedError ? err.status : 500;
12437
12615
  const requestId2 = c.get("requestId") || "unknown";
@@ -12464,8 +12642,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12464
12642
  if (!isExpectedError) {
12465
12643
  const errorMessage = err instanceof Error ? err.message : String(err);
12466
12644
  const errorStack = err instanceof Error ? err.stack : void 0;
12467
- if (logger27) {
12468
- logger27.error(
12645
+ if (logger28) {
12646
+ logger28.error(
12469
12647
  {
12470
12648
  error: err,
12471
12649
  message: errorMessage,
@@ -12477,8 +12655,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12477
12655
  );
12478
12656
  }
12479
12657
  } else {
12480
- if (logger27) {
12481
- logger27.error(
12658
+ if (logger28) {
12659
+ logger28.error(
12482
12660
  {
12483
12661
  error: err,
12484
12662
  path: c.req.path,
@@ -12495,8 +12673,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12495
12673
  const response = err.getResponse();
12496
12674
  return response;
12497
12675
  } catch (responseError) {
12498
- if (logger27) {
12499
- logger27.error({ error: responseError }, "Error while handling HTTPException response");
12676
+ if (logger28) {
12677
+ logger28.error({ error: responseError }, "Error while handling HTTPException response");
12500
12678
  }
12501
12679
  }
12502
12680
  }
@@ -12512,7 +12690,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12512
12690
  ...instance && { instance }
12513
12691
  });
12514
12692
  });
12515
- app6.use(
12693
+ app7.use(
12516
12694
  "*",
12517
12695
  cors.cors({
12518
12696
  origin: "*",
@@ -12523,14 +12701,14 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12523
12701
  maxAge: 86400
12524
12702
  })
12525
12703
  );
12526
- app6.use("/tenants/*", apiKeyAuth());
12527
- app6.use("/agents/*", apiKeyAuth());
12528
- app6.use("/v1/*", apiKeyAuth());
12529
- app6.use("/api/*", apiKeyAuth());
12530
- app6.use("*", async (c, next) => {
12704
+ app7.use("/tenants/*", apiKeyAuth());
12705
+ app7.use("/agents/*", apiKeyAuth());
12706
+ app7.use("/v1/*", apiKeyAuth());
12707
+ app7.use("/api/*", apiKeyAuth());
12708
+ app7.use("*", async (c, next) => {
12531
12709
  const executionContext = c.get("executionContext");
12532
12710
  if (!executionContext) {
12533
- logger27.debug({}, "Empty execution context");
12711
+ logger28.debug({}, "Empty execution context");
12534
12712
  return next();
12535
12713
  }
12536
12714
  const { tenantId, projectId, agentId } = executionContext;
@@ -12539,7 +12717,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12539
12717
  if (requestBody) {
12540
12718
  conversationId = requestBody.conversationId;
12541
12719
  if (!conversationId) {
12542
- logger27.debug({ requestBody }, "No conversation ID found in request body");
12720
+ logger28.debug({ requestBody }, "No conversation ID found in request body");
12543
12721
  }
12544
12722
  }
12545
12723
  const entries = Object.fromEntries(
@@ -12554,7 +12732,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12554
12732
  })
12555
12733
  );
12556
12734
  if (!Object.keys(entries).length) {
12557
- logger27.debug({}, "Empty entries for baggage");
12735
+ logger28.debug({}, "Empty entries for baggage");
12558
12736
  return next();
12559
12737
  }
12560
12738
  const bag = Object.entries(entries).reduce(
@@ -12564,7 +12742,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12564
12742
  const ctxWithBag = api.propagation.setBaggage(api.context.active(), bag);
12565
12743
  return await api.context.with(ctxWithBag, async () => await next());
12566
12744
  });
12567
- app6.openapi(
12745
+ app7.openapi(
12568
12746
  zodOpenapi.createRoute({
12569
12747
  method: "get",
12570
12748
  path: "/health",
@@ -12581,29 +12759,30 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12581
12759
  return c.body(null, 204);
12582
12760
  }
12583
12761
  );
12584
- app6.route("/v1/chat", chat_default);
12585
- app6.route("/api", chatDataStream_default);
12586
- app6.route("/v1/mcp", mcp_default);
12587
- app6.route("/agents", agents_default);
12588
- setupOpenAPIRoutes(app6);
12589
- app6.use("/tenants/*", async (_c, next) => {
12762
+ app7.route("/v1/chat", chat_default);
12763
+ app7.route("/api", chatDataStream_default);
12764
+ app7.route("/v1/mcp", mcp_default);
12765
+ app7.route("/agents", agents_default);
12766
+ app7.route("/v1", dataComponentPreview_default);
12767
+ setupOpenAPIRoutes(app7);
12768
+ app7.use("/tenants/*", async (_c, next) => {
12590
12769
  await next();
12591
12770
  await flushBatchProcessor();
12592
12771
  });
12593
- app6.use("/agents/*", async (_c, next) => {
12772
+ app7.use("/agents/*", async (_c, next) => {
12594
12773
  await next();
12595
12774
  await flushBatchProcessor();
12596
12775
  });
12597
- app6.use("/v1/*", async (_c, next) => {
12776
+ app7.use("/v1/*", async (_c, next) => {
12598
12777
  await next();
12599
12778
  await flushBatchProcessor();
12600
12779
  });
12601
- app6.use("/api/*", async (_c, next) => {
12780
+ app7.use("/api/*", async (_c, next) => {
12602
12781
  await next();
12603
12782
  await flushBatchProcessor();
12604
12783
  });
12605
12784
  const baseApp = new hono.Hono();
12606
- baseApp.route("/", app6);
12785
+ baseApp.route("/", app7);
12607
12786
  return baseApp;
12608
12787
  }
12609
12788
 
@@ -12619,8 +12798,8 @@ var defaultConfig = {
12619
12798
  };
12620
12799
  var defaultStores = agentsCore.createDefaultCredentialStores();
12621
12800
  var defaultRegistry = new agentsCore.CredentialStoreRegistry(defaultStores);
12622
- var app5 = createExecutionHono(defaultConfig, defaultRegistry);
12623
- var index_default = app5;
12801
+ var app6 = createExecutionHono(defaultConfig, defaultRegistry);
12802
+ var index_default = app6;
12624
12803
  function createExecutionApp(config) {
12625
12804
  const serverConfig = config?.serverConfig ?? defaultConfig;
12626
12805
  const stores = config?.credentialStores ?? defaultStores;