@inkeep/agents-run-api 0.29.3 → 0.29.5

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 +98 -340
  2. package/dist/index.js +93 -333
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -358,8 +358,8 @@ async function getConversationScopedArtifacts(params) {
358
358
  });
359
359
  referenceArtifacts.push(...artifacts);
360
360
  }
361
- const logger30 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
362
- logger30.debug(
361
+ const logger29 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
362
+ logger29.debug(
363
363
  {
364
364
  conversationId,
365
365
  visibleMessages: visibleMessages.length,
@@ -371,8 +371,8 @@ async function getConversationScopedArtifacts(params) {
371
371
  );
372
372
  return referenceArtifacts;
373
373
  } catch (error) {
374
- const logger30 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
375
- logger30.error(
374
+ const logger29 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
375
+ logger29.error(
376
376
  {
377
377
  error: error instanceof Error ? error.message : "Unknown error",
378
378
  conversationId
@@ -413,14 +413,14 @@ const execute = ${executeCode}
413
413
  })();
414
414
  `;
415
415
  }
416
- function parseExecutionResult(stdout, functionId, logger30) {
416
+ function parseExecutionResult(stdout, functionId, logger29) {
417
417
  try {
418
418
  const outputLines = stdout.split("\n").filter((line) => line.trim());
419
419
  const resultLine = outputLines[outputLines.length - 1];
420
420
  return JSON.parse(resultLine);
421
421
  } catch (parseError) {
422
- if (logger30) {
423
- logger30.warn(
422
+ if (logger29) {
423
+ logger29.warn(
424
424
  {
425
425
  functionId,
426
426
  stdout,
@@ -1712,10 +1712,10 @@ var extractContextFromTeamAgentToken = async (token, baseUrl, expectedSubAgentId
1712
1712
 
1713
1713
  // src/openapi.ts
1714
1714
  init_env();
1715
- function setupOpenAPIRoutes(app7) {
1716
- app7.get("/openapi.json", (c) => {
1715
+ function setupOpenAPIRoutes(app6) {
1716
+ app6.get("/openapi.json", (c) => {
1717
1717
  try {
1718
- const document = app7.getOpenAPIDocument({
1718
+ const document = app6.getOpenAPIDocument({
1719
1719
  openapi: "3.0.0",
1720
1720
  info: {
1721
1721
  title: "Inkeep Agents Run API",
@@ -1736,7 +1736,7 @@ function setupOpenAPIRoutes(app7) {
1736
1736
  return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
1737
1737
  }
1738
1738
  });
1739
- app7.get(
1739
+ app6.get(
1740
1740
  "/docs",
1741
1741
  swaggerUi.swaggerUI({
1742
1742
  url: "/openapi.json",
@@ -2091,7 +2091,7 @@ async function handleMessageStream(c, agent, request) {
2091
2091
  }
2092
2092
  }
2093
2093
  };
2094
- return streaming.streamSSE(c, async (stream3) => {
2094
+ return streaming.streamSSE(c, async (stream2) => {
2095
2095
  try {
2096
2096
  const initialTask = {
2097
2097
  id: task.id,
@@ -2103,7 +2103,7 @@ async function handleMessageStream(c, agent, request) {
2103
2103
  artifacts: [],
2104
2104
  kind: "task"
2105
2105
  };
2106
- await stream3.writeSSE({
2106
+ await stream2.writeSSE({
2107
2107
  data: JSON.stringify({
2108
2108
  jsonrpc: "2.0",
2109
2109
  result: initialTask,
@@ -2121,7 +2121,7 @@ async function handleMessageStream(c, agent, request) {
2121
2121
  (part) => part.kind === "data" && part.data && typeof part.data === "object" && part.data.type === "transfer"
2122
2122
  );
2123
2123
  if (transferPart && transferPart.kind === "data" && transferPart.data) {
2124
- await stream3.writeSSE({
2124
+ await stream2.writeSSE({
2125
2125
  data: JSON.stringify({
2126
2126
  jsonrpc: "2.0",
2127
2127
  result: {
@@ -2155,7 +2155,7 @@ async function handleMessageStream(c, agent, request) {
2155
2155
  contextId: params.message.contextId,
2156
2156
  kind: "message"
2157
2157
  };
2158
- await stream3.writeSSE({
2158
+ await stream2.writeSSE({
2159
2159
  data: JSON.stringify({
2160
2160
  jsonrpc: "2.0",
2161
2161
  result: messageResponse,
@@ -2170,7 +2170,7 @@ async function handleMessageStream(c, agent, request) {
2170
2170
  },
2171
2171
  artifacts: result.artifacts
2172
2172
  };
2173
- await stream3.writeSSE({
2173
+ await stream2.writeSSE({
2174
2174
  data: JSON.stringify({
2175
2175
  jsonrpc: "2.0",
2176
2176
  result: completedTask,
@@ -2179,7 +2179,7 @@ async function handleMessageStream(c, agent, request) {
2179
2179
  });
2180
2180
  } catch (error) {
2181
2181
  console.error("Error in stream execution:", error);
2182
- await stream3.writeSSE({
2182
+ await stream2.writeSSE({
2183
2183
  data: JSON.stringify({
2184
2184
  jsonrpc: "2.0",
2185
2185
  error: {
@@ -2311,7 +2311,7 @@ async function handleTasksResubscribe(c, agent, request) {
2311
2311
  id: request.id
2312
2312
  });
2313
2313
  }
2314
- return streaming.streamSSE(c, async (stream3) => {
2314
+ return streaming.streamSSE(c, async (stream2) => {
2315
2315
  try {
2316
2316
  const task = {
2317
2317
  id: params.taskId,
@@ -2323,7 +2323,7 @@ async function handleTasksResubscribe(c, agent, request) {
2323
2323
  artifacts: [],
2324
2324
  kind: "task"
2325
2325
  };
2326
- await stream3.writeSSE({
2326
+ await stream2.writeSSE({
2327
2327
  data: JSON.stringify({
2328
2328
  jsonrpc: "2.0",
2329
2329
  result: task,
@@ -2332,7 +2332,7 @@ async function handleTasksResubscribe(c, agent, request) {
2332
2332
  });
2333
2333
  } catch (error) {
2334
2334
  console.error("Error in task resubscription:", error);
2335
- await stream3.writeSSE({
2335
+ await stream2.writeSSE({
2336
2336
  data: JSON.stringify({
2337
2337
  jsonrpc: "2.0",
2338
2338
  error: {
@@ -10932,8 +10932,8 @@ async function executeTransfer({
10932
10932
  init_dbClient();
10933
10933
  init_logger();
10934
10934
  var SSEStreamHelper = class {
10935
- constructor(stream3, requestId2, timestamp) {
10936
- this.stream = stream3;
10935
+ constructor(stream2, requestId2, timestamp) {
10936
+ this.stream = stream2;
10937
10937
  this.requestId = requestId2;
10938
10938
  this.timestamp = timestamp;
10939
10939
  __publicField(this, "isTextStreaming", false);
@@ -11099,8 +11099,8 @@ ${errorMessage}`);
11099
11099
  await this.writeDone();
11100
11100
  }
11101
11101
  };
11102
- function createSSEStreamHelper(stream3, requestId2, timestamp) {
11103
- return new SSEStreamHelper(stream3, requestId2, timestamp);
11102
+ function createSSEStreamHelper(stream2, requestId2, timestamp) {
11103
+ return new SSEStreamHelper(stream2, requestId2, timestamp);
11104
11104
  }
11105
11105
  var _VercelDataStreamHelper = class _VercelDataStreamHelper {
11106
11106
  // 10 minutes max lifetime
@@ -11247,12 +11247,12 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
11247
11247
  async streamData(data) {
11248
11248
  await this.writeContent(JSON.stringify(data));
11249
11249
  }
11250
- async mergeStream(stream3) {
11250
+ async mergeStream(stream2) {
11251
11251
  if (this.isCompleted) {
11252
11252
  console.warn("Attempted to merge stream to completed stream");
11253
11253
  return;
11254
11254
  }
11255
- this.writer.merge(stream3);
11255
+ this.writer.merge(stream2);
11256
11256
  }
11257
11257
  /**
11258
11258
  * Clean up all memory allocations
@@ -12191,9 +12191,9 @@ app2.openapi(chatCompletionsRoute, async (c) => {
12191
12191
  "database.operation": "insert"
12192
12192
  });
12193
12193
  }
12194
- return streaming.streamSSE(c, async (stream3) => {
12194
+ return streaming.streamSSE(c, async (stream2) => {
12195
12195
  try {
12196
- const sseHelper = createSSEStreamHelper(stream3, requestId2, timestamp);
12196
+ const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
12197
12197
  await sseHelper.writeRole();
12198
12198
  logger25.info({ subAgentId }, "Starting execution");
12199
12199
  const emitOperationsHeader = c.req.header("x-emit-operations");
@@ -12230,7 +12230,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
12230
12230
  "Error during streaming execution"
12231
12231
  );
12232
12232
  try {
12233
- const sseHelper = createSSEStreamHelper(stream3, requestId2, timestamp);
12233
+ const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
12234
12234
  await sseHelper.writeOperation(
12235
12235
  errorOp(
12236
12236
  "Sorry, I was unable to process your request at this time. Please try again.",
@@ -12458,7 +12458,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
12458
12458
  c.header("x-accel-buffering", "no");
12459
12459
  return streaming.stream(
12460
12460
  c,
12461
- (stream3) => stream3.pipe(
12461
+ (stream2) => stream2.pipe(
12462
12462
  dataStream.pipeThrough(new ai.JsonToSseTransformStream()).pipeThrough(new TextEncoderStream())
12463
12463
  )
12464
12464
  );
@@ -12472,247 +12472,6 @@ app3.openapi(chatDataStreamRoute, async (c) => {
12472
12472
  }
12473
12473
  });
12474
12474
  var chatDataStream_default = app3;
12475
- init_dbClient();
12476
- init_logger();
12477
- var logger27 = agentsCore.getLogger("dataComponentPreview");
12478
- var app4 = new zodOpenapi.OpenAPIHono();
12479
- var generatePreviewRoute = zodOpenapi.createRoute({
12480
- method: "post",
12481
- path: "/:tenantId/projects/:projectId/data-components/:id/generate-render",
12482
- tags: ["Data Component Preview"],
12483
- summary: "Generate Component Render",
12484
- description: "Generate a React/Tailwind component render using AI based on the data component schema",
12485
- request: {
12486
- params: z6.z.object({
12487
- tenantId: z6.z.string(),
12488
- projectId: z6.z.string(),
12489
- id: z6.z.string()
12490
- }),
12491
- body: {
12492
- content: {
12493
- "application/json": {
12494
- schema: z6.z.object({
12495
- instructions: z6.z.string().optional().describe("Custom instructions for modifying the component"),
12496
- existingCode: z6.z.string().optional().describe("Existing component code to modify")
12497
- })
12498
- }
12499
- }
12500
- }
12501
- },
12502
- responses: {
12503
- 200: {
12504
- description: "Streaming component code generation",
12505
- headers: z6.z.object({
12506
- "Content-Type": z6.z.string().default("text/plain; charset=utf-8"),
12507
- "Cache-Control": z6.z.string().default("no-cache"),
12508
- Connection: z6.z.string().default("keep-alive")
12509
- }),
12510
- content: {
12511
- "text/plain": {
12512
- schema: z6.z.string().describe("Streaming generated component code")
12513
- }
12514
- }
12515
- },
12516
- ...agentsCore.commonGetErrorResponses
12517
- }
12518
- });
12519
- app4.openapi(generatePreviewRoute, async (c) => {
12520
- const { tenantId, projectId, id } = c.req.valid("param");
12521
- const body = c.req.valid("json");
12522
- const { instructions, existingCode } = body;
12523
- logger27.info(
12524
- {
12525
- tenantId,
12526
- projectId,
12527
- dataComponentId: id,
12528
- hasInstructions: !!instructions,
12529
- hasExistingCode: !!existingCode
12530
- },
12531
- "Generating component preview"
12532
- );
12533
- const dataComponent = await agentsCore.getDataComponent(dbClient_default)({
12534
- scopes: { tenantId, projectId },
12535
- dataComponentId: id
12536
- });
12537
- if (!dataComponent) {
12538
- throw agentsCore.createApiError({
12539
- code: "not_found",
12540
- message: "Data component not found"
12541
- });
12542
- }
12543
- const project = await agentsCore.getProject(dbClient_default)({
12544
- scopes: { tenantId, projectId }
12545
- });
12546
- if (!project?.models?.base) {
12547
- throw agentsCore.createApiError({
12548
- code: "bad_request",
12549
- message: "Project base model configuration is required"
12550
- });
12551
- }
12552
- const prompt = buildGenerationPrompt(dataComponent, instructions, existingCode);
12553
- try {
12554
- const modelConfig = ModelFactory.prepareGenerationConfig(project.models.base);
12555
- const renderSchema = z6.z.object({
12556
- component: z6.z.string().describe("The React component code"),
12557
- mockData: z6.z.any().describe("Sample data matching the props schema")
12558
- });
12559
- const result = ai.streamObject({
12560
- ...modelConfig,
12561
- prompt,
12562
- schema: renderSchema,
12563
- temperature: 0.7
12564
- });
12565
- c.header("Content-Type", "text/plain; charset=utf-8");
12566
- c.header("Cache-Control", "no-cache");
12567
- c.header("Connection", "keep-alive");
12568
- const existingData = existingCode && dataComponent.render && typeof dataComponent.render === "object" && "mockData" in dataComponent.render ? dataComponent.render.mockData : null;
12569
- return streaming.stream(c, async (stream3) => {
12570
- try {
12571
- for await (const partialObject of result.partialObjectStream) {
12572
- const outputObject = instructions && existingData ? { ...partialObject, mockData: existingData } : partialObject;
12573
- await stream3.write(JSON.stringify(outputObject) + "\n");
12574
- }
12575
- } catch (error) {
12576
- logger27.error(
12577
- { error, tenantId, projectId, dataComponentId: id },
12578
- "Error streaming preview generation"
12579
- );
12580
- await stream3.write(
12581
- JSON.stringify({ component: "// Error generating component preview", mockData: {} }) + "\n"
12582
- );
12583
- }
12584
- });
12585
- } catch (error) {
12586
- logger27.error(
12587
- { error, tenantId, projectId, dataComponentId: id },
12588
- "Error generating component preview"
12589
- );
12590
- throw agentsCore.createApiError({
12591
- code: "internal_server_error",
12592
- message: "Failed to generate component preview"
12593
- });
12594
- }
12595
- });
12596
- function buildGenerationPrompt(dataComponent, instructions, existingCode) {
12597
- const propsSchema = dataComponent.props || {};
12598
- const propsJson = JSON.stringify(propsSchema, null, 2);
12599
- const componentName = sanitizeComponentName(dataComponent.name);
12600
- if (instructions && existingCode) {
12601
- return `You are an expert React and Tailwind CSS developer. You need to modify an existing React component based on specific instructions.
12602
-
12603
- COMPONENT DETAILS:
12604
- - Original Name: ${dataComponent.name}
12605
- - Component Function Name: ${componentName}
12606
- - Description: ${dataComponent.description}
12607
- - Props Schema (JSON Schema): ${propsJson}
12608
-
12609
- EXISTING COMPONENT CODE:
12610
- \`\`\`jsx
12611
- ${existingCode}
12612
- \`\`\`
12613
-
12614
- MODIFICATION INSTRUCTIONS:
12615
- ${instructions}
12616
-
12617
- REQUIREMENTS:
12618
- 1. Modify the existing component code according to the instructions
12619
- 2. Keep using Tailwind CSS SEMANTIC COLOR CLASSES (bg-background, text-foreground, etc.)
12620
- 3. Maintain the balanced spacing and design principles from the original
12621
- 4. Keep using lucide-react icons where appropriate
12622
- 5. DO NOT include export statements - just the imports and function
12623
- 6. DO NOT include TypeScript type annotations
12624
- 7. Component name should remain: ${componentName}
12625
- 8. DO NOT regenerate sample data - keep the same data structure
12626
-
12627
- OUTPUT FORMAT:
12628
- You need to generate only one thing:
12629
- 1. "component": The modified React component code as a string
12630
-
12631
- Return ONLY the component field, the mockData field will be reused from the existing render.
12632
-
12633
- EXAMPLE OUTPUT:
12634
- {
12635
- "component": "import { Mail, User } from 'lucide-react';\\n\\nfunction ${componentName}(props) {\\n // Modified component code here\\n}"
12636
- }
12637
-
12638
- Focus on making the requested changes while maintaining the component's quality and design principles.`;
12639
- }
12640
- 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.
12641
-
12642
- COMPONENT DETAILS:
12643
- - Original Name: ${dataComponent.name}
12644
- - Component Function Name: ${componentName}
12645
- - Description: ${dataComponent.description}
12646
- - Props Schema (JSON Schema): ${propsJson}
12647
-
12648
- REQUIREMENTS:
12649
- 1. Create a React functional component (JSX, not TypeScript)
12650
- 2. Use Tailwind CSS SEMANTIC COLOR CLASSES (these automatically adapt to light/dark mode):
12651
- - Background: bg-background, bg-card, bg-muted, bg-muted/40, bg-accent, bg-primary
12652
- - Text: text-foreground, text-muted-foreground, text-card-foreground, text-primary-foreground
12653
- - Borders: border-border, border-input, border-muted
12654
- - DO NOT use direct colors like bg-white, bg-gray-800, text-gray-900, etc.
12655
- - DO NOT use dark: prefix - semantic classes handle dark mode automatically
12656
- 3. Make it balanced - comfortable but efficient:
12657
- - Use moderate padding: p-4, px-4 py-3 (balanced, not cramped or excessive)
12658
- - Use appropriate text sizes: text-sm for body, text-base for headings, text-xs for captions
12659
- - Use balanced spacing: gap-2.5, gap-3, space-y-2, mt-2, mb-3
12660
- - Aim for a clean, professional look with good readability
12661
- 4. Design for embedding - this component blends into existing content:
12662
- - DO NOT add redundant titles or headers unless they're part of the actual data schema
12663
- - Focus on displaying the data directly and elegantly
12664
- - Assume the component is part of a larger conversation or content flow
12665
- - If the schema has a "title" or "name" property, display it as data, not as a wrapper heading
12666
- 5. Use LUCIDE-REACT ICONS to enhance UI aesthetics:
12667
- - Import icons from lucide-react: import { User, Mail, Clock } from 'lucide-react'
12668
- - Use icons with size-4 or size-5 classes for balanced visibility
12669
- - Place icons inline with text or as visual indicators
12670
- - Example: <User className="size-4" /> or <Mail className="size-4 text-muted-foreground" />
12671
- - Common useful icons: User, Mail, Calendar, Clock, Check, X, Star, Heart, Settings, Search, etc.
12672
- 6. The component should accept props that match the JSON Schema properties
12673
- 7. Make it visually appealing and professional - clean with good whitespace
12674
- 8. Use semantic HTML elements
12675
- 9. Make it responsive and accessible
12676
- 10. You can import icons from 'lucide-react' at the top
12677
- 11. DO NOT include export statements - just the imports and function
12678
- 12. DO NOT include TypeScript type annotations
12679
- 13. Component name should be exactly: ${componentName}
12680
-
12681
- AVAILABLE SEMANTIC COLOR CLASSES:
12682
- - Backgrounds: bg-background, bg-foreground, bg-card, bg-popover, bg-primary, bg-secondary, bg-muted, bg-accent, bg-destructive
12683
- - 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
12684
- - Borders: border-border, border-input, border-ring
12685
- - You can use opacity modifiers: bg-muted/40, bg-accent/10, etc.
12686
-
12687
- OUTPUT FORMAT:
12688
- You need to generate two things:
12689
- 1. "component": The complete React component code as a string
12690
- 2. "mockData": Realistic sample data that matches the props schema (as a JSON object)
12691
-
12692
- EXAMPLE OUTPUT (for a user profile schema with name, email, role):
12693
- {
12694
- "component": "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}",
12695
- "mockData": {
12696
- "name": "Sarah Chen",
12697
- "email": "sarah.chen@example.com",
12698
- "role": "Product Manager"
12699
- }
12700
- }
12701
-
12702
- REMEMBER:
12703
- - ONLY use semantic color classes (bg-card, text-foreground, etc.)
12704
- - NO direct colors (bg-white, text-gray-900, etc.)
12705
- - NO dark: prefix needed - semantic classes adapt automatically
12706
- - Use balanced spacing (p-4, gap-2.5/gap-3, text-sm for body, text-base for headings)
12707
- - Use lucide-react icons where appropriate for better UI
12708
- - NO redundant titles - just display the actual data from props
12709
- - Design for embedding - this blends into existing content, not a standalone card
12710
- - Make the sample data realistic and useful for previewing the component`;
12711
- }
12712
- function sanitizeComponentName(name) {
12713
- return name.split(/\s+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("").replace(/[^a-zA-Z0-9]/g, "");
12714
- }
12715
- var dataComponentPreview_default = app4;
12716
12475
 
12717
12476
  // src/routes/mcp.ts
12718
12477
  init_dbClient();
@@ -12720,7 +12479,7 @@ init_logger();
12720
12479
  function createMCPSchema(schema) {
12721
12480
  return schema;
12722
12481
  }
12723
- var logger28 = agentsCore.getLogger("mcp");
12482
+ var logger27 = agentsCore.getLogger("mcp");
12724
12483
  var _MockResponseSingleton = class _MockResponseSingleton {
12725
12484
  constructor() {
12726
12485
  __publicField(this, "mockRes");
@@ -12775,21 +12534,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
12775
12534
  id: 0
12776
12535
  });
12777
12536
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
12778
- logger28.info({ sessionId }, "Spoofing initialization message to set transport state");
12537
+ logger27.info({ sessionId }, "Spoofing initialization message to set transport state");
12779
12538
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
12780
12539
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
12781
12540
  try {
12782
12541
  await transport.handleRequest(req, mockRes, spoofInitMessage);
12783
- logger28.info({ sessionId }, "Successfully spoofed initialization");
12542
+ logger27.info({ sessionId }, "Successfully spoofed initialization");
12784
12543
  } catch (spoofError) {
12785
- logger28.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
12544
+ logger27.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
12786
12545
  }
12787
12546
  };
12788
12547
  var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
12789
12548
  const sessionId = req.headers["mcp-session-id"];
12790
- logger28.info({ sessionId }, "Received MCP session ID");
12549
+ logger27.info({ sessionId }, "Received MCP session ID");
12791
12550
  if (!sessionId) {
12792
- logger28.info({ body }, "Missing session ID");
12551
+ logger27.info({ body }, "Missing session ID");
12793
12552
  res.writeHead(400).end(
12794
12553
  JSON.stringify({
12795
12554
  jsonrpc: "2.0",
@@ -12815,7 +12574,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
12815
12574
  scopes: { tenantId, projectId },
12816
12575
  conversationId: sessionId
12817
12576
  });
12818
- logger28.info(
12577
+ logger27.info(
12819
12578
  {
12820
12579
  sessionId,
12821
12580
  conversationFound: !!conversation,
@@ -12826,7 +12585,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
12826
12585
  "Conversation lookup result"
12827
12586
  );
12828
12587
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.agentId !== agentId) {
12829
- logger28.info(
12588
+ logger27.info(
12830
12589
  { sessionId, conversationId: conversation?.id },
12831
12590
  "MCP session not found or invalid"
12832
12591
  );
@@ -12887,7 +12646,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultS
12887
12646
  requestId: requestId2,
12888
12647
  sseHelper: mcpStreamHelper
12889
12648
  });
12890
- logger28.info(
12649
+ logger27.info(
12891
12650
  { result },
12892
12651
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
12893
12652
  );
@@ -12971,7 +12730,7 @@ var getServer = async (headers2, executionContext, conversationId, credentialSto
12971
12730
  dbClient: dbClient_default,
12972
12731
  credentialStores
12973
12732
  });
12974
- logger28.info(
12733
+ logger27.info(
12975
12734
  {
12976
12735
  tenantId,
12977
12736
  projectId,
@@ -13000,8 +12759,8 @@ var getServer = async (headers2, executionContext, conversationId, credentialSto
13000
12759
  );
13001
12760
  return server;
13002
12761
  };
13003
- var app5 = new zodOpenapi.OpenAPIHono();
13004
- app5.use("/", async (c, next) => {
12762
+ var app4 = new zodOpenapi.OpenAPIHono();
12763
+ app4.use("/", async (c, next) => {
13005
12764
  if (c.req.method === "POST") {
13006
12765
  return agentsCore.contextValidationMiddleware(dbClient_default)(c, next);
13007
12766
  }
@@ -13033,7 +12792,7 @@ var validateRequestParameters = (c) => {
13033
12792
  };
13034
12793
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
13035
12794
  const { tenantId, projectId, agentId } = executionContext;
13036
- logger28.info({ body }, "Received initialization request");
12795
+ logger27.info({ body }, "Received initialization request");
13037
12796
  const sessionId = agentsCore.getConversationId();
13038
12797
  const activeSpan = api.trace.getActiveSpan();
13039
12798
  if (activeSpan) {
@@ -13089,7 +12848,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
13089
12848
  }
13090
12849
  }
13091
12850
  });
13092
- logger28.info(
12851
+ logger27.info(
13093
12852
  { sessionId, conversationId: conversation.id },
13094
12853
  "Created MCP session as conversation"
13095
12854
  );
@@ -13098,9 +12857,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
13098
12857
  });
13099
12858
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
13100
12859
  await server.connect(transport);
13101
- logger28.info({ sessionId }, "Server connected for initialization");
12860
+ logger27.info({ sessionId }, "Server connected for initialization");
13102
12861
  res.setHeader("Mcp-Session-Id", sessionId);
13103
- logger28.info(
12862
+ logger27.info(
13104
12863
  {
13105
12864
  sessionId,
13106
12865
  bodyMethod: body?.method,
@@ -13109,7 +12868,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
13109
12868
  "About to handle initialization request"
13110
12869
  );
13111
12870
  await transport.handleRequest(req, res, body);
13112
- logger28.info({ sessionId }, "Successfully handled initialization request");
12871
+ logger27.info({ sessionId }, "Successfully handled initialization request");
13113
12872
  return fetchToNode.toFetchResponse(res);
13114
12873
  });
13115
12874
  };
@@ -13136,8 +12895,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
13136
12895
  sessionId,
13137
12896
  conversation.metadata?.session_data?.mcpProtocolVersion
13138
12897
  );
13139
- logger28.info({ sessionId }, "Server connected and transport initialized");
13140
- logger28.info(
12898
+ logger27.info({ sessionId }, "Server connected and transport initialized");
12899
+ logger27.info(
13141
12900
  {
13142
12901
  sessionId,
13143
12902
  bodyKeys: Object.keys(body || {}),
@@ -13151,9 +12910,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
13151
12910
  );
13152
12911
  try {
13153
12912
  await transport.handleRequest(req, res, body);
13154
- logger28.info({ sessionId }, "Successfully handled MCP request");
12913
+ logger27.info({ sessionId }, "Successfully handled MCP request");
13155
12914
  } catch (transportError) {
13156
- logger28.error(
12915
+ logger27.error(
13157
12916
  {
13158
12917
  sessionId,
13159
12918
  error: transportError,
@@ -13170,7 +12929,7 @@ var createErrorResponse = (code, message, id = null) => ({
13170
12929
  error: { code, message },
13171
12930
  id
13172
12931
  });
13173
- app5.openapi(
12932
+ app4.openapi(
13174
12933
  zodOpenapi.createRoute({
13175
12934
  method: "post",
13176
12935
  path: "/",
@@ -13204,13 +12963,13 @@ app5.openapi(
13204
12963
  }
13205
12964
  const { executionContext } = paramValidation;
13206
12965
  const body = c.get("requestBody") || {};
13207
- logger28.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
12966
+ logger27.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
13208
12967
  const isInitRequest = body.method === "initialize";
13209
12968
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
13210
12969
  const validatedContext = c.get("validatedContext") || {};
13211
12970
  const credentialStores = c.get("credentialStores");
13212
- logger28.info({ validatedContext }, "Validated context");
13213
- logger28.info({ req }, "request");
12971
+ logger27.info({ validatedContext }, "Validated context");
12972
+ logger27.info({ req }, "request");
13214
12973
  if (isInitRequest) {
13215
12974
  return await handleInitializationRequest(
13216
12975
  body,
@@ -13232,7 +12991,7 @@ app5.openapi(
13232
12991
  );
13233
12992
  }
13234
12993
  } catch (e) {
13235
- logger28.error(
12994
+ logger27.error(
13236
12995
  {
13237
12996
  error: e instanceof Error ? e.message : e,
13238
12997
  stack: e instanceof Error ? e.stack : void 0
@@ -13243,8 +13002,8 @@ app5.openapi(
13243
13002
  }
13244
13003
  }
13245
13004
  );
13246
- app5.get("/", async (c) => {
13247
- logger28.info({}, "Received GET MCP request");
13005
+ app4.get("/", async (c) => {
13006
+ logger27.info({}, "Received GET MCP request");
13248
13007
  return c.json(
13249
13008
  {
13250
13009
  jsonrpc: "2.0",
@@ -13257,8 +13016,8 @@ app5.get("/", async (c) => {
13257
13016
  { status: 405 }
13258
13017
  );
13259
13018
  });
13260
- app5.delete("/", async (c) => {
13261
- logger28.info({}, "Received DELETE MCP request");
13019
+ app4.delete("/", async (c) => {
13020
+ logger27.info({}, "Received DELETE MCP request");
13262
13021
  return c.json(
13263
13022
  {
13264
13023
  jsonrpc: "2.0",
@@ -13268,15 +13027,15 @@ app5.delete("/", async (c) => {
13268
13027
  { status: 405 }
13269
13028
  );
13270
13029
  });
13271
- var mcp_default = app5;
13030
+ var mcp_default = app4;
13272
13031
 
13273
13032
  // src/app.ts
13274
- var logger29 = agentsCore.getLogger("agents-run-api");
13033
+ var logger28 = agentsCore.getLogger("agents-run-api");
13275
13034
  function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13276
- const app7 = new zodOpenapi.OpenAPIHono();
13277
- app7.use("*", otel.otel());
13278
- app7.use("*", requestId.requestId());
13279
- app7.use("*", async (c, next) => {
13035
+ const app6 = new zodOpenapi.OpenAPIHono();
13036
+ app6.use("*", otel.otel());
13037
+ app6.use("*", requestId.requestId());
13038
+ app6.use("*", async (c, next) => {
13280
13039
  c.set("serverConfig", serverConfig);
13281
13040
  c.set("credentialStores", credentialStores);
13282
13041
  if (sandboxConfig) {
@@ -13284,18 +13043,18 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13284
13043
  }
13285
13044
  return next();
13286
13045
  });
13287
- app7.use("*", async (c, next) => {
13046
+ app6.use("*", async (c, next) => {
13288
13047
  if (c.req.header("content-type")?.includes("application/json")) {
13289
13048
  try {
13290
13049
  const body = await c.req.json();
13291
13050
  c.set("requestBody", body);
13292
13051
  } catch (error) {
13293
- logger29.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
13052
+ logger28.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
13294
13053
  }
13295
13054
  }
13296
13055
  return next();
13297
13056
  });
13298
- app7.use("*", async (c, next) => {
13057
+ app6.use("*", async (c, next) => {
13299
13058
  const reqId = c.get("requestId");
13300
13059
  let bag = api.propagation.getBaggage(api.context.active());
13301
13060
  if (!bag) {
@@ -13308,7 +13067,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13308
13067
  }
13309
13068
  return next();
13310
13069
  });
13311
- app7.onError(async (err, c) => {
13070
+ app6.onError(async (err, c) => {
13312
13071
  const isExpectedError = err instanceof httpException.HTTPException;
13313
13072
  const status = isExpectedError ? err.status : 500;
13314
13073
  const requestId2 = c.get("requestId") || "unknown";
@@ -13341,8 +13100,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13341
13100
  if (!isExpectedError) {
13342
13101
  const errorMessage = err instanceof Error ? err.message : String(err);
13343
13102
  const errorStack = err instanceof Error ? err.stack : void 0;
13344
- if (logger29) {
13345
- logger29.error(
13103
+ if (logger28) {
13104
+ logger28.error(
13346
13105
  {
13347
13106
  error: err,
13348
13107
  message: errorMessage,
@@ -13354,8 +13113,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13354
13113
  );
13355
13114
  }
13356
13115
  } else {
13357
- if (logger29) {
13358
- logger29.error(
13116
+ if (logger28) {
13117
+ logger28.error(
13359
13118
  {
13360
13119
  error: err,
13361
13120
  path: c.req.path,
@@ -13372,8 +13131,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13372
13131
  const response = err.getResponse();
13373
13132
  return response;
13374
13133
  } catch (responseError) {
13375
- if (logger29) {
13376
- logger29.error({ error: responseError }, "Error while handling HTTPException response");
13134
+ if (logger28) {
13135
+ logger28.error({ error: responseError }, "Error while handling HTTPException response");
13377
13136
  }
13378
13137
  }
13379
13138
  }
@@ -13389,7 +13148,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13389
13148
  ...instance && { instance }
13390
13149
  });
13391
13150
  });
13392
- app7.use(
13151
+ app6.use(
13393
13152
  "*",
13394
13153
  cors.cors({
13395
13154
  origin: "*",
@@ -13400,14 +13159,14 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13400
13159
  maxAge: 86400
13401
13160
  })
13402
13161
  );
13403
- app7.use("/tenants/*", apiKeyAuth());
13404
- app7.use("/agents/*", apiKeyAuth());
13405
- app7.use("/v1/*", apiKeyAuth());
13406
- app7.use("/api/*", apiKeyAuth());
13407
- app7.use("*", async (c, next) => {
13162
+ app6.use("/tenants/*", apiKeyAuth());
13163
+ app6.use("/agents/*", apiKeyAuth());
13164
+ app6.use("/v1/*", apiKeyAuth());
13165
+ app6.use("/api/*", apiKeyAuth());
13166
+ app6.use("*", async (c, next) => {
13408
13167
  const executionContext = c.get("executionContext");
13409
13168
  if (!executionContext) {
13410
- logger29.debug({}, "Empty execution context");
13169
+ logger28.debug({}, "Empty execution context");
13411
13170
  return next();
13412
13171
  }
13413
13172
  const { tenantId, projectId, agentId } = executionContext;
@@ -13416,7 +13175,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13416
13175
  if (requestBody) {
13417
13176
  conversationId = requestBody.conversationId;
13418
13177
  if (!conversationId) {
13419
- logger29.debug({ requestBody }, "No conversation ID found in request body");
13178
+ logger28.debug({ requestBody }, "No conversation ID found in request body");
13420
13179
  }
13421
13180
  }
13422
13181
  const entries = Object.fromEntries(
@@ -13431,7 +13190,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13431
13190
  })
13432
13191
  );
13433
13192
  if (!Object.keys(entries).length) {
13434
- logger29.debug({}, "Empty entries for baggage");
13193
+ logger28.debug({}, "Empty entries for baggage");
13435
13194
  return next();
13436
13195
  }
13437
13196
  const bag = Object.entries(entries).reduce(
@@ -13441,7 +13200,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13441
13200
  const ctxWithBag = api.propagation.setBaggage(api.context.active(), bag);
13442
13201
  return await api.context.with(ctxWithBag, async () => await next());
13443
13202
  });
13444
- app7.openapi(
13203
+ app6.openapi(
13445
13204
  zodOpenapi.createRoute({
13446
13205
  method: "get",
13447
13206
  path: "/health",
@@ -13458,30 +13217,29 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
13458
13217
  return c.body(null, 204);
13459
13218
  }
13460
13219
  );
13461
- app7.route("/v1/chat", chat_default);
13462
- app7.route("/api", chatDataStream_default);
13463
- app7.route("/v1/mcp", mcp_default);
13464
- app7.route("/agents", agents_default);
13465
- app7.route("/v1", dataComponentPreview_default);
13466
- setupOpenAPIRoutes(app7);
13467
- app7.use("/tenants/*", async (_c, next) => {
13220
+ app6.route("/v1/chat", chat_default);
13221
+ app6.route("/api", chatDataStream_default);
13222
+ app6.route("/v1/mcp", mcp_default);
13223
+ app6.route("/agents", agents_default);
13224
+ setupOpenAPIRoutes(app6);
13225
+ app6.use("/tenants/*", async (_c, next) => {
13468
13226
  await next();
13469
13227
  await flushBatchProcessor();
13470
13228
  });
13471
- app7.use("/agents/*", async (_c, next) => {
13229
+ app6.use("/agents/*", async (_c, next) => {
13472
13230
  await next();
13473
13231
  await flushBatchProcessor();
13474
13232
  });
13475
- app7.use("/v1/*", async (_c, next) => {
13233
+ app6.use("/v1/*", async (_c, next) => {
13476
13234
  await next();
13477
13235
  await flushBatchProcessor();
13478
13236
  });
13479
- app7.use("/api/*", async (_c, next) => {
13237
+ app6.use("/api/*", async (_c, next) => {
13480
13238
  await next();
13481
13239
  await flushBatchProcessor();
13482
13240
  });
13483
13241
  const baseApp = new hono.Hono();
13484
- baseApp.route("/", app7);
13242
+ baseApp.route("/", app6);
13485
13243
  return baseApp;
13486
13244
  }
13487
13245
 
@@ -13497,8 +13255,8 @@ var defaultConfig = {
13497
13255
  };
13498
13256
  var defaultStores = agentsCore.createDefaultCredentialStores();
13499
13257
  var defaultRegistry = new agentsCore.CredentialStoreRegistry(defaultStores);
13500
- var app6 = createExecutionHono(defaultConfig, defaultRegistry);
13501
- var index_default = app6;
13258
+ var app5 = createExecutionHono(defaultConfig, defaultRegistry);
13259
+ var index_default = app5;
13502
13260
  function createExecutionApp(config) {
13503
13261
  const serverConfig = config?.serverConfig ?? defaultConfig;
13504
13262
  const stores = config?.credentialStores ?? defaultStores;