@inkeep/agents-run-api 0.0.0-dev-20251008182848 → 0.0.0-dev-20251008200151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import { HTTPException } from 'hono/http-exception';
14
14
  import { requestId } from 'hono/request-id';
15
15
  import { createMiddleware } from 'hono/factory';
16
16
  import { swaggerUI } from '@hono/swagger-ui';
17
- import z4, { z } from 'zod';
17
+ import z5, { z } from 'zod';
18
18
  import { streamSSE, stream } from 'hono/streaming';
19
19
  import { nanoid } from 'nanoid';
20
20
  import { createUIMessageStream, JsonToSseTransformStream, parsePartialJson, generateObject, tool, streamText, generateText, streamObject } from 'ai';
@@ -24,6 +24,7 @@ import { createGoogleGenerativeAI, google } from '@ai-sdk/google';
24
24
  import { createOpenAI, openai } from '@ai-sdk/openai';
25
25
  import { createOpenRouter, openrouter } from '@openrouter/ai-sdk-provider';
26
26
  import jmespath from 'jmespath';
27
+ import Ajv from 'ajv';
27
28
  import destr from 'destr';
28
29
  import traverse from 'traverse';
29
30
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
@@ -941,38 +942,6 @@ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
941
942
  apiKey
942
943
  });
943
944
  }
944
- async function resolveModelConfig(graphId, agent) {
945
- if (agent.models?.base?.model) {
946
- return {
947
- base: agent.models.base,
948
- structuredOutput: agent.models.structuredOutput || agent.models.base,
949
- summarizer: agent.models.summarizer || agent.models.base
950
- };
951
- }
952
- const graph = await getAgentGraphById(dbClient_default)({
953
- scopes: { tenantId: agent.tenantId, projectId: agent.projectId, graphId }
954
- });
955
- if (graph?.models?.base?.model) {
956
- return {
957
- base: graph.models.base,
958
- structuredOutput: agent.models?.structuredOutput || graph.models.structuredOutput || graph.models.base,
959
- summarizer: agent.models?.summarizer || graph.models.summarizer || graph.models.base
960
- };
961
- }
962
- const project = await getProject(dbClient_default)({
963
- scopes: { tenantId: agent.tenantId, projectId: agent.projectId }
964
- });
965
- if (project?.models?.base?.model) {
966
- return {
967
- base: project.models.base,
968
- structuredOutput: agent.models?.structuredOutput || project.models.structuredOutput || project.models.base,
969
- summarizer: agent.models?.summarizer || project.models.summarizer || project.models.base
970
- };
971
- }
972
- throw new Error(
973
- "Base model configuration is required. Please configure models at the project level."
974
- );
975
- }
976
945
  var logger4 = getLogger("ModelFactory");
977
946
  var _ModelFactory = class _ModelFactory {
978
947
  /**
@@ -1356,7 +1325,43 @@ function unregisterStreamHelper(requestId2) {
1356
1325
  streamHelperRegistry.delete(requestId2);
1357
1326
  }
1358
1327
  var tracer = getTracer("agents-run-api");
1359
- var logger6 = getLogger("ArtifactService");
1328
+ getLogger("SchemaValidation");
1329
+ new Ajv({ allErrors: true, strict: false });
1330
+ function extractPreviewFields(schema) {
1331
+ const previewProperties = {};
1332
+ if (schema.properties) {
1333
+ for (const [key, prop] of Object.entries(schema.properties)) {
1334
+ if (prop.inPreview === true) {
1335
+ const cleanProp = { ...prop };
1336
+ delete cleanProp.inPreview;
1337
+ previewProperties[key] = cleanProp;
1338
+ }
1339
+ }
1340
+ }
1341
+ return {
1342
+ type: "object",
1343
+ properties: previewProperties,
1344
+ required: schema.required?.filter((field) => previewProperties[field])
1345
+ };
1346
+ }
1347
+ function extractFullFields(schema) {
1348
+ const fullProperties = {};
1349
+ if (schema.properties) {
1350
+ for (const [key, prop] of Object.entries(schema.properties)) {
1351
+ const cleanProp = { ...prop };
1352
+ delete cleanProp.inPreview;
1353
+ fullProperties[key] = cleanProp;
1354
+ }
1355
+ }
1356
+ return {
1357
+ type: "object",
1358
+ properties: fullProperties,
1359
+ required: schema.required
1360
+ };
1361
+ }
1362
+
1363
+ // src/services/ArtifactService.ts
1364
+ var logger7 = getLogger("ArtifactService");
1360
1365
  var _ArtifactService = class _ArtifactService {
1361
1366
  constructor(context) {
1362
1367
  this.context = context;
@@ -1368,6 +1373,12 @@ var _ArtifactService = class _ArtifactService {
1368
1373
  static clearCaches() {
1369
1374
  _ArtifactService.selectorCache.clear();
1370
1375
  }
1376
+ /**
1377
+ * Update artifact components in the context
1378
+ */
1379
+ updateArtifactComponents(artifactComponents) {
1380
+ this.context.artifactComponents = artifactComponents;
1381
+ }
1371
1382
  /**
1372
1383
  * Get all artifacts for a context from database
1373
1384
  */
@@ -1382,7 +1393,7 @@ var _ArtifactService = class _ArtifactService {
1382
1393
  id: taskId
1383
1394
  });
1384
1395
  if (!task) {
1385
- logger6.warn({ taskId }, "Task not found when fetching artifacts");
1396
+ logger7.warn({ taskId }, "Task not found when fetching artifacts");
1386
1397
  continue;
1387
1398
  }
1388
1399
  const taskArtifacts = await getLedgerArtifacts(dbClient_default)({
@@ -1400,7 +1411,7 @@ var _ArtifactService = class _ArtifactService {
1400
1411
  }
1401
1412
  }
1402
1413
  } catch (error) {
1403
- logger6.error({ error, contextId }, "Error loading context artifacts");
1414
+ logger7.error({ error, contextId }, "Error loading context artifacts");
1404
1415
  }
1405
1416
  return artifacts;
1406
1417
  }
@@ -1409,12 +1420,12 @@ var _ArtifactService = class _ArtifactService {
1409
1420
  */
1410
1421
  async createArtifact(request, agentId) {
1411
1422
  if (!this.context.sessionId) {
1412
- logger6.warn({ request }, "No session ID available for artifact creation");
1423
+ logger7.warn({ request }, "No session ID available for artifact creation");
1413
1424
  return null;
1414
1425
  }
1415
1426
  const toolResult = toolSessionManager.getToolResult(this.context.sessionId, request.toolCallId);
1416
1427
  if (!toolResult) {
1417
- logger6.warn(
1428
+ logger7.warn(
1418
1429
  { request, sessionId: this.context.sessionId },
1419
1430
  "Tool result not found for artifact"
1420
1431
  );
@@ -1430,7 +1441,7 @@ var _ArtifactService = class _ArtifactService {
1430
1441
  selectedData = selectedData.length > 0 ? selectedData[0] : {};
1431
1442
  }
1432
1443
  if (!selectedData) {
1433
- logger6.warn(
1444
+ logger7.warn(
1434
1445
  {
1435
1446
  request,
1436
1447
  baseSelector: request.baseSelector
@@ -1439,8 +1450,26 @@ var _ArtifactService = class _ArtifactService {
1439
1450
  );
1440
1451
  selectedData = {};
1441
1452
  }
1442
- const summaryData = this.extractProps(selectedData, request.summaryProps || {});
1443
- let fullData = this.extractProps(selectedData, request.fullProps || {});
1453
+ const component = this.context.artifactComponents?.find((ac) => ac.name === request.type);
1454
+ let summaryData = {};
1455
+ let fullData = {};
1456
+ if (component?.props) {
1457
+ const previewSchema = extractPreviewFields(component.props);
1458
+ const fullSchema = extractFullFields(component.props);
1459
+ summaryData = this.extractPropsFromSchema(
1460
+ selectedData,
1461
+ previewSchema,
1462
+ request.detailsSelector || {}
1463
+ );
1464
+ fullData = this.extractPropsFromSchema(
1465
+ selectedData,
1466
+ fullSchema,
1467
+ request.detailsSelector || {}
1468
+ );
1469
+ } else {
1470
+ summaryData = selectedData;
1471
+ fullData = selectedData;
1472
+ }
1444
1473
  const isFullDataEmpty = !fullData || Object.keys(fullData).length === 0 || Object.values(fullData).every(
1445
1474
  (val) => val === null || val === void 0 || val === "" || Array.isArray(val) && val.length === 0 || typeof val === "object" && Object.keys(val).length === 0
1446
1475
  );
@@ -1449,14 +1478,13 @@ var _ArtifactService = class _ArtifactService {
1449
1478
  }
1450
1479
  const cleanedSummaryData = this.cleanEscapedContent(summaryData);
1451
1480
  const cleanedFullData = this.cleanEscapedContent(fullData);
1452
- const component = this.context.artifactComponents?.find((ac) => ac.name === request.type);
1453
1481
  const artifactData = {
1454
1482
  artifactId: request.artifactId,
1455
1483
  toolCallId: request.toolCallId,
1456
1484
  name: "Processing...",
1457
1485
  description: "Name and description being generated...",
1458
1486
  type: request.type,
1459
- artifactSummary: component?.summaryProps ? this.filterBySchema(cleanedSummaryData, component.summaryProps) : cleanedSummaryData
1487
+ data: cleanedSummaryData
1460
1488
  };
1461
1489
  await this.persistArtifact(request, cleanedSummaryData, cleanedFullData, agentId);
1462
1490
  await this.cacheArtifact(
@@ -1467,15 +1495,15 @@ var _ArtifactService = class _ArtifactService {
1467
1495
  );
1468
1496
  return artifactData;
1469
1497
  } catch (error) {
1470
- logger6.error({ error, request }, "Failed to create artifact");
1498
+ logger7.error({ error, request }, "Failed to create artifact");
1471
1499
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
1472
1500
  throw new Error(`Artifact creation failed for ${request.artifactId}: ${errorMessage}`);
1473
1501
  }
1474
1502
  }
1475
1503
  /**
1476
- * Get artifact data by ID and tool call ID
1504
+ * Get artifact summary data by ID and tool call ID
1477
1505
  */
1478
- async getArtifactData(artifactId, toolCallId, artifactMap) {
1506
+ async getArtifactSummary(artifactId, toolCallId, artifactMap) {
1479
1507
  const key = `${artifactId}:${toolCallId}`;
1480
1508
  if (this.context.streamRequestId) {
1481
1509
  const cachedArtifact = await graphSessionManager.getArtifactCache(
@@ -1483,20 +1511,20 @@ var _ArtifactService = class _ArtifactService {
1483
1511
  key
1484
1512
  );
1485
1513
  if (cachedArtifact) {
1486
- return this.formatArtifactData(cachedArtifact, artifactId, toolCallId);
1514
+ return this.formatArtifactSummaryData(cachedArtifact, artifactId, toolCallId);
1487
1515
  }
1488
1516
  }
1489
1517
  if (this.createdArtifacts.has(key)) {
1490
1518
  const cached = this.createdArtifacts.get(key);
1491
- return this.formatArtifactData(cached, artifactId, toolCallId);
1519
+ return this.formatArtifactSummaryData(cached, artifactId, toolCallId);
1492
1520
  }
1493
1521
  if (artifactMap?.has(key)) {
1494
1522
  const artifact = artifactMap.get(key);
1495
- return this.formatArtifactData(artifact, artifactId, toolCallId);
1523
+ return this.formatArtifactSummaryData(artifact, artifactId, toolCallId);
1496
1524
  }
1497
1525
  try {
1498
1526
  if (!this.context.projectId || !this.context.taskId) {
1499
- logger6.warn(
1527
+ logger7.warn(
1500
1528
  { artifactId, toolCallId },
1501
1529
  "No projectId or taskId available for artifact lookup"
1502
1530
  );
@@ -1508,10 +1536,10 @@ var _ArtifactService = class _ArtifactService {
1508
1536
  taskId: this.context.taskId
1509
1537
  });
1510
1538
  if (artifacts.length > 0) {
1511
- return this.formatArtifactData(artifacts[0], artifactId, toolCallId);
1539
+ return this.formatArtifactSummaryData(artifacts[0], artifactId, toolCallId);
1512
1540
  }
1513
1541
  } catch (error) {
1514
- logger6.warn(
1542
+ logger7.warn(
1515
1543
  { artifactId, toolCallId, taskId: this.context.taskId, error },
1516
1544
  "Failed to fetch artifact"
1517
1545
  );
@@ -1519,16 +1547,75 @@ var _ArtifactService = class _ArtifactService {
1519
1547
  return null;
1520
1548
  }
1521
1549
  /**
1522
- * Format raw artifact to standardized data format
1550
+ * Get artifact full data by ID and tool call ID
1551
+ */
1552
+ async getArtifactFull(artifactId, toolCallId, artifactMap) {
1553
+ const key = `${artifactId}:${toolCallId}`;
1554
+ if (this.context.streamRequestId) {
1555
+ const cachedArtifact = await graphSessionManager.getArtifactCache(
1556
+ this.context.streamRequestId,
1557
+ key
1558
+ );
1559
+ if (cachedArtifact) {
1560
+ return this.formatArtifactFullData(cachedArtifact, artifactId, toolCallId);
1561
+ }
1562
+ }
1563
+ if (this.createdArtifacts.has(key)) {
1564
+ const cached = this.createdArtifacts.get(key);
1565
+ return this.formatArtifactFullData(cached, artifactId, toolCallId);
1566
+ }
1567
+ if (artifactMap?.has(key)) {
1568
+ const artifact = artifactMap.get(key);
1569
+ return this.formatArtifactFullData(artifact, artifactId, toolCallId);
1570
+ }
1571
+ try {
1572
+ if (!this.context.projectId || !this.context.taskId) {
1573
+ logger7.warn(
1574
+ { artifactId, toolCallId },
1575
+ "No projectId or taskId available for artifact lookup"
1576
+ );
1577
+ return null;
1578
+ }
1579
+ const artifacts = await getLedgerArtifacts(dbClient_default)({
1580
+ scopes: { tenantId: this.context.tenantId, projectId: this.context.projectId },
1581
+ artifactId,
1582
+ taskId: this.context.taskId
1583
+ });
1584
+ if (artifacts.length > 0) {
1585
+ return this.formatArtifactFullData(artifacts[0], artifactId, toolCallId);
1586
+ }
1587
+ } catch (error) {
1588
+ logger7.warn(
1589
+ { artifactId, toolCallId, taskId: this.context.taskId, error },
1590
+ "Failed to fetch artifact"
1591
+ );
1592
+ }
1593
+ return null;
1594
+ }
1595
+ /**
1596
+ * Format raw artifact to standardized summary data format
1597
+ */
1598
+ formatArtifactSummaryData(artifact, artifactId, toolCallId) {
1599
+ return {
1600
+ artifactId,
1601
+ toolCallId,
1602
+ name: artifact.name || "Processing...",
1603
+ description: artifact.description || "Name and description being generated...",
1604
+ type: artifact.metadata?.artifactType || artifact.artifactType,
1605
+ data: artifact.parts?.[0]?.data?.summary || {}
1606
+ };
1607
+ }
1608
+ /**
1609
+ * Format raw artifact to standardized full data format
1523
1610
  */
1524
- formatArtifactData(artifact, artifactId, toolCallId) {
1611
+ formatArtifactFullData(artifact, artifactId, toolCallId) {
1525
1612
  return {
1526
1613
  artifactId,
1527
1614
  toolCallId,
1528
1615
  name: artifact.name || "Processing...",
1529
1616
  description: artifact.description || "Name and description being generated...",
1530
1617
  type: artifact.metadata?.artifactType || artifact.artifactType,
1531
- artifactSummary: artifact.parts?.[0]?.data?.summary || {}
1618
+ data: artifact.parts?.[0]?.data?.full || {}
1532
1619
  };
1533
1620
  }
1534
1621
  /**
@@ -1546,14 +1633,13 @@ var _ArtifactService = class _ArtifactService {
1546
1633
  taskId: this.context.taskId,
1547
1634
  toolCallId: request.toolCallId,
1548
1635
  artifactType: request.type,
1549
- summaryProps: summaryData,
1550
- fullProps: fullData,
1636
+ summaryData,
1637
+ data: fullData,
1551
1638
  agentId: effectiveAgentId,
1552
1639
  metadata: {
1553
1640
  toolCallId: request.toolCallId,
1554
1641
  baseSelector: request.baseSelector,
1555
- summaryProps: request.summaryProps,
1556
- fullProps: request.fullProps,
1642
+ detailsSelector: request.detailsSelector,
1557
1643
  sessionId: this.context.sessionId,
1558
1644
  artifactType: request.type
1559
1645
  },
@@ -1564,14 +1650,17 @@ var _ArtifactService = class _ArtifactService {
1564
1650
  }
1565
1651
  );
1566
1652
  } else {
1567
- logger6.warn({
1568
- artifactId: request.artifactId,
1569
- hasStreamRequestId: !!this.context.streamRequestId,
1570
- hasAgentId: !!effectiveAgentId,
1571
- hasTaskId: !!this.context.taskId,
1572
- passedAgentId: agentId,
1573
- contextAgentId: this.context.agentId
1574
- }, "Skipping artifact_saved event - missing required context");
1653
+ logger7.warn(
1654
+ {
1655
+ artifactId: request.artifactId,
1656
+ hasStreamRequestId: !!this.context.streamRequestId,
1657
+ hasAgentId: !!effectiveAgentId,
1658
+ hasTaskId: !!this.context.taskId,
1659
+ passedAgentId: agentId,
1660
+ contextAgentId: this.context.agentId
1661
+ },
1662
+ "Skipping artifact_saved event - missing required context"
1663
+ );
1575
1664
  }
1576
1665
  }
1577
1666
  /**
@@ -1581,7 +1670,7 @@ var _ArtifactService = class _ArtifactService {
1581
1670
  const cacheKey = `${artifactId}:${toolCallId}`;
1582
1671
  const artifactForCache = {
1583
1672
  ...artifactData,
1584
- parts: [{ data: { summary: artifactData.artifactSummary, full: fullData } }],
1673
+ parts: [{ data: { summary: artifactData.data, data: fullData } }],
1585
1674
  metadata: { artifactType: artifactData.type, toolCallId },
1586
1675
  taskId: this.context.taskId
1587
1676
  };
@@ -1622,6 +1711,30 @@ var _ArtifactService = class _ArtifactService {
1622
1711
  * Used by GraphSession to save artifacts after name/description generation
1623
1712
  */
1624
1713
  async saveArtifact(artifact) {
1714
+ let summaryData = artifact.data;
1715
+ let fullData = artifact.data;
1716
+ if (this.context.artifactComponents) {
1717
+ const artifactComponent = this.context.artifactComponents.find(
1718
+ (ac) => ac.name === artifact.type
1719
+ );
1720
+ if (artifactComponent?.props) {
1721
+ try {
1722
+ const schema = artifactComponent.props;
1723
+ const previewSchema = extractPreviewFields(schema);
1724
+ const fullSchema = extractFullFields(schema);
1725
+ summaryData = this.filterBySchema(artifact.data, previewSchema);
1726
+ fullData = this.filterBySchema(artifact.data, fullSchema);
1727
+ } catch (error) {
1728
+ logger7.warn(
1729
+ {
1730
+ artifactType: artifact.type,
1731
+ error: error instanceof Error ? error.message : "Unknown error"
1732
+ },
1733
+ "Failed to extract preview/full fields from schema, using full data for both"
1734
+ );
1735
+ }
1736
+ }
1737
+ }
1625
1738
  const artifactToSave = {
1626
1739
  artifactId: artifact.artifactId,
1627
1740
  name: artifact.name,
@@ -1632,8 +1745,8 @@ var _ArtifactService = class _ArtifactService {
1632
1745
  {
1633
1746
  kind: "data",
1634
1747
  data: {
1635
- summary: artifact.summaryProps,
1636
- full: artifact.fullProps
1748
+ summary: summaryData,
1749
+ full: fullData
1637
1750
  }
1638
1751
  }
1639
1752
  ],
@@ -1646,10 +1759,11 @@ var _ArtifactService = class _ArtifactService {
1646
1759
  },
1647
1760
  contextId: this.context.contextId,
1648
1761
  taskId: this.context.taskId,
1762
+ toolCallId: artifact.toolCallId,
1649
1763
  artifact: artifactToSave
1650
1764
  });
1651
1765
  if (!result.created && result.existing) {
1652
- logger6.debug(
1766
+ logger7.debug(
1653
1767
  {
1654
1768
  artifactId: artifact.artifactId,
1655
1769
  taskId: this.context.taskId
@@ -1702,7 +1816,7 @@ var _ArtifactService = class _ArtifactService {
1702
1816
  extracted[propName] = this.cleanEscapedContent(rawValue);
1703
1817
  }
1704
1818
  } catch (error) {
1705
- logger6.warn(
1819
+ logger7.warn(
1706
1820
  { propName, selector, error: error instanceof Error ? error.message : "Unknown error" },
1707
1821
  "Failed to extract property"
1708
1822
  );
@@ -1714,6 +1828,39 @@ var _ArtifactService = class _ArtifactService {
1714
1828
  }
1715
1829
  return extracted;
1716
1830
  }
1831
+ /**
1832
+ * Extract properties from data using schema-defined fields and custom selectors
1833
+ */
1834
+ extractPropsFromSchema(item, schema, customSelectors) {
1835
+ const extracted = {};
1836
+ if (schema.properties) {
1837
+ for (const fieldName of Object.keys(schema.properties)) {
1838
+ try {
1839
+ const customSelector = customSelectors[fieldName];
1840
+ let rawValue;
1841
+ if (customSelector) {
1842
+ const sanitizedSelector = this.sanitizeJMESPathSelector(customSelector);
1843
+ rawValue = jmespath.search(item, sanitizedSelector);
1844
+ } else {
1845
+ rawValue = item[fieldName];
1846
+ }
1847
+ if (rawValue !== null && rawValue !== void 0) {
1848
+ extracted[fieldName] = this.cleanEscapedContent(rawValue);
1849
+ }
1850
+ } catch (error) {
1851
+ logger7.warn(
1852
+ { fieldName, error: error instanceof Error ? error.message : "Unknown error" },
1853
+ "Failed to extract schema field"
1854
+ );
1855
+ const fallbackValue = item[fieldName];
1856
+ if (fallbackValue !== null && fallbackValue !== void 0) {
1857
+ extracted[fieldName] = this.cleanEscapedContent(fallbackValue);
1858
+ }
1859
+ }
1860
+ }
1861
+ }
1862
+ return extracted;
1863
+ }
1717
1864
  /**
1718
1865
  * Filter extracted props based on schema
1719
1866
  */
@@ -1732,15 +1879,19 @@ __publicField(_ArtifactService, "selectorCache", /* @__PURE__ */ new Map());
1732
1879
  var ArtifactService = _ArtifactService;
1733
1880
 
1734
1881
  // src/services/ArtifactParser.ts
1735
- var logger7 = getLogger("ArtifactParser");
1882
+ var logger8 = getLogger("ArtifactParser");
1736
1883
  var _ArtifactParser = class _ArtifactParser {
1737
1884
  constructor(tenantId, options) {
1738
1885
  __publicField(this, "artifactService");
1739
- const context = {
1740
- tenantId,
1741
- ...options
1742
- };
1743
- this.artifactService = new ArtifactService(context);
1886
+ if (options?.artifactService) {
1887
+ this.artifactService = options.artifactService;
1888
+ } else {
1889
+ const context = {
1890
+ tenantId,
1891
+ ...options
1892
+ };
1893
+ this.artifactService = new ArtifactService(context);
1894
+ }
1744
1895
  }
1745
1896
  /**
1746
1897
  * Check if text contains complete artifact markers (ref or create)
@@ -1816,7 +1967,7 @@ var _ArtifactParser = class _ArtifactParser {
1816
1967
  attrs[key] = value;
1817
1968
  }
1818
1969
  if (!attrs.id || !attrs.tool || !attrs.type || !attrs.base) {
1819
- logger7.warn({ attrs, attrString }, "Missing required attributes in artifact annotation");
1970
+ logger8.warn({ attrs, attrString }, "Missing required attributes in artifact annotation");
1820
1971
  return null;
1821
1972
  }
1822
1973
  return {
@@ -1824,8 +1975,7 @@ var _ArtifactParser = class _ArtifactParser {
1824
1975
  toolCallId: attrs.tool,
1825
1976
  type: attrs.type,
1826
1977
  baseSelector: attrs.base,
1827
- summaryProps: attrs.summary || {},
1828
- fullProps: attrs.full || {}
1978
+ detailsSelector: attrs.details || {}
1829
1979
  };
1830
1980
  }
1831
1981
  /**
@@ -1854,8 +2004,7 @@ var _ArtifactParser = class _ArtifactParser {
1854
2004
  toolCallId: annotation.toolCallId,
1855
2005
  type: annotation.type,
1856
2006
  baseSelector: annotation.baseSelector,
1857
- summaryProps: annotation.summaryProps,
1858
- fullProps: annotation.fullProps
2007
+ detailsSelector: annotation.detailsSelector
1859
2008
  };
1860
2009
  return this.artifactService.createArtifact(request, agentId);
1861
2010
  }
@@ -1875,9 +2024,14 @@ var _ArtifactParser = class _ArtifactParser {
1875
2024
  if (artifactData && annotation.raw) {
1876
2025
  createdArtifactData.set(annotation.raw, artifactData);
1877
2026
  } else if (annotation.raw) {
1878
- failedAnnotations.push(`Failed to create artifact "${annotation.artifactId}": Missing or invalid data`);
2027
+ failedAnnotations.push(
2028
+ `Failed to create artifact "${annotation.artifactId}": Missing or invalid data`
2029
+ );
1879
2030
  processedText = processedText.replace(annotation.raw, "");
1880
- logger7.warn({ annotation, artifactData }, "Removed failed artifact:create annotation from output");
2031
+ logger8.warn(
2032
+ { annotation, artifactData },
2033
+ "Removed failed artifact:create annotation from output"
2034
+ );
1881
2035
  }
1882
2036
  } catch (error) {
1883
2037
  const errorMsg = error instanceof Error ? error.message : "Unknown error";
@@ -1885,14 +2039,17 @@ var _ArtifactParser = class _ArtifactParser {
1885
2039
  if (annotation.raw) {
1886
2040
  processedText = processedText.replace(annotation.raw, "");
1887
2041
  }
1888
- logger7.error({ annotation, error }, "Failed to extract artifact from create annotation");
2042
+ logger8.error({ annotation, error }, "Failed to extract artifact from create annotation");
1889
2043
  }
1890
2044
  }
1891
2045
  if (failedAnnotations.length > 0) {
1892
- logger7.warn({
1893
- failedCount: failedAnnotations.length,
1894
- failures: failedAnnotations
1895
- }, "Some artifact creation attempts failed");
2046
+ logger8.warn(
2047
+ {
2048
+ failedCount: failedAnnotations.length,
2049
+ failures: failedAnnotations
2050
+ },
2051
+ "Some artifact creation attempts failed"
2052
+ );
1896
2053
  }
1897
2054
  const parts = [];
1898
2055
  const createRegex = /<artifact:create\s+([^>]+?)(?:\s*\/)?>(?:(.*?)<\/artifact:create>)?/gs;
@@ -1925,7 +2082,17 @@ var _ArtifactParser = class _ArtifactParser {
1925
2082
  artifactData = await this.getArtifactData(artifactId, toolCallId, artifactMap);
1926
2083
  }
1927
2084
  if (artifactData) {
1928
- parts.push({ kind: "data", data: artifactData });
2085
+ parts.push({
2086
+ kind: "data",
2087
+ data: {
2088
+ artifactId: artifactData.artifactId,
2089
+ toolCallId: artifactData.toolCallId,
2090
+ name: artifactData.name,
2091
+ description: artifactData.description,
2092
+ type: artifactData.type,
2093
+ artifactSummary: artifactData.data
2094
+ }
2095
+ });
1929
2096
  }
1930
2097
  lastIndex = matchStart + fullMatch.length;
1931
2098
  }
@@ -1951,12 +2118,32 @@ var _ArtifactParser = class _ArtifactParser {
1951
2118
  artifactMap
1952
2119
  );
1953
2120
  if (artifactData) {
1954
- parts.push({ kind: "data", data: artifactData });
2121
+ parts.push({
2122
+ kind: "data",
2123
+ data: {
2124
+ artifactId: artifactData.artifactId,
2125
+ toolCallId: artifactData.toolCallId,
2126
+ name: artifactData.name,
2127
+ description: artifactData.description,
2128
+ type: artifactData.type,
2129
+ artifactSummary: artifactData.data
2130
+ }
2131
+ });
1955
2132
  }
1956
2133
  } else if (this.isArtifactCreateComponent(component)) {
1957
2134
  const createData = await this.extractFromArtifactCreateComponent(component, agentId);
1958
2135
  if (createData) {
1959
- parts.push({ kind: "data", data: createData });
2136
+ parts.push({
2137
+ kind: "data",
2138
+ data: {
2139
+ artifactId: createData.artifactId,
2140
+ toolCallId: createData.toolCallId,
2141
+ name: createData.name,
2142
+ description: createData.description,
2143
+ type: createData.type,
2144
+ artifactSummary: createData.data
2145
+ }
2146
+ });
1960
2147
  }
1961
2148
  } else {
1962
2149
  parts.push({ kind: "data", data: component });
@@ -1970,11 +2157,35 @@ var _ArtifactParser = class _ArtifactParser {
1970
2157
  obj.props.tool_call_id,
1971
2158
  artifactMap
1972
2159
  );
1973
- return artifactData ? [{ kind: "data", data: artifactData }] : [];
2160
+ return artifactData ? [
2161
+ {
2162
+ kind: "data",
2163
+ data: {
2164
+ artifactId: artifactData.artifactId,
2165
+ toolCallId: artifactData.toolCallId,
2166
+ name: artifactData.name,
2167
+ description: artifactData.description,
2168
+ type: artifactData.type,
2169
+ artifactSummary: artifactData.data
2170
+ }
2171
+ }
2172
+ ] : [];
1974
2173
  }
1975
2174
  if (this.isArtifactCreateComponent(obj)) {
1976
2175
  const createData = await this.extractFromArtifactCreateComponent(obj, agentId);
1977
- return createData ? [{ kind: "data", data: createData }] : [];
2176
+ return createData ? [
2177
+ {
2178
+ kind: "data",
2179
+ data: {
2180
+ artifactId: createData.artifactId,
2181
+ toolCallId: createData.toolCallId,
2182
+ name: createData.name,
2183
+ description: createData.description,
2184
+ type: createData.type,
2185
+ artifactSummary: createData.data
2186
+ }
2187
+ }
2188
+ ] : [];
1978
2189
  }
1979
2190
  return [{ kind: "data", data: obj }];
1980
2191
  }
@@ -2003,8 +2214,7 @@ var _ArtifactParser = class _ArtifactParser {
2003
2214
  toolCallId: props.tool_call_id,
2004
2215
  type: props.type,
2005
2216
  baseSelector: props.base_selector,
2006
- summaryProps: props.summary_props || {},
2007
- fullProps: props.full_props || {}
2217
+ detailsSelector: props.details_selector || {}
2008
2218
  };
2009
2219
  return await this.extractFromCreateAnnotation(annotation, agentId);
2010
2220
  }
@@ -2012,7 +2222,7 @@ var _ArtifactParser = class _ArtifactParser {
2012
2222
  * Get artifact data - delegates to service
2013
2223
  */
2014
2224
  async getArtifactData(artifactId, toolCallId, artifactMap) {
2015
- return this.artifactService.getArtifactData(artifactId, toolCallId, artifactMap);
2225
+ return await this.artifactService.getArtifactSummary(artifactId, toolCallId, artifactMap);
2016
2226
  }
2017
2227
  };
2018
2228
  // Shared regex patterns - support both single and double quotes
@@ -2046,7 +2256,7 @@ __publicField(_ArtifactParser, "INCOMPLETE_CREATE_REGEX", /<artifact:create(?![^
2046
2256
  var ArtifactParser = _ArtifactParser;
2047
2257
 
2048
2258
  // src/services/GraphSession.ts
2049
- var logger8 = getLogger("GraphSession");
2259
+ var logger9 = getLogger("GraphSession");
2050
2260
  var GraphSession = class {
2051
2261
  // Whether to send data operations
2052
2262
  constructor(sessionId, messageId, graphId, tenantId, projectId, contextId) {
@@ -2079,7 +2289,7 @@ var GraphSession = class {
2079
2289
  __publicField(this, "artifactParser");
2080
2290
  // Session-scoped ArtifactParser instance
2081
2291
  __publicField(this, "isEmitOperations", false);
2082
- logger8.debug({ sessionId, messageId, graphId }, "GraphSession created");
2292
+ logger9.debug({ sessionId, messageId, graphId }, "GraphSession created");
2083
2293
  if (tenantId && projectId) {
2084
2294
  toolSessionManager.createSessionWithId(
2085
2295
  sessionId,
@@ -2103,7 +2313,9 @@ var GraphSession = class {
2103
2313
  sessionId,
2104
2314
  contextId,
2105
2315
  taskId: `task_${contextId}-${messageId}`,
2106
- streamRequestId: sessionId
2316
+ streamRequestId: sessionId,
2317
+ artifactService: this.artifactService
2318
+ // Pass the shared ArtifactService
2107
2319
  });
2108
2320
  }
2109
2321
  }
@@ -2112,7 +2324,7 @@ var GraphSession = class {
2112
2324
  */
2113
2325
  enableEmitOperations() {
2114
2326
  this.isEmitOperations = true;
2115
- logger8.info(
2327
+ logger9.info(
2116
2328
  { sessionId: this.sessionId },
2117
2329
  "\u{1F50D} DEBUG: Emit operations enabled for GraphSession"
2118
2330
  );
@@ -2136,7 +2348,7 @@ var GraphSession = class {
2136
2348
  await streamHelper.writeOperation(formattedOperation);
2137
2349
  }
2138
2350
  } catch (error) {
2139
- logger8.error(
2351
+ logger9.error(
2140
2352
  {
2141
2353
  sessionId: this.sessionId,
2142
2354
  eventType: event.eventType,
@@ -2199,7 +2411,7 @@ var GraphSession = class {
2199
2411
  if (this.statusUpdateState.config.timeInSeconds) {
2200
2412
  this.statusUpdateTimer = setInterval(async () => {
2201
2413
  if (!this.statusUpdateState || this.isEnded) {
2202
- logger8.debug(
2414
+ logger9.debug(
2203
2415
  { sessionId: this.sessionId },
2204
2416
  "Timer triggered but session already cleaned up or ended"
2205
2417
  );
@@ -2211,7 +2423,7 @@ var GraphSession = class {
2211
2423
  }
2212
2424
  await this.checkAndSendTimeBasedUpdate();
2213
2425
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
2214
- logger8.info(
2426
+ logger9.info(
2215
2427
  {
2216
2428
  sessionId: this.sessionId,
2217
2429
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -2233,7 +2445,7 @@ var GraphSession = class {
2233
2445
  });
2234
2446
  }
2235
2447
  if (this.isEnded) {
2236
- logger8.debug(
2448
+ logger9.debug(
2237
2449
  {
2238
2450
  sessionId: this.sessionId,
2239
2451
  eventType,
@@ -2253,7 +2465,7 @@ var GraphSession = class {
2253
2465
  if (eventType === "artifact_saved" && data.pendingGeneration) {
2254
2466
  const artifactId = data.artifactId;
2255
2467
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
2256
- logger8.warn(
2468
+ logger9.warn(
2257
2469
  {
2258
2470
  sessionId: this.sessionId,
2259
2471
  artifactId,
@@ -2275,7 +2487,7 @@ var GraphSession = class {
2275
2487
  this.artifactProcessingErrors.set(artifactId, errorCount);
2276
2488
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
2277
2489
  this.pendingArtifacts.delete(artifactId);
2278
- logger8.error(
2490
+ logger9.error(
2279
2491
  {
2280
2492
  sessionId: this.sessionId,
2281
2493
  artifactId,
@@ -2287,7 +2499,7 @@ var GraphSession = class {
2287
2499
  "Artifact processing failed after max retries, giving up"
2288
2500
  );
2289
2501
  } else {
2290
- logger8.warn(
2502
+ logger9.warn(
2291
2503
  {
2292
2504
  sessionId: this.sessionId,
2293
2505
  artifactId,
@@ -2309,14 +2521,14 @@ var GraphSession = class {
2309
2521
  */
2310
2522
  checkStatusUpdates() {
2311
2523
  if (this.isEnded) {
2312
- logger8.debug(
2524
+ logger9.debug(
2313
2525
  { sessionId: this.sessionId },
2314
2526
  "Session has ended - skipping status update check"
2315
2527
  );
2316
2528
  return;
2317
2529
  }
2318
2530
  if (!this.statusUpdateState) {
2319
- logger8.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
2531
+ logger9.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
2320
2532
  return;
2321
2533
  }
2322
2534
  const statusUpdateState = this.statusUpdateState;
@@ -2327,11 +2539,11 @@ var GraphSession = class {
2327
2539
  */
2328
2540
  async checkAndSendTimeBasedUpdate() {
2329
2541
  if (this.isEnded) {
2330
- logger8.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
2542
+ logger9.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
2331
2543
  return;
2332
2544
  }
2333
2545
  if (!this.statusUpdateState) {
2334
- logger8.debug(
2546
+ logger9.debug(
2335
2547
  { sessionId: this.sessionId },
2336
2548
  "No status updates configured for time-based check"
2337
2549
  );
@@ -2344,7 +2556,7 @@ var GraphSession = class {
2344
2556
  try {
2345
2557
  await this.generateAndSendUpdate();
2346
2558
  } catch (error) {
2347
- logger8.error(
2559
+ logger9.error(
2348
2560
  {
2349
2561
  sessionId: this.sessionId,
2350
2562
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2447,29 +2659,29 @@ var GraphSession = class {
2447
2659
  */
2448
2660
  async generateAndSendUpdate() {
2449
2661
  if (this.isEnded) {
2450
- logger8.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
2662
+ logger9.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
2451
2663
  return;
2452
2664
  }
2453
2665
  if (this.isTextStreaming) {
2454
- logger8.debug(
2666
+ logger9.debug(
2455
2667
  { sessionId: this.sessionId },
2456
2668
  "Text is currently streaming - skipping status update"
2457
2669
  );
2458
2670
  return;
2459
2671
  }
2460
2672
  if (this.isGeneratingUpdate) {
2461
- logger8.debug(
2673
+ logger9.debug(
2462
2674
  { sessionId: this.sessionId },
2463
2675
  "Update already in progress - skipping duplicate generation"
2464
2676
  );
2465
2677
  return;
2466
2678
  }
2467
2679
  if (!this.statusUpdateState) {
2468
- logger8.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
2680
+ logger9.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
2469
2681
  return;
2470
2682
  }
2471
2683
  if (!this.graphId) {
2472
- logger8.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
2684
+ logger9.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
2473
2685
  return;
2474
2686
  }
2475
2687
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -2481,7 +2693,7 @@ var GraphSession = class {
2481
2693
  try {
2482
2694
  const streamHelper = getStreamHelper(this.sessionId);
2483
2695
  if (!streamHelper) {
2484
- logger8.warn(
2696
+ logger9.warn(
2485
2697
  { sessionId: this.sessionId },
2486
2698
  "No stream helper found - cannot send status update"
2487
2699
  );
@@ -2501,7 +2713,7 @@ var GraphSession = class {
2501
2713
  if (result.summaries && result.summaries.length > 0) {
2502
2714
  for (const summary of result.summaries) {
2503
2715
  if (!summary || !summary.type || !summary.data || !summary.data.label || Object.keys(summary.data).length === 0) {
2504
- logger8.warn(
2716
+ logger9.warn(
2505
2717
  {
2506
2718
  sessionId: this.sessionId,
2507
2719
  summary
@@ -2538,7 +2750,7 @@ var GraphSession = class {
2538
2750
  this.statusUpdateState.lastEventCount = this.events.length;
2539
2751
  }
2540
2752
  } catch (error) {
2541
- logger8.error(
2753
+ logger9.error(
2542
2754
  {
2543
2755
  sessionId: this.sessionId,
2544
2756
  error: error instanceof Error ? error.message : "Unknown error",
@@ -2576,7 +2788,7 @@ var GraphSession = class {
2576
2788
  this.releaseUpdateLock();
2577
2789
  }
2578
2790
  } catch (error) {
2579
- logger8.error(
2791
+ logger9.error(
2580
2792
  {
2581
2793
  sessionId: this.sessionId,
2582
2794
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2654,7 +2866,7 @@ User's Question/Context:
2654
2866
  ${conversationHistory}
2655
2867
  ` : "";
2656
2868
  } catch (error) {
2657
- logger8.warn(
2869
+ logger9.warn(
2658
2870
  { sessionId: this.sessionId, error },
2659
2871
  "Failed to fetch conversation history for structured status update"
2660
2872
  );
@@ -2788,7 +3000,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2788
3000
  return { summaries };
2789
3001
  } catch (error) {
2790
3002
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
2791
- logger8.error({ error }, "Failed to generate structured update, using fallback");
3003
+ logger9.error({ error }, "Failed to generate structured update, using fallback");
2792
3004
  return { summaries: [] };
2793
3005
  } finally {
2794
3006
  span.end();
@@ -2933,6 +3145,9 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2933
3145
  "graph_session.id": this.sessionId,
2934
3146
  "artifact.id": artifactData.artifactId,
2935
3147
  "artifact.type": artifactData.artifactType || "unknown",
3148
+ "artifact.agent_id": artifactData.agentId || "unknown",
3149
+ "artifact.tool_call_id": artifactData.metadata?.toolCallId || "unknown",
3150
+ "artifact.data": JSON.stringify(artifactData.data, null, 2),
2936
3151
  "tenant.id": artifactData.tenantId || "unknown",
2937
3152
  "project.id": artifactData.projectId || "unknown",
2938
3153
  "context.id": artifactData.contextId || "unknown",
@@ -2983,8 +3198,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2983
3198
  Tool Context: ${toolContext ? JSON.stringify(toolContext, null, 2) : "No tool context"}
2984
3199
  Context: ${conversationHistory?.slice(-200) || "Processing"}
2985
3200
  Type: ${artifactData.artifactType || "data"}
2986
- Summary: ${JSON.stringify(artifactData.summaryProps, null, 2)}
2987
- Full: ${JSON.stringify(artifactData.fullProps, null, 2)}
3201
+ Data: ${JSON.stringify(artifactData.data || artifactData.summaryData, null, 2)}
2988
3202
 
2989
3203
  Make it specific and relevant.`;
2990
3204
  let modelToUse = this.statusUpdateState?.summarizerModel;
@@ -3002,7 +3216,7 @@ Make it specific and relevant.`;
3002
3216
  });
3003
3217
  if (agentData && "models" in agentData && agentData.models?.base?.model) {
3004
3218
  modelToUse = agentData.models.base;
3005
- logger8.info(
3219
+ logger9.info(
3006
3220
  {
3007
3221
  sessionId: this.sessionId,
3008
3222
  artifactId: artifactData.artifactId,
@@ -3013,7 +3227,7 @@ Make it specific and relevant.`;
3013
3227
  );
3014
3228
  }
3015
3229
  } catch (error) {
3016
- logger8.warn(
3230
+ logger9.warn(
3017
3231
  {
3018
3232
  sessionId: this.sessionId,
3019
3233
  artifactId: artifactData.artifactId,
@@ -3025,7 +3239,7 @@ Make it specific and relevant.`;
3025
3239
  }
3026
3240
  }
3027
3241
  if (!modelToUse?.model?.trim()) {
3028
- logger8.warn(
3242
+ logger9.warn(
3029
3243
  {
3030
3244
  sessionId: this.sessionId,
3031
3245
  artifactId: artifactData.artifactId
@@ -3058,8 +3272,12 @@ Make it specific and relevant.`;
3058
3272
  "llm.operation": "generate_object",
3059
3273
  "artifact.id": artifactData.artifactId,
3060
3274
  "artifact.type": artifactData.artifactType,
3061
- "artifact.summary": JSON.stringify(artifactData.summaryProps, null, 2),
3062
- "artifact.full": JSON.stringify(artifactData.fullProps, null, 2),
3275
+ "artifact.summary": JSON.stringify(artifactData.summaryData, null, 2),
3276
+ "artifact.full": JSON.stringify(
3277
+ artifactData.data || artifactData.summaryData,
3278
+ null,
3279
+ 2
3280
+ ),
3063
3281
  "prompt.length": prompt.length
3064
3282
  }
3065
3283
  },
@@ -3089,8 +3307,12 @@ Make it specific and relevant.`;
3089
3307
  "artifact.type": artifactData.artifactType,
3090
3308
  "artifact.name": result2.object.name,
3091
3309
  "artifact.description": result2.object.description,
3092
- "artifact.summary": JSON.stringify(artifactData.summaryProps, null, 2),
3093
- "artifact.full": JSON.stringify(artifactData.fullProps, null, 2),
3310
+ "artifact.summary": JSON.stringify(artifactData.summaryData, null, 2),
3311
+ "artifact.full": JSON.stringify(
3312
+ artifactData.data || artifactData.summaryData,
3313
+ null,
3314
+ 2
3315
+ ),
3094
3316
  "generation.name_length": result2.object.name.length,
3095
3317
  "generation.description_length": result2.object.description.length,
3096
3318
  "generation.attempts": attempt
@@ -3099,7 +3321,7 @@ Make it specific and relevant.`;
3099
3321
  return result2;
3100
3322
  } catch (error) {
3101
3323
  lastError = error instanceof Error ? error : new Error(String(error));
3102
- logger8.warn(
3324
+ logger9.warn(
3103
3325
  {
3104
3326
  sessionId: this.sessionId,
3105
3327
  artifactId: artifactData.artifactId,
@@ -3139,9 +3361,9 @@ Make it specific and relevant.`;
3139
3361
  name: result.name,
3140
3362
  description: result.description,
3141
3363
  type: artifactData.artifactType || "source",
3142
- summaryProps: artifactData.summaryProps || {},
3143
- fullProps: artifactData.fullProps || {},
3144
- metadata: artifactData.metadata || {}
3364
+ data: artifactData.data || {},
3365
+ metadata: artifactData.metadata || {},
3366
+ toolCallId: artifactData.toolCallId
3145
3367
  });
3146
3368
  mainSaveSucceeded = true;
3147
3369
  span.setAttributes({
@@ -3151,7 +3373,7 @@ Make it specific and relevant.`;
3151
3373
  });
3152
3374
  span.setStatus({ code: SpanStatusCode.OK });
3153
3375
  } catch (saveError) {
3154
- logger8.error(
3376
+ logger9.error(
3155
3377
  {
3156
3378
  sessionId: this.sessionId,
3157
3379
  artifactId: artifactData.artifactId,
@@ -3175,11 +3397,11 @@ Make it specific and relevant.`;
3175
3397
  name: `Artifact ${artifactData.artifactId.substring(0, 8)}`,
3176
3398
  description: `${artifactData.artifactType || "Data"} from ${artifactData.metadata?.toolName || "tool results"}`,
3177
3399
  type: artifactData.artifactType || "source",
3178
- summaryProps: artifactData.summaryProps || {},
3179
- fullProps: artifactData.fullProps || {},
3180
- metadata: artifactData.metadata || {}
3400
+ data: artifactData.data || {},
3401
+ metadata: artifactData.metadata || {},
3402
+ toolCallId: artifactData.toolCallId
3181
3403
  });
3182
- logger8.info(
3404
+ logger9.info(
3183
3405
  {
3184
3406
  sessionId: this.sessionId,
3185
3407
  artifactId: artifactData.artifactId
@@ -3190,7 +3412,7 @@ Make it specific and relevant.`;
3190
3412
  } catch (fallbackError) {
3191
3413
  const isDuplicateError = fallbackError instanceof Error && (fallbackError.message?.includes("UNIQUE") || fallbackError.message?.includes("duplicate"));
3192
3414
  if (isDuplicateError) ; else {
3193
- logger8.error(
3415
+ logger9.error(
3194
3416
  {
3195
3417
  sessionId: this.sessionId,
3196
3418
  artifactId: artifactData.artifactId,
@@ -3203,7 +3425,7 @@ Make it specific and relevant.`;
3203
3425
  }
3204
3426
  } catch (error) {
3205
3427
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
3206
- logger8.error(
3428
+ logger9.error(
3207
3429
  {
3208
3430
  sessionId: this.sessionId,
3209
3431
  artifactId: artifactData.artifactId,
@@ -3222,7 +3444,7 @@ Make it specific and relevant.`;
3222
3444
  */
3223
3445
  setArtifactCache(key, artifact) {
3224
3446
  this.artifactCache.set(key, artifact);
3225
- logger8.debug({ sessionId: this.sessionId, key }, "Artifact cached in session");
3447
+ logger9.debug({ sessionId: this.sessionId, key }, "Artifact cached in session");
3226
3448
  }
3227
3449
  /**
3228
3450
  * Get session-scoped ArtifactService instance
@@ -3241,9 +3463,17 @@ Make it specific and relevant.`;
3241
3463
  */
3242
3464
  getArtifactCache(key) {
3243
3465
  const artifact = this.artifactCache.get(key);
3244
- logger8.debug({ sessionId: this.sessionId, key, found: !!artifact }, "Artifact cache lookup");
3466
+ logger9.debug({ sessionId: this.sessionId, key, found: !!artifact }, "Artifact cache lookup");
3245
3467
  return artifact || null;
3246
3468
  }
3469
+ /**
3470
+ * Update artifact components in the shared ArtifactService
3471
+ */
3472
+ updateArtifactComponents(artifactComponents) {
3473
+ if (this.artifactService) {
3474
+ this.artifactService.updateArtifactComponents(artifactComponents);
3475
+ }
3476
+ }
3247
3477
  };
3248
3478
  var GraphSessionManager = class {
3249
3479
  constructor() {
@@ -3256,7 +3486,7 @@ var GraphSessionManager = class {
3256
3486
  const sessionId = messageId;
3257
3487
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId, contextId);
3258
3488
  this.sessions.set(sessionId, session);
3259
- logger8.info(
3489
+ logger9.info(
3260
3490
  { sessionId, messageId, graphId, tenantId, projectId, contextId },
3261
3491
  "GraphSession created"
3262
3492
  );
@@ -3270,7 +3500,7 @@ var GraphSessionManager = class {
3270
3500
  if (session) {
3271
3501
  session.initializeStatusUpdates(config, summarizerModel);
3272
3502
  } else {
3273
- logger8.error(
3503
+ logger9.error(
3274
3504
  {
3275
3505
  sessionId,
3276
3506
  availableSessions: Array.from(this.sessions.keys())
@@ -3287,7 +3517,7 @@ var GraphSessionManager = class {
3287
3517
  if (session) {
3288
3518
  session.enableEmitOperations();
3289
3519
  } else {
3290
- logger8.error(
3520
+ logger9.error(
3291
3521
  {
3292
3522
  sessionId,
3293
3523
  availableSessions: Array.from(this.sessions.keys())
@@ -3308,7 +3538,7 @@ var GraphSessionManager = class {
3308
3538
  recordEvent(sessionId, eventType, agentId, data) {
3309
3539
  const session = this.sessions.get(sessionId);
3310
3540
  if (!session) {
3311
- logger8.warn({ sessionId }, "Attempted to record event in non-existent session");
3541
+ logger9.warn({ sessionId }, "Attempted to record event in non-existent session");
3312
3542
  return;
3313
3543
  }
3314
3544
  session.recordEvent(eventType, agentId, data);
@@ -3319,12 +3549,12 @@ var GraphSessionManager = class {
3319
3549
  endSession(sessionId) {
3320
3550
  const session = this.sessions.get(sessionId);
3321
3551
  if (!session) {
3322
- logger8.warn({ sessionId }, "Attempted to end non-existent session");
3552
+ logger9.warn({ sessionId }, "Attempted to end non-existent session");
3323
3553
  return [];
3324
3554
  }
3325
3555
  const events = session.getEvents();
3326
3556
  const summary = session.getSummary();
3327
- logger8.info({ sessionId, summary }, "GraphSession ended");
3557
+ logger9.info({ sessionId, summary }, "GraphSession ended");
3328
3558
  session.cleanup();
3329
3559
  this.sessions.delete(sessionId);
3330
3560
  return events;
@@ -3378,11 +3608,52 @@ var GraphSessionManager = class {
3378
3608
  const session = this.sessions.get(sessionId);
3379
3609
  return session ? session.getArtifactParser() : null;
3380
3610
  }
3611
+ /**
3612
+ * Update artifact components for a session
3613
+ */
3614
+ updateArtifactComponents(sessionId, artifactComponents) {
3615
+ const session = this.sessions.get(sessionId);
3616
+ if (session) {
3617
+ session.updateArtifactComponents(artifactComponents);
3618
+ }
3619
+ }
3381
3620
  };
3382
3621
  var graphSessionManager = new GraphSessionManager();
3622
+ async function resolveModelConfig(graphId, agent) {
3623
+ if (agent.models?.base?.model) {
3624
+ return {
3625
+ base: agent.models.base,
3626
+ structuredOutput: agent.models.structuredOutput || agent.models.base,
3627
+ summarizer: agent.models.summarizer || agent.models.base
3628
+ };
3629
+ }
3630
+ const graph = await getAgentGraphById(dbClient_default)({
3631
+ scopes: { tenantId: agent.tenantId, projectId: agent.projectId, graphId }
3632
+ });
3633
+ if (graph?.models?.base?.model) {
3634
+ return {
3635
+ base: graph.models.base,
3636
+ structuredOutput: agent.models?.structuredOutput || graph.models.structuredOutput || graph.models.base,
3637
+ summarizer: agent.models?.summarizer || graph.models.summarizer || graph.models.base
3638
+ };
3639
+ }
3640
+ const project = await getProject(dbClient_default)({
3641
+ scopes: { tenantId: agent.tenantId, projectId: agent.projectId }
3642
+ });
3643
+ if (project?.models?.base?.model) {
3644
+ return {
3645
+ base: project.models.base,
3646
+ structuredOutput: agent.models?.structuredOutput || project.models.structuredOutput || project.models.base,
3647
+ summarizer: agent.models?.summarizer || project.models.summarizer || project.models.base
3648
+ };
3649
+ }
3650
+ throw new Error(
3651
+ "Base model configuration is required. Please configure models at the project level."
3652
+ );
3653
+ }
3383
3654
 
3384
3655
  // src/services/IncrementalStreamParser.ts
3385
- var logger9 = getLogger("IncrementalStreamParser");
3656
+ var logger10 = getLogger("IncrementalStreamParser");
3386
3657
  var _IncrementalStreamParser = class _IncrementalStreamParser {
3387
3658
  // Max number of collected parts to prevent unbounded growth
3388
3659
  constructor(streamHelper, tenantId, contextId, artifactParserOptions) {
@@ -3411,9 +3682,20 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3411
3682
  return;
3412
3683
  }
3413
3684
  }
3685
+ let sharedArtifactService = null;
3686
+ if (artifactParserOptions?.streamRequestId && typeof graphSessionManager.getArtifactService === "function") {
3687
+ try {
3688
+ sharedArtifactService = graphSessionManager.getArtifactService(
3689
+ artifactParserOptions.streamRequestId
3690
+ );
3691
+ } catch (error) {
3692
+ }
3693
+ }
3414
3694
  this.artifactParser = new ArtifactParser(tenantId, {
3415
3695
  ...artifactParserOptions,
3416
- contextId
3696
+ contextId,
3697
+ artifactService: sharedArtifactService
3698
+ // Use shared ArtifactService if available
3417
3699
  });
3418
3700
  }
3419
3701
  /**
@@ -3423,7 +3705,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3423
3705
  async initializeArtifactMap() {
3424
3706
  try {
3425
3707
  this.artifactMap = await this.artifactParser.getContextArtifacts(this.contextId);
3426
- logger9.debug(
3708
+ logger10.debug(
3427
3709
  {
3428
3710
  contextId: this.contextId,
3429
3711
  artifactMapSize: this.artifactMap.size
@@ -3431,7 +3713,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3431
3713
  "Initialized artifact map for streaming"
3432
3714
  );
3433
3715
  } catch (error) {
3434
- logger9.warn({ error, contextId: this.contextId }, "Failed to initialize artifact map");
3716
+ logger10.warn({ error, contextId: this.contextId }, "Failed to initialize artifact map");
3435
3717
  this.artifactMap = /* @__PURE__ */ new Map();
3436
3718
  }
3437
3719
  }
@@ -3528,9 +3810,13 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3528
3810
  * Note: Text components are handled separately with incremental streaming
3529
3811
  */
3530
3812
  async streamComponent(component) {
3531
- const parts = await this.artifactParser.parseObject({
3532
- dataComponents: [component]
3533
- }, this.artifactMap, this.agentId);
3813
+ const parts = await this.artifactParser.parseObject(
3814
+ {
3815
+ dataComponents: [component]
3816
+ },
3817
+ this.artifactMap,
3818
+ this.agentId
3819
+ );
3534
3820
  if (!Array.isArray(parts)) {
3535
3821
  console.warn("parseObject returned non-array:", parts);
3536
3822
  return;
@@ -3600,9 +3886,13 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3600
3886
  const componentKey = component.id;
3601
3887
  const hasBeenStreamed = this.lastStreamedComponents.has(componentKey);
3602
3888
  if (!hasBeenStreamed && this.isComponentComplete(component) && component.name !== "Text") {
3603
- const parts = await this.artifactParser.parseObject({
3604
- dataComponents: [component]
3605
- }, this.artifactMap, this.agentId);
3889
+ const parts = await this.artifactParser.parseObject(
3890
+ {
3891
+ dataComponents: [component]
3892
+ },
3893
+ this.artifactMap,
3894
+ this.agentId
3895
+ );
3606
3896
  for (const part of parts) {
3607
3897
  await this.streamPart(part);
3608
3898
  }
@@ -3667,7 +3957,11 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3667
3957
  remainingBuffer: workingBuffer
3668
3958
  };
3669
3959
  }
3670
- const parts = await this.artifactParser.parseText(workingBuffer, this.artifactMap, this.agentId);
3960
+ const parts = await this.artifactParser.parseText(
3961
+ workingBuffer,
3962
+ this.artifactMap,
3963
+ this.agentId
3964
+ );
3671
3965
  if (parts.length > 0 && parts[parts.length - 1].kind === "text") {
3672
3966
  const lastPart = parts[parts.length - 1];
3673
3967
  const lastText = lastPart.text || "";
@@ -3739,20 +4033,35 @@ __publicField(_IncrementalStreamParser, "MAX_COLLECTED_PARTS", 1e4);
3739
4033
  var IncrementalStreamParser = _IncrementalStreamParser;
3740
4034
 
3741
4035
  // src/services/ResponseFormatter.ts
3742
- var logger10 = getLogger("ResponseFormatter");
4036
+ var logger11 = getLogger("ResponseFormatter");
3743
4037
  var ResponseFormatter = class {
3744
4038
  constructor(tenantId, artifactParserOptions) {
3745
4039
  __publicField(this, "artifactParser");
3746
4040
  __publicField(this, "agentId");
3747
4041
  this.agentId = artifactParserOptions?.agentId;
3748
4042
  if (artifactParserOptions?.streamRequestId) {
3749
- const sessionParser = graphSessionManager.getArtifactParser(artifactParserOptions.streamRequestId);
4043
+ const sessionParser = graphSessionManager.getArtifactParser(
4044
+ artifactParserOptions.streamRequestId
4045
+ );
3750
4046
  if (sessionParser) {
3751
4047
  this.artifactParser = sessionParser;
3752
4048
  return;
3753
4049
  }
3754
4050
  }
3755
- this.artifactParser = new ArtifactParser(tenantId, artifactParserOptions);
4051
+ let sharedArtifactService = null;
4052
+ if (artifactParserOptions?.streamRequestId && typeof graphSessionManager.getArtifactService === "function") {
4053
+ try {
4054
+ sharedArtifactService = graphSessionManager.getArtifactService(
4055
+ artifactParserOptions.streamRequestId
4056
+ );
4057
+ } catch (error) {
4058
+ }
4059
+ }
4060
+ this.artifactParser = new ArtifactParser(tenantId, {
4061
+ ...artifactParserOptions,
4062
+ artifactService: sharedArtifactService
4063
+ // Use shared ArtifactService if available
4064
+ });
3756
4065
  }
3757
4066
  /**
3758
4067
  * Process structured object response and replace artifact markers with actual artifacts
@@ -3765,7 +4074,11 @@ var ResponseFormatter = class {
3765
4074
  "response.type": "object",
3766
4075
  "response.availableArtifacts": artifactMap.size
3767
4076
  });
3768
- const parts = await this.artifactParser.parseObject(responseObject, artifactMap, this.agentId);
4077
+ const parts = await this.artifactParser.parseObject(
4078
+ responseObject,
4079
+ artifactMap,
4080
+ this.agentId
4081
+ );
3769
4082
  const uniqueArtifacts = this.countUniqueArtifacts(parts);
3770
4083
  span.setAttributes({
3771
4084
  "response.dataPartsCount": parts.length,
@@ -3779,7 +4092,7 @@ var ResponseFormatter = class {
3779
4092
  return { parts };
3780
4093
  } catch (error) {
3781
4094
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
3782
- logger10.error({ error, responseObject }, "Error formatting object response");
4095
+ logger11.error({ error, responseObject }, "Error formatting object response");
3783
4096
  return {
3784
4097
  parts: [{ kind: "data", data: responseObject }]
3785
4098
  };
@@ -3831,7 +4144,7 @@ var ResponseFormatter = class {
3831
4144
  return { parts };
3832
4145
  } catch (error) {
3833
4146
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
3834
- logger10.error({ error, responseText }, "Error formatting response");
4147
+ logger11.error({ error, responseText }, "Error formatting response");
3835
4148
  return { text: responseText };
3836
4149
  } finally {
3837
4150
  span.end();
@@ -3907,10 +4220,10 @@ function errorOp(message, agentId, severity = "error", code) {
3907
4220
  function generateToolId() {
3908
4221
  return `tool_${nanoid(8)}`;
3909
4222
  }
3910
- var logger11 = getLogger("DataComponentSchema");
4223
+ var logger12 = getLogger("DataComponentSchema");
3911
4224
  function jsonSchemaToZod(jsonSchema) {
3912
4225
  if (!jsonSchema || typeof jsonSchema !== "object") {
3913
- logger11.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
4226
+ logger12.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
3914
4227
  return z.string();
3915
4228
  }
3916
4229
  switch (jsonSchema.type) {
@@ -3937,7 +4250,7 @@ function jsonSchemaToZod(jsonSchema) {
3937
4250
  case "null":
3938
4251
  return z.null();
3939
4252
  default:
3940
- logger11.warn(
4253
+ logger12.warn(
3941
4254
  {
3942
4255
  unsupportedType: jsonSchema.type,
3943
4256
  schema: jsonSchema
@@ -4213,8 +4526,7 @@ var ArtifactCreateSchema = class {
4213
4526
  */
4214
4527
  static getSchemas(artifactComponents) {
4215
4528
  return artifactComponents.map((component) => {
4216
- const enhancedSummaryProps = SchemaProcessor.enhanceSchemaWithJMESPathGuidance(component.summaryProps);
4217
- const enhancedFullProps = SchemaProcessor.enhanceSchemaWithJMESPathGuidance(component.fullProps);
4529
+ const enhancedSchema = component.props ? SchemaProcessor.enhanceSchemaWithJMESPathGuidance(component.props) : { type: "object", properties: {} };
4218
4530
  const propsSchema = {
4219
4531
  type: "object",
4220
4532
  properties: {
@@ -4233,10 +4545,9 @@ var ArtifactCreateSchema = class {
4233
4545
  },
4234
4546
  base_selector: {
4235
4547
  type: "string",
4236
- description: `JMESPath selector starting with "result." to navigate to ONE specific item. Summary/full props will be relative to this selection. Use filtering to avoid arrays (e.g., "result.items[?type=='guide']"). EXAMPLE: For JSON {"result":{"structuredContent":{"content":[{"type":"document","title":"Guide"}]}}} - WRONG: "result.content[?type=='document']" (skips structuredContent) - RIGHT: "result.structuredContent.content[?type=='document']".`
4548
+ description: `JMESPath selector starting with "result." to navigate to ONE specific item. Details selector will be relative to this selection. Use filtering to avoid arrays (e.g., "result.items[?type=='guide']").`
4237
4549
  },
4238
- summary_props: enhancedSummaryProps,
4239
- full_props: enhancedFullProps
4550
+ details_selector: enhancedSchema
4240
4551
  },
4241
4552
  required: ["id", "tool_call_id", "type", "base_selector"]
4242
4553
  };
@@ -4254,8 +4565,7 @@ var ArtifactCreateSchema = class {
4254
4565
  */
4255
4566
  static getDataComponents(tenantId, projectId = "", artifactComponents) {
4256
4567
  return artifactComponents.map((component) => {
4257
- const enhancedSummaryProps = SchemaProcessor.enhanceSchemaWithJMESPathGuidance(component.summaryProps);
4258
- const enhancedFullProps = SchemaProcessor.enhanceSchemaWithJMESPathGuidance(component.fullProps);
4568
+ const enhancedSchema = component.props ? SchemaProcessor.enhanceSchemaWithJMESPathGuidance(component.props) : { type: "object", properties: {} };
4259
4569
  const propsSchema = {
4260
4570
  type: "object",
4261
4571
  properties: {
@@ -4274,10 +4584,9 @@ var ArtifactCreateSchema = class {
4274
4584
  },
4275
4585
  base_selector: {
4276
4586
  type: "string",
4277
- description: `JMESPath selector starting with "result." to navigate to ONE specific item. Summary/full props will be relative to this selection. Use filtering to avoid arrays (e.g., "result.items[?type=='guide']"). EXAMPLE: For JSON {"result":{"structuredContent":{"content":[{"type":"document","title":"Guide"}]}}} - WRONG: "result.content[?type=='document']" (skips structuredContent) - RIGHT: "result.structuredContent.content[?type=='document']".`
4587
+ description: `JMESPath selector starting with "result." to navigate to ONE specific item. Details selector will be relative to this selection. Use filtering to avoid arrays (e.g., "result.items[?type=='guide']").`
4278
4588
  },
4279
- summary_props: enhancedSummaryProps,
4280
- full_props: enhancedFullProps
4589
+ details_selector: enhancedSchema
4281
4590
  },
4282
4591
  required: ["id", "tool_call_id", "type", "base_selector"]
4283
4592
  };
@@ -4304,7 +4613,7 @@ function parseEmbeddedJson(data) {
4304
4613
  }
4305
4614
 
4306
4615
  // src/a2a/client.ts
4307
- var logger12 = getLogger("a2aClient");
4616
+ var logger13 = getLogger("a2aClient");
4308
4617
  var DEFAULT_BACKOFF = {
4309
4618
  initialInterval: 500,
4310
4619
  maxInterval: 6e4,
@@ -4510,7 +4819,7 @@ var A2AClient = class {
4510
4819
  try {
4511
4820
  const res = await fn();
4512
4821
  if (attempt > 0) {
4513
- logger12.info(
4822
+ logger13.info(
4514
4823
  {
4515
4824
  attempts: attempt + 1,
4516
4825
  elapsedTime: Date.now() - start
@@ -4525,7 +4834,7 @@ var A2AClient = class {
4525
4834
  }
4526
4835
  const elapsed = Date.now() - start;
4527
4836
  if (elapsed > maxElapsedTime) {
4528
- logger12.warn(
4837
+ logger13.warn(
4529
4838
  {
4530
4839
  attempts: attempt + 1,
4531
4840
  elapsedTime: elapsed,
@@ -4546,7 +4855,7 @@ var A2AClient = class {
4546
4855
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4547
4856
  }
4548
4857
  const delayMs = Math.min(retryInterval, maxInterval);
4549
- logger12.info(
4858
+ logger13.info(
4550
4859
  {
4551
4860
  attempt: attempt + 1,
4552
4861
  delayMs,
@@ -4631,7 +4940,7 @@ var A2AClient = class {
4631
4940
  }
4632
4941
  const rpcResponse = await httpResponse.json();
4633
4942
  if (rpcResponse.id !== requestId2) {
4634
- logger12.warn(
4943
+ logger13.warn(
4635
4944
  {
4636
4945
  method,
4637
4946
  expectedId: requestId2,
@@ -4830,7 +5139,7 @@ var A2AClient = class {
4830
5139
  try {
4831
5140
  while (true) {
4832
5141
  const { done, value } = await reader.read();
4833
- logger12.info({ done, value }, "parseA2ASseStream");
5142
+ logger13.info({ done, value }, "parseA2ASseStream");
4834
5143
  if (done) {
4835
5144
  if (eventDataBuffer.trim()) {
4836
5145
  const result = this._processSseEventData(
@@ -4917,7 +5226,7 @@ var A2AClient = class {
4917
5226
  };
4918
5227
 
4919
5228
  // src/agents/relationTools.ts
4920
- var logger13 = getLogger("relationships Tools");
5229
+ var logger14 = getLogger("relationships Tools");
4921
5230
  var generateTransferToolDescription = (config) => {
4922
5231
  return `Hand off the conversation to agent ${config.id}.
4923
5232
 
@@ -4946,7 +5255,7 @@ var createTransferToAgentTool = ({
4946
5255
  }) => {
4947
5256
  return tool({
4948
5257
  description: generateTransferToolDescription(transferConfig),
4949
- inputSchema: z4.object({}),
5258
+ inputSchema: z5.object({}),
4950
5259
  execute: async () => {
4951
5260
  const activeSpan = trace.getActiveSpan();
4952
5261
  if (activeSpan) {
@@ -4955,7 +5264,7 @@ var createTransferToAgentTool = ({
4955
5264
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4956
5265
  });
4957
5266
  }
4958
- logger13.info(
5267
+ logger14.info(
4959
5268
  {
4960
5269
  transferTo: transferConfig.id ?? "unknown",
4961
5270
  fromAgent: callingAgentId
@@ -4992,7 +5301,7 @@ function createDelegateToAgentTool({
4992
5301
  }) {
4993
5302
  return tool({
4994
5303
  description: generateDelegateToolDescription(delegateConfig.config),
4995
- inputSchema: z4.object({ message: z4.string() }),
5304
+ inputSchema: z5.object({ message: z5.string() }),
4996
5305
  execute: async (input, context) => {
4997
5306
  const delegationId = `del_${nanoid()}`;
4998
5307
  const activeSpan = trace.getActiveSpan();
@@ -5104,7 +5413,7 @@ function createDelegateToAgentTool({
5104
5413
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
5105
5414
  }
5106
5415
  };
5107
- logger13.info({ messageToSend }, "messageToSend");
5416
+ logger14.info({ messageToSend }, "messageToSend");
5108
5417
  await createMessage(dbClient_default)({
5109
5418
  id: nanoid(),
5110
5419
  tenantId,
@@ -5166,7 +5475,7 @@ function createDelegateToAgentTool({
5166
5475
  }
5167
5476
 
5168
5477
  // src/agents/SystemPromptBuilder.ts
5169
- var logger14 = getLogger("SystemPromptBuilder");
5478
+ var logger15 = getLogger("SystemPromptBuilder");
5170
5479
  var SystemPromptBuilder = class {
5171
5480
  constructor(version, versionConfig) {
5172
5481
  this.version = version;
@@ -5182,12 +5491,12 @@ var SystemPromptBuilder = class {
5182
5491
  this.templates.set(name, content);
5183
5492
  }
5184
5493
  this.loaded = true;
5185
- logger14.debug(
5494
+ logger15.debug(
5186
5495
  { templateCount: this.templates.size, version: this.version },
5187
5496
  `Loaded ${this.templates.size} templates for version ${this.version}`
5188
5497
  );
5189
5498
  } catch (error) {
5190
- logger14.error({ error }, `Failed to load templates for version ${this.version}`);
5499
+ logger15.error({ error }, `Failed to load templates for version ${this.version}`);
5191
5500
  throw new Error(`Template loading failed: ${error}`);
5192
5501
  }
5193
5502
  }
@@ -5212,68 +5521,6 @@ var SystemPromptBuilder = class {
5212
5521
  }
5213
5522
  };
5214
5523
 
5215
- // templates/v1/shared/artifact.xml?raw
5216
- var artifact_default = "<artifact>\n <name>{{ARTIFACT_NAME}}</name>\n <description>{{ARTIFACT_DESCRIPTION}}</description>\n <task_id>{{TASK_ID}}</task_id>\n <artifact_id>{{ARTIFACT_ID}}</artifact_id>\n <tool_call_id>{{TOOL_CALL_ID}}</tool_call_id>\n <summary_data>{{ARTIFACT_SUMMARY}}</summary_data>\n</artifact> ";
5217
-
5218
- // templates/v1/shared/artifact-retrieval-guidance.xml?raw
5219
- var artifact_retrieval_guidance_default = `ARTIFACT RETRIEVAL: ACCESSING EXISTING ARTIFACT DATA
5220
-
5221
- \u{1F6A8} **CRITICAL: ALWAYS CHECK EXISTING ARTIFACTS FIRST** \u{1F6A8}
5222
- Before creating new artifacts, ALWAYS examine existing artifacts to see if they contain relevant information for the current topic or question.
5223
-
5224
- You CAN and SHOULD retrieve information from existing artifacts to answer user questions.
5225
- Available artifacts contain structured data that you can access in two ways:
5226
-
5227
- 1. **SUMMARY DATA**: Read the summary_data directly from available artifacts for basic information
5228
- 2. **FULL DATA**: Use the get_artifact tool to retrieve complete artifact data (both summary_data and full_data) when you need detailed information
5229
-
5230
- **REUSE EXISTING ARTIFACTS WHEN POSSIBLE:**
5231
- - Look for artifacts with similar topics, names, or descriptions
5232
- - Check if existing artifacts can answer the current question
5233
- - Use existing artifact data instead of creating duplicates
5234
- - Only create new artifacts if existing ones don't contain the needed information
5235
- - Prioritize reusing relevant existing artifacts over creating new ones
5236
-
5237
- HOW TO USE ARTIFACT DATA:
5238
- - Read summary_data from available artifacts for quick answers
5239
- - Use get_artifact tool when you need comprehensive details
5240
- - Extract specific information to answer user questions accurately
5241
- - Reference artifacts when citing the information source
5242
- - Combine information from multiple existing artifacts when relevant
5243
-
5244
- \u{1F6A8} **MANDATORY CITATION POLICY** \u{1F6A8}
5245
- EVERY piece of information from existing artifacts MUST be properly cited:
5246
- - When referencing information from existing artifacts = MUST cite with artifact reference
5247
- - When discussing artifact data = MUST cite the artifact source
5248
- - When using artifact information = MUST reference the artifact
5249
- - NO INFORMATION from existing artifacts can be presented without proper citation
5250
-
5251
- CITATION PLACEMENT RULES:
5252
- - ALWAYS place artifact citations AFTER complete thoughts and punctuation
5253
- - Never interrupt a sentence or thought with an artifact citation
5254
- - Complete your sentence or thought, add punctuation, THEN add the citation
5255
- - This maintains natural reading flow and professional presentation
5256
-
5257
- \u2705 CORRECT EXAMPLES:
5258
- - "The API uses OAuth 2.0 authentication. <artifact:create id='auth-doc' ...> This process involves three main steps..."
5259
- - "Based on the documentation, there are several authentication methods available. <artifact:create id='auth-methods' ...> The recommended approach is OAuth 2.0."
5260
-
5261
- \u274C WRONG EXAMPLES:
5262
- - "The API uses <artifact:create id='auth-doc' ...> OAuth 2.0 authentication which involves..."
5263
- - "According to <artifact:create id='auth-doc' ...>, the authentication method is OAuth 2.0."
5264
-
5265
- \u{1F3AF} **KEY PRINCIPLE**: Information from tools \u2192 Complete thought \u2192 Punctuation \u2192 Citation \u2192 Continue
5266
-
5267
- DELEGATION AND ARTIFACTS:
5268
- When you use delegation tools, the response may include artifacts in the parts array. These appear as objects with:
5269
- - kind: "data"
5270
- - data: { artifactId, toolCallId, name, description, type, artifactSummary }
5271
-
5272
- These artifacts become immediately available for you to reference using the artifactId and toolCallId from the response.
5273
- Present delegation results naturally without mentioning the delegation process itself.
5274
-
5275
- IMPORTANT: All agents can retrieve and use information from existing artifacts when the graph has artifact components, regardless of whether the individual agent can create new artifacts.`;
5276
-
5277
5524
  // templates/v1/phase1/system-prompt.xml?raw
5278
5525
  var system_prompt_default = `<system_message>
5279
5526
  <agent_identity>
@@ -5390,6 +5637,68 @@ var thinking_preparation_default = `<thinking_preparation_mode>
5390
5637
  // templates/v1/phase1/tool.xml?raw
5391
5638
  var tool_default = "<tool>\n <name>{{TOOL_NAME}}</name>\n <description>{{TOOL_DESCRIPTION}}</description>\n <parameters>\n <schema>\n {{TOOL_PARAMETERS_SCHEMA}}\n </schema>\n </parameters>\n <usage_guidelines>\n {{TOOL_USAGE_GUIDELINES}}\n </usage_guidelines>\n</tool> ";
5392
5639
 
5640
+ // templates/v1/shared/artifact.xml?raw
5641
+ var artifact_default = "<artifact>\n <name>{{ARTIFACT_NAME}}</name>\n <description>{{ARTIFACT_DESCRIPTION}}</description>\n <task_id>{{TASK_ID}}</task_id>\n <artifact_id>{{ARTIFACT_ID}}</artifact_id>\n <tool_call_id>{{TOOL_CALL_ID}}</tool_call_id>\n <summary_data>{{ARTIFACT_SUMMARY}}</summary_data>\n <!-- NOTE: This shows summary/preview data only. Use get_reference_artifact tool to get complete artifact data if needed. -->\n</artifact> ";
5642
+
5643
+ // templates/v1/shared/artifact-retrieval-guidance.xml?raw
5644
+ var artifact_retrieval_guidance_default = `ARTIFACT RETRIEVAL: ACCESSING EXISTING ARTIFACT DATA
5645
+
5646
+ \u{1F6A8} **CRITICAL: ALWAYS CHECK EXISTING ARTIFACTS FIRST** \u{1F6A8}
5647
+ Before creating new artifacts, ALWAYS examine existing artifacts to see if they contain relevant information for the current topic or question.
5648
+
5649
+ You CAN and SHOULD retrieve information from existing artifacts to answer user questions.
5650
+ Available artifacts contain structured data that you can access in two ways:
5651
+
5652
+ 1. **SUMMARY DATA**: Read the summary_data directly from available artifacts for basic information
5653
+ 2. **FULL DATA**: Use the get_artifact tool to retrieve complete artifact data (both summary_data and full_data) when you need detailed information
5654
+
5655
+ **REUSE EXISTING ARTIFACTS WHEN POSSIBLE:**
5656
+ - Look for artifacts with similar topics, names, or descriptions
5657
+ - Check if existing artifacts can answer the current question
5658
+ - Use existing artifact data instead of creating duplicates
5659
+ - Only create new artifacts if existing ones don't contain the needed information
5660
+ - Prioritize reusing relevant existing artifacts over creating new ones
5661
+
5662
+ HOW TO USE ARTIFACT DATA:
5663
+ - Read summary_data from available artifacts for quick answers
5664
+ - Use get_artifact tool when you need comprehensive details
5665
+ - Extract specific information to answer user questions accurately
5666
+ - Reference artifacts when citing the information source
5667
+ - Combine information from multiple existing artifacts when relevant
5668
+
5669
+ \u{1F6A8} **MANDATORY CITATION POLICY** \u{1F6A8}
5670
+ EVERY piece of information from existing artifacts MUST be properly cited:
5671
+ - When referencing information from existing artifacts = MUST cite with artifact reference
5672
+ - When discussing artifact data = MUST cite the artifact source
5673
+ - When using artifact information = MUST reference the artifact
5674
+ - NO INFORMATION from existing artifacts can be presented without proper citation
5675
+
5676
+ CITATION PLACEMENT RULES:
5677
+ - ALWAYS place artifact citations AFTER complete thoughts and punctuation
5678
+ - Never interrupt a sentence or thought with an artifact citation
5679
+ - Complete your sentence or thought, add punctuation, THEN add the citation
5680
+ - This maintains natural reading flow and professional presentation
5681
+
5682
+ \u2705 CORRECT EXAMPLES:
5683
+ - "The API uses OAuth 2.0 authentication. <artifact:create id='auth-doc' ...> This process involves three main steps..."
5684
+ - "Based on the documentation, there are several authentication methods available. <artifact:create id='auth-methods' ...> The recommended approach is OAuth 2.0."
5685
+
5686
+ \u274C WRONG EXAMPLES:
5687
+ - "The API uses <artifact:create id='auth-doc' ...> OAuth 2.0 authentication which involves..."
5688
+ - "According to <artifact:create id='auth-doc' ...>, the authentication method is OAuth 2.0."
5689
+
5690
+ \u{1F3AF} **KEY PRINCIPLE**: Information from tools \u2192 Complete thought \u2192 Punctuation \u2192 Citation \u2192 Continue
5691
+
5692
+ DELEGATION AND ARTIFACTS:
5693
+ When you use delegation tools, the response may include artifacts in the parts array. These appear as objects with:
5694
+ - kind: "data"
5695
+ - data: { artifactId, toolCallId, name, description, type, artifactSummary }
5696
+
5697
+ These artifacts become immediately available for you to reference using the artifactId and toolCallId from the response.
5698
+ Present delegation results naturally without mentioning the delegation process itself.
5699
+
5700
+ IMPORTANT: All agents can retrieve and use information from existing artifacts when the graph has artifact components, regardless of whether the individual agent can create new artifacts.`;
5701
+
5393
5702
  // src/agents/versions/v1/Phase1Config.ts
5394
5703
  getLogger("Phase1Config");
5395
5704
  var Phase1Config = class _Phase1Config {
@@ -5525,8 +5834,8 @@ SELECTOR REQUIREMENTS:
5525
5834
 
5526
5835
  CRITICAL: SELECTOR HIERARCHY
5527
5836
  - base_selector: Points to ONE specific item in the tool result
5528
- - summary_props/full_props: Contain JMESPath selectors RELATIVE to the base selector
5529
- - Example: If base="result.documents[?type=='api']" then summary_props uses "title" not "documents[0].title"
5837
+ - details_selector: Contains JMESPath selectors RELATIVE to the base selector
5838
+ - Example: If base="result.documents[?type=='api']" then details_selector uses "title" not "documents[0].title"
5530
5839
 
5531
5840
  COMMON FAILURE POINTS (AVOID THESE):
5532
5841
  1. **Array Selection**: result.items (returns array) \u274C
@@ -5558,24 +5867,22 @@ You will create and reference artifacts using inline annotations in your text re
5558
5867
 
5559
5868
  CREATING ARTIFACTS (SERVES AS CITATION):
5560
5869
  Use the artifact:create annotation to extract data from tool results. The creation itself serves as a citation.
5561
- Format: <artifact:create id="unique-id" tool="tool_call_id" type="TypeName" base="selector.path" summary='{"key":"jmespath_selector"}' full='{"key":"jmespath_selector"}' />
5870
+ Format: <artifact:create id="unique-id" tool="tool_call_id" type="TypeName" base="selector.path" details='{"key":"jmespath_selector"}' />
5562
5871
 
5563
- \u{1F6A8} CRITICAL: SUMMARY AND FULL PROPS USE JMESPATH SELECTORS, NOT LITERAL VALUES! \u{1F6A8}
5872
+ \u{1F6A8} CRITICAL: DETAILS PROPS USE JMESPATH SELECTORS, NOT LITERAL VALUES! \u{1F6A8}
5564
5873
 
5565
5874
  \u274C WRONG - Using literal values:
5566
- summary='{"title":"API Documentation","type":"guide"}'
5567
- full='{"description":"This is a comprehensive guide..."}'
5875
+ details='{"title":"API Documentation","type":"guide"}'
5568
5876
 
5569
5877
  \u2705 CORRECT - Using JMESPath selectors (relative to base selector):
5570
- summary='{"title":"metadata.title","doc_type":"document_type"}'
5571
- full='{"description":"content.description","main_text":"content.text","author":"metadata.author"}'
5878
+ details='{"title":"metadata.title","doc_type":"document_type","description":"content.description","main_text":"content.text","author":"metadata.author"}'
5572
5879
 
5573
5880
  The selectors extract actual field values from the data structure selected by your base selector.
5574
5881
 
5575
- THE summary AND full PROPERTIES MUST CONTAIN JMESPATH SELECTORS THAT EXTRACT DATA FROM THE TOOL RESULT!
5576
- - summary: Contains JMESPath selectors relative to the base selector
5577
- - full: Contains JMESPath selectors relative to the base selector
5882
+ THE details PROPERTY MUST CONTAIN JMESPATH SELECTORS THAT EXTRACT DATA FROM THE TOOL RESULT!
5883
+ - details: Contains JMESPath selectors relative to the base selector that map to artifact schema fields
5578
5884
  - These selectors are evaluated against the tool result to extract the actual values
5885
+ - The system automatically determines which fields are preview vs full based on the artifact schema
5579
5886
  - NEVER put literal values like "Inkeep" or "2023" - always use selectors like "metadata.company" or "founded_year"
5580
5887
 
5581
5888
  \u{1F6AB} FORBIDDEN JMESPATH PATTERNS:
@@ -5635,7 +5942,7 @@ Only use artifact:ref when you need to cite the SAME artifact again for a differ
5635
5942
  Format: <artifact:ref id="artifact-id" tool="tool_call_id" />
5636
5943
 
5637
5944
  EXAMPLE TEXT RESPONSE:
5638
- "I found the authentication documentation. <artifact:create id='auth-doc-1' tool='call_xyz789' type='APIDoc' base='result.documents[?type=="auth"]' summary='{"title":"metadata.title","endpoint":"api.endpoint"}' full='{"description":"content.description","parameters":"spec.parameters","examples":"examples.sample_code"}' /> The documentation explains OAuth 2.0 implementation in detail.
5945
+ "I found the authentication documentation. <artifact:create id='auth-doc-1' tool='call_xyz789' type='APIDoc' base='result.documents[?type=="auth"]' details='{"title":"metadata.title","endpoint":"api.endpoint","description":"content.description","parameters":"spec.parameters","examples":"examples.sample_code"}' /> The documentation explains OAuth 2.0 implementation in detail.
5639
5946
 
5640
5947
  The process involves three main steps: registration, token exchange, and API calls. As mentioned in the authentication documentation <artifact:ref id='auth-doc-1' tool='call_xyz789' />, you'll need to register your application first."
5641
5948
 
@@ -5691,31 +5998,29 @@ IMPORTANT GUIDELINES:
5691
5998
  return "";
5692
5999
  }
5693
6000
  const typeDescriptions = artifactComponents.map((ac) => {
5694
- let summarySchema = "No schema defined";
5695
- let fullSchema = "No schema defined";
5696
- if (ac.summaryProps?.properties) {
5697
- const summaryDetails = Object.entries(ac.summaryProps.properties).map(([key, value]) => `${key} (${value.description || value.type || "field"})`).join(", ");
5698
- summarySchema = `Required: ${summaryDetails}`;
5699
- }
5700
- if (ac.fullProps?.properties) {
5701
- const fullDetails = Object.entries(ac.fullProps.properties).map(([key, value]) => `${key} (${value.description || value.type || "field"})`).join(", ");
5702
- fullSchema = `Available: ${fullDetails}`;
6001
+ let schemaDescription = "No schema defined";
6002
+ if (ac.props?.properties) {
6003
+ const fieldDetails = Object.entries(ac.props.properties).map(([key, value]) => {
6004
+ const inPreview = value.inPreview ? " [PREVIEW]" : " [FULL]";
6005
+ return `${key} (${value.description || value.type || "field"})${inPreview}`;
6006
+ }).join(", ");
6007
+ schemaDescription = `Fields: ${fieldDetails}`;
5703
6008
  }
5704
6009
  return ` - "${ac.name}": ${ac.description || "No description available"}
5705
- Summary Props: ${summarySchema}
5706
- Full Props: ${fullSchema}`;
6010
+ ${schemaDescription}`;
5707
6011
  }).join("\n\n");
5708
6012
  return `
5709
6013
  AVAILABLE ARTIFACT TYPES:
5710
6014
 
5711
6015
  ${typeDescriptions}
5712
6016
 
5713
- \u{1F6A8} CRITICAL: SUMMARY AND FULL PROPS MUST MATCH THE ARTIFACT SCHEMA! \u{1F6A8}
6017
+ \u{1F6A8} CRITICAL: DETAILS PROPS MUST MATCH THE ARTIFACT SCHEMA! \u{1F6A8}
5714
6018
  - Only use property names that are defined in the artifact component schema above
5715
6019
  - Do NOT make up arbitrary property names like "founders", "nick_details", "year"
5716
- - Each artifact type has specific required fields in summaryProps and available fields in fullProps
6020
+ - Each artifact type has specific fields defined in its schema
5717
6021
  - Your JMESPath selectors must extract values for these exact schema-defined properties
5718
- - Example: If schema defines "title" and "url", use summary='{"title":"title","url":"url"}' not made-up names
6022
+ - Example: If schema defines "title" and "url", use details='{"title":"title","url":"url"}' not made-up names
6023
+ - The system will automatically determine which fields are preview vs full based on schema configuration
5719
6024
 
5720
6025
  \u{1F6A8} CRITICAL: USE EXACT ARTIFACT TYPE NAMES IN QUOTES! \u{1F6A8}
5721
6026
  - MUST use the exact type name shown in quotes above
@@ -5726,7 +6031,11 @@ ${typeDescriptions}
5726
6031
  }
5727
6032
  generateArtifactsSection(templates, artifacts, hasArtifactComponents = false, artifactComponents, hasGraphArtifactComponents) {
5728
6033
  const shouldShowReferencingRules = hasGraphArtifactComponents || artifacts.length > 0;
5729
- const rules = this.getArtifactReferencingRules(hasArtifactComponents, templates, shouldShowReferencingRules);
6034
+ const rules = this.getArtifactReferencingRules(
6035
+ hasArtifactComponents,
6036
+ templates,
6037
+ shouldShowReferencingRules
6038
+ );
5730
6039
  const creationInstructions = this.getArtifactCreationInstructions(
5731
6040
  hasArtifactComponents,
5732
6041
  artifactComponents
@@ -5821,6 +6130,12 @@ ${propertiesXml}
5821
6130
  }
5822
6131
  };
5823
6132
 
6133
+ // templates/v1/phase2/data-component.xml?raw
6134
+ var data_component_default = "<data-component>\n <name>{{COMPONENT_NAME}}</name>\n <description>{{COMPONENT_DESCRIPTION}}</description>\n <props>\n <schema>\n {{COMPONENT_PROPS_SCHEMA}}\n </schema>\n </props>\n</data-component> ";
6135
+
6136
+ // templates/v1/phase2/data-components.xml?raw
6137
+ var data_components_default = '<data_components_section description="These are the data components available for you to use in generating responses. Each component represents a single structured piece of information. You can create multiple instances of the same component type when needed.\n\n***MANDATORY JSON RESPONSE FORMAT - ABSOLUTELY CRITICAL***:\n- WHEN DATA COMPONENTS ARE AVAILABLE, YOU MUST RESPOND IN JSON FORMAT ONLY\n- DO NOT respond with plain text when data components are defined\n- YOUR RESPONSE MUST BE STRUCTURED JSON WITH dataComponents ARRAY\n- THIS IS NON-NEGOTIABLE - JSON FORMAT IS REQUIRED\n\nCRITICAL JSON FORMATTING RULES - MUST FOLLOW EXACTLY:\n1. Each data component must include id, name, and props fields\n2. The id and name should match the exact component definition\n3. The props field contains the actual component data using exact property names from the schema\n4. NEVER omit the id and name fields\n\nCORRECT: [{\\"id\\": \\"component1\\", \\"name\\": \\"Component1\\", \\"props\\": {\\"field1\\": \\"value1\\", \\"field2\\": \\"value2\\"}}, {\\"id\\": \\"component2\\", \\"name\\": \\"Component2\\", \\"props\\": {\\"field3\\": \\"value3\\"}}]\nWRONG: [{\\"field1\\": \\"value1\\", \\"field2\\": \\"value2\\"}, {\\"field3\\": \\"value3\\"}]\n\nAVAILABLE DATA COMPONENTS: {{DATA_COMPONENTS_LIST}}">\n\n{{DATA_COMPONENTS_XML}}\n\n</data_components_section>';
6138
+
5824
6139
  // templates/v1/phase2/system-prompt.xml?raw
5825
6140
  var system_prompt_default2 = `<phase2_system_message>
5826
6141
  <instruction>
@@ -5860,12 +6175,6 @@ var system_prompt_default2 = `<phase2_system_message>
5860
6175
  </requirements>
5861
6176
  </phase2_system_message>`;
5862
6177
 
5863
- // templates/v1/phase2/data-components.xml?raw
5864
- var data_components_default = '<data_components_section description="These are the data components available for you to use in generating responses. Each component represents a single structured piece of information. You can create multiple instances of the same component type when needed.\n\n***MANDATORY JSON RESPONSE FORMAT - ABSOLUTELY CRITICAL***:\n- WHEN DATA COMPONENTS ARE AVAILABLE, YOU MUST RESPOND IN JSON FORMAT ONLY\n- DO NOT respond with plain text when data components are defined\n- YOUR RESPONSE MUST BE STRUCTURED JSON WITH dataComponents ARRAY\n- THIS IS NON-NEGOTIABLE - JSON FORMAT IS REQUIRED\n\nCRITICAL JSON FORMATTING RULES - MUST FOLLOW EXACTLY:\n1. Each data component must include id, name, and props fields\n2. The id and name should match the exact component definition\n3. The props field contains the actual component data using exact property names from the schema\n4. NEVER omit the id and name fields\n\nCORRECT: [{\\"id\\": \\"component1\\", \\"name\\": \\"Component1\\", \\"props\\": {\\"field1\\": \\"value1\\", \\"field2\\": \\"value2\\"}}, {\\"id\\": \\"component2\\", \\"name\\": \\"Component2\\", \\"props\\": {\\"field3\\": \\"value3\\"}}]\nWRONG: [{\\"field1\\": \\"value1\\", \\"field2\\": \\"value2\\"}, {\\"field3\\": \\"value3\\"}]\n\nAVAILABLE DATA COMPONENTS: {{DATA_COMPONENTS_LIST}}">\n\n{{DATA_COMPONENTS_XML}}\n\n</data_components_section>';
5865
-
5866
- // templates/v1/phase2/data-component.xml?raw
5867
- var data_component_default = "<data-component>\n <name>{{COMPONENT_NAME}}</name>\n <description>{{COMPONENT_DESCRIPTION}}</description>\n <props>\n <schema>\n {{COMPONENT_PROPS_SCHEMA}}\n </schema>\n </props>\n</data-component> ";
5868
-
5869
6178
  // src/agents/versions/v1/Phase2Config.ts
5870
6179
  var Phase2Config = class {
5871
6180
  getArtifactCreationGuidance() {
@@ -5911,17 +6220,15 @@ When the same field names appear at different levels (like 'content', 'title', '
5911
6220
 
5912
6221
  CRITICAL: SELECTOR HIERARCHY
5913
6222
  - base_selector: Points to ONE specific item in the tool result
5914
- - summary_props/full_props: Contain JMESPath selectors RELATIVE to the base selector
5915
- - Example: If base="result.documents[?type=='api']" then summary_props uses "title" not "documents[0].title"
6223
+ - details_selector: Contains JMESPath selectors RELATIVE to the base selector
6224
+ - Example: If base="result.documents[?type=='api']" then details_selector uses "title" not "documents[0].title"
5916
6225
 
5917
6226
  \u274C WRONG EXAMPLE:
5918
6227
  {
5919
6228
  "base_selector": "result.content[?title=='Guide']",
5920
- "summary_props": {
6229
+ "details_selector": {
5921
6230
  "title": "Guide", // \u274C This is a literal value, not a selector!
5922
- "url": "result.content[?title=='Guide'].url" // \u274C This is absolute, not relative!
5923
- },
5924
- "full_props": {
6231
+ "url": "result.content[?title=='Guide'].url", // \u274C This is absolute, not relative!
5925
6232
  "description": "A comprehensive guide", // \u274C Literal value instead of selector!
5926
6233
  "content": "result.content[?title=='Guide'].content" // \u274C Absolute path instead of relative!
5927
6234
  }
@@ -5930,11 +6237,9 @@ CRITICAL: SELECTOR HIERARCHY
5930
6237
  \u2705 CORRECT EXAMPLE:
5931
6238
  {
5932
6239
  "base_selector": "result.content[?title=='Guide']",
5933
- "summary_props": {
6240
+ "details_selector": {
5934
6241
  "title": "title", // \u2705 Relative selector to get title field
5935
- "url": "url" // \u2705 Relative selector to get url field
5936
- },
5937
- "full_props": {
6242
+ "url": "url", // \u2705 Relative selector to get url field
5938
6243
  "description": "description", // \u2705 Relative selector
5939
6244
  "content": "content", // \u2705 Relative selector
5940
6245
  "metadata": "metadata.details" // \u2705 Relative selector with nesting
@@ -6020,8 +6325,7 @@ EXAMPLE STRUCTURED RESPONSE:
6020
6325
  "tool_call_id": "call_abc123",
6021
6326
  "type": "APIDoc",
6022
6327
  "base_selector": "result.documents[?type=='api']",
6023
- "summary_props": {"title": "metadata.title", "endpoint": "api.endpoint"},
6024
- "full_props": {"description": "content.description", "parameters": "spec.parameters", "examples": "examples.sample_code"}
6328
+ "details_selector": {"title": "metadata.title", "endpoint": "api.endpoint", "description": "content.description", "parameters": "spec.parameters", "examples": "examples.sample_code"}
6025
6329
  }
6026
6330
  },
6027
6331
  {
@@ -6101,14 +6405,14 @@ IMPORTANT GUIDELINES:
6101
6405
  return "";
6102
6406
  }
6103
6407
  const componentDescriptions = artifactComponents.map((ac) => {
6104
- const summaryProps = ac.summaryProps?.properties ? Object.entries(ac.summaryProps.properties).map(([key, value]) => ` - ${key}: ${value.description || "Field from tool result"}`).join("\n") : " No properties defined";
6105
- const fullProps = ac.fullProps?.properties ? Object.entries(ac.fullProps.properties).map(([key, value]) => ` - ${key}: ${value.description || "Field from tool result"}`).join("\n") : " No properties defined";
6408
+ const schemaProps = ac.props?.properties ? Object.entries(ac.props.properties).map(([key, value]) => {
6409
+ const inPreview = value.inPreview ? " [PREVIEW]" : " [FULL]";
6410
+ return ` - ${key}: ${value.description || "Field from tool result"}${inPreview}`;
6411
+ }).join("\n") : " No properties defined";
6106
6412
  return ` ArtifactCreate_${ac.name}:
6107
6413
  Description: ${ac.description || "Extract and structure data"}
6108
- Summary Properties:
6109
- ${summaryProps}
6110
- Full Properties:
6111
- ${fullProps}`;
6414
+ Schema Properties:
6415
+ ${schemaProps}`;
6112
6416
  }).join("\n\n");
6113
6417
  return `
6114
6418
  AVAILABLE ARTIFACT TYPES:
@@ -6122,8 +6426,14 @@ ${componentDescriptions}`;
6122
6426
  const dataComponentsDescription = dataComponents.map((dc) => `${dc.name}: ${dc.description}`).join(", ");
6123
6427
  const dataComponentsXml = dataComponents.map((dataComponent) => this.generateDataComponentXml(dataComponent)).join("\n ");
6124
6428
  let dataComponentsSection = data_components_default;
6125
- dataComponentsSection = dataComponentsSection.replace("{{DATA_COMPONENTS_LIST}}", dataComponentsDescription);
6126
- dataComponentsSection = dataComponentsSection.replace("{{DATA_COMPONENTS_XML}}", dataComponentsXml);
6429
+ dataComponentsSection = dataComponentsSection.replace(
6430
+ "{{DATA_COMPONENTS_LIST}}",
6431
+ dataComponentsDescription
6432
+ );
6433
+ dataComponentsSection = dataComponentsSection.replace(
6434
+ "{{DATA_COMPONENTS_XML}}",
6435
+ dataComponentsXml
6436
+ );
6127
6437
  return dataComponentsSection;
6128
6438
  }
6129
6439
  generateDataComponentXml(dataComponent) {
@@ -6195,14 +6505,21 @@ ${artifact_retrieval_guidance_default}
6195
6505
  * Assemble the complete Phase 2 system prompt for structured output generation
6196
6506
  */
6197
6507
  assemblePhase2Prompt(config) {
6198
- const { corePrompt, dataComponents, artifactComponents, hasArtifactComponents, hasGraphArtifactComponents, artifacts = [] } = config;
6508
+ const {
6509
+ corePrompt,
6510
+ dataComponents,
6511
+ artifactComponents,
6512
+ hasArtifactComponents,
6513
+ hasGraphArtifactComponents,
6514
+ artifacts = []
6515
+ } = config;
6199
6516
  let allDataComponents = [...dataComponents];
6200
6517
  if (hasArtifactComponents && artifactComponents) {
6201
6518
  const artifactCreateComponents = ArtifactCreateSchema.getDataComponents(
6202
6519
  "tenant",
6203
6520
  // placeholder - not used in Phase2
6204
6521
  "",
6205
- // placeholder - not used in Phase2
6522
+ // placeholder - not used in Phase2
6206
6523
  artifactComponents
6207
6524
  );
6208
6525
  allDataComponents = [...dataComponents, ...artifactCreateComponents];
@@ -6210,8 +6527,15 @@ ${artifact_retrieval_guidance_default}
6210
6527
  const dataComponentsSection = this.generateDataComponentsSection(allDataComponents);
6211
6528
  const artifactsSection = this.generateArtifactsSection(artifacts);
6212
6529
  const shouldShowReferencingRules = hasGraphArtifactComponents || artifacts.length > 0;
6213
- const artifactGuidance = this.getStructuredArtifactGuidance(hasArtifactComponents, artifactComponents, shouldShowReferencingRules);
6214
- const artifactTypes = this.getArtifactCreationInstructions(hasArtifactComponents, artifactComponents);
6530
+ const artifactGuidance = this.getStructuredArtifactGuidance(
6531
+ hasArtifactComponents,
6532
+ artifactComponents,
6533
+ shouldShowReferencingRules
6534
+ );
6535
+ const artifactTypes = this.getArtifactCreationInstructions(
6536
+ hasArtifactComponents,
6537
+ artifactComponents
6538
+ );
6215
6539
  let phase2Prompt = system_prompt_default2;
6216
6540
  phase2Prompt = phase2Prompt.replace("{{CORE_INSTRUCTIONS}}", corePrompt);
6217
6541
  phase2Prompt = phase2Prompt.replace("{{DATA_COMPONENTS_SECTION}}", dataComponentsSection);
@@ -6232,7 +6556,7 @@ function hasToolCallWithPrefix(prefix) {
6232
6556
  return false;
6233
6557
  };
6234
6558
  }
6235
- var logger16 = getLogger("Agent");
6559
+ var logger17 = getLogger("Agent");
6236
6560
  var CONSTANTS = {
6237
6561
  MAX_GENERATION_STEPS: 12,
6238
6562
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -6533,14 +6857,14 @@ var Agent = class {
6533
6857
  for (const toolSet of tools) {
6534
6858
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
6535
6859
  if (!isValidTool(originalTool)) {
6536
- logger16.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6860
+ logger17.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6537
6861
  continue;
6538
6862
  }
6539
6863
  const sessionWrappedTool = tool({
6540
6864
  description: originalTool.description,
6541
6865
  inputSchema: originalTool.inputSchema,
6542
6866
  execute: async (args, { toolCallId }) => {
6543
- logger16.debug({ toolName, toolCallId }, "MCP Tool Called");
6867
+ logger17.debug({ toolName, toolCallId }, "MCP Tool Called");
6544
6868
  try {
6545
6869
  const rawResult = await originalTool.execute(args, { toolCallId });
6546
6870
  const parsedResult = parseEmbeddedJson(rawResult);
@@ -6554,7 +6878,7 @@ var Agent = class {
6554
6878
  });
6555
6879
  return { result: enhancedResult, toolCallId };
6556
6880
  } catch (error) {
6557
- logger16.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6881
+ logger17.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6558
6882
  throw error;
6559
6883
  }
6560
6884
  }
@@ -6649,7 +6973,7 @@ var Agent = class {
6649
6973
  headers: agentToolRelationHeaders
6650
6974
  };
6651
6975
  }
6652
- logger16.info(
6976
+ logger17.info(
6653
6977
  {
6654
6978
  toolName: tool3.name,
6655
6979
  credentialReferenceId,
@@ -6674,7 +6998,7 @@ var Agent = class {
6674
6998
  this.mcpClientCache.set(cacheKey, client);
6675
6999
  } catch (error) {
6676
7000
  this.mcpConnectionLocks.delete(cacheKey);
6677
- logger16.error(
7001
+ logger17.error(
6678
7002
  {
6679
7003
  toolName: tool3.name,
6680
7004
  agentId: this.config.id,
@@ -6698,7 +7022,7 @@ var Agent = class {
6698
7022
  await client.connect();
6699
7023
  return client;
6700
7024
  } catch (error) {
6701
- logger16.error(
7025
+ logger17.error(
6702
7026
  {
6703
7027
  toolName: tool3.name,
6704
7028
  agentId: this.config.id,
@@ -6733,7 +7057,7 @@ var Agent = class {
6733
7057
  async getResolvedContext(conversationId, requestContext) {
6734
7058
  try {
6735
7059
  if (!this.config.contextConfigId) {
6736
- logger16.debug({ graphId: this.config.graphId }, "No context config found for graph");
7060
+ logger17.debug({ graphId: this.config.graphId }, "No context config found for graph");
6737
7061
  return null;
6738
7062
  }
6739
7063
  const contextConfig = await getContextConfigById(dbClient_default)({
@@ -6745,7 +7069,7 @@ var Agent = class {
6745
7069
  id: this.config.contextConfigId
6746
7070
  });
6747
7071
  if (!contextConfig) {
6748
- logger16.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7072
+ logger17.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
6749
7073
  return null;
6750
7074
  }
6751
7075
  if (!this.contextResolver) {
@@ -6762,7 +7086,7 @@ var Agent = class {
6762
7086
  $now: (/* @__PURE__ */ new Date()).toISOString(),
6763
7087
  $env: process.env
6764
7088
  };
6765
- logger16.debug(
7089
+ logger17.debug(
6766
7090
  {
6767
7091
  conversationId,
6768
7092
  contextConfigId: contextConfig.id,
@@ -6776,7 +7100,7 @@ var Agent = class {
6776
7100
  );
6777
7101
  return contextWithBuiltins;
6778
7102
  } catch (error) {
6779
- logger16.error(
7103
+ logger17.error(
6780
7104
  {
6781
7105
  conversationId,
6782
7106
  error: error instanceof Error ? error.message : "Unknown error"
@@ -6800,7 +7124,7 @@ var Agent = class {
6800
7124
  });
6801
7125
  return graphDefinition?.graphPrompt || void 0;
6802
7126
  } catch (error) {
6803
- logger16.warn(
7127
+ logger17.warn(
6804
7128
  {
6805
7129
  graphId: this.config.graphId,
6806
7130
  error: error instanceof Error ? error.message : "Unknown error"
@@ -6829,7 +7153,7 @@ var Agent = class {
6829
7153
  (agent) => "artifactComponents" in agent && agent.artifactComponents && agent.artifactComponents.length > 0
6830
7154
  );
6831
7155
  } catch (error) {
6832
- logger16.warn(
7156
+ logger17.warn(
6833
7157
  {
6834
7158
  graphId: this.config.graphId,
6835
7159
  tenantId: this.config.tenantId,
@@ -6858,7 +7182,7 @@ var Agent = class {
6858
7182
  preserveUnresolved: false
6859
7183
  });
6860
7184
  } catch (error) {
6861
- logger16.error(
7185
+ logger17.error(
6862
7186
  {
6863
7187
  conversationId,
6864
7188
  error: error instanceof Error ? error.message : "Unknown error"
@@ -6905,7 +7229,7 @@ var Agent = class {
6905
7229
  preserveUnresolved: false
6906
7230
  });
6907
7231
  } catch (error) {
6908
- logger16.error(
7232
+ logger17.error(
6909
7233
  {
6910
7234
  conversationId,
6911
7235
  error: error instanceof Error ? error.message : "Unknown error"
@@ -6944,7 +7268,7 @@ var Agent = class {
6944
7268
  preserveUnresolved: false
6945
7269
  });
6946
7270
  } catch (error) {
6947
- logger16.error(
7271
+ logger17.error(
6948
7272
  {
6949
7273
  conversationId,
6950
7274
  error: error instanceof Error ? error.message : "Unknown error"
@@ -6971,23 +7295,29 @@ var Agent = class {
6971
7295
  }
6972
7296
  getArtifactTools() {
6973
7297
  return tool({
6974
- description: "Call this tool to get the artifact with the given artifactId. Only retrieve this when the description of the artifact is insufficient to understand the artifact and you need to see the actual artifact for more context. Please refrain from using this tool unless absolutely necessary.",
7298
+ description: "Call this tool to get the complete artifact data with the given artifactId. This retrieves the full artifact content (not just the summary). Only use this when you need the complete artifact data and the summary shown in your context is insufficient.",
6975
7299
  inputSchema: z.object({
6976
- artifactId: z.string().describe("The unique identifier of the artifact to get.")
7300
+ artifactId: z.string().describe("The unique identifier of the artifact to get."),
7301
+ toolCallId: z.string().describe("The tool call ID associated with this artifact.")
6977
7302
  }),
6978
- execute: async ({ artifactId }) => {
6979
- logger16.info({ artifactId }, "get_artifact executed");
6980
- const artifact = await getLedgerArtifacts(dbClient_default)({
6981
- scopes: {
6982
- tenantId: this.config.tenantId,
6983
- projectId: this.config.projectId
6984
- },
6985
- artifactId
6986
- });
6987
- if (!artifact) {
6988
- throw new Error(`Artifact ${artifactId} not found`);
7303
+ execute: async ({ artifactId, toolCallId }) => {
7304
+ logger17.info({ artifactId, toolCallId }, "get_artifact_full executed");
7305
+ const streamRequestId = this.getStreamRequestId();
7306
+ const artifactService = graphSessionManager.getArtifactService(streamRequestId);
7307
+ if (!artifactService) {
7308
+ throw new Error(`ArtifactService not found for session ${streamRequestId}`);
6989
7309
  }
6990
- return { artifact: artifact[0] };
7310
+ const artifactData = await artifactService.getArtifactFull(artifactId, toolCallId);
7311
+ if (!artifactData) {
7312
+ throw new Error(`Artifact ${artifactId} with toolCallId ${toolCallId} not found`);
7313
+ }
7314
+ return {
7315
+ artifactId: artifactData.artifactId,
7316
+ name: artifactData.name,
7317
+ description: artifactData.description,
7318
+ type: artifactData.type,
7319
+ data: artifactData.data
7320
+ };
6991
7321
  }
6992
7322
  });
6993
7323
  }
@@ -7198,8 +7528,7 @@ var Agent = class {
7198
7528
  artifactGuidance: {
7199
7529
  creationFirst: "\u{1F6A8} CRITICAL: Artifacts must be CREATED before they can be referenced. Use ArtifactCreate_[Type] components FIRST, then reference with Artifact components only if citing the SAME artifact again.",
7200
7530
  baseSelector: `\u{1F3AF} CRITICAL: Use base_selector to navigate to ONE specific item. For deeply nested structures with repeated keys, use full paths with specific filtering (e.g., "result.data.content.items[?type=='guide' && status=='active']")`,
7201
- summaryProps: '\u{1F4DD} Use relative selectors from that item (e.g., "title", "metadata.category", "properties.status")',
7202
- fullProps: '\u{1F4D6} Use relative selectors for detailed data (e.g., "content.details", "specifications.data", "attributes")',
7531
+ detailsSelector: '\u{1F4DD} Use relative selectors for specific fields (e.g., "title", "metadata.category", "properties.status", "content.details")',
7203
7532
  avoidLiterals: "\u274C NEVER use literal values - always use field selectors to extract from data",
7204
7533
  avoidArrays: "\u2728 ALWAYS filter arrays to single items using [?condition] - NEVER use [*] notation which returns arrays",
7205
7534
  nestedKeys: "\u{1F511} For structures with repeated keys (like result.content.data.content.items.content), use full paths with filtering at each level",
@@ -7226,7 +7555,7 @@ var Agent = class {
7226
7555
  };
7227
7556
  return enhanced;
7228
7557
  } catch (error) {
7229
- logger16.warn({ error }, "Failed to enhance tool result with structure hints");
7558
+ logger17.warn({ error }, "Failed to enhance tool result with structure hints");
7230
7559
  return result;
7231
7560
  }
7232
7561
  }
@@ -7241,7 +7570,7 @@ var Agent = class {
7241
7570
  }
7242
7571
  });
7243
7572
  } catch (error) {
7244
- logger16.error(
7573
+ logger17.error(
7245
7574
  { error, graphId: this.config.graphId },
7246
7575
  "Failed to check graph artifact components"
7247
7576
  );
@@ -7342,7 +7671,7 @@ var Agent = class {
7342
7671
  const configuredTimeout = modelSettings.maxDuration ? Math.min(modelSettings.maxDuration * 1e3, MAX_ALLOWED_TIMEOUT_MS) : shouldStreamPhase1 ? CONSTANTS.PHASE_1_TIMEOUT_MS : CONSTANTS.NON_STREAMING_PHASE_1_TIMEOUT_MS;
7343
7672
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
7344
7673
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
7345
- logger16.warn(
7674
+ logger17.warn(
7346
7675
  {
7347
7676
  requestedTimeout: modelSettings.maxDuration * 1e3,
7348
7677
  appliedTimeout: timeoutMs,
@@ -7384,7 +7713,7 @@ var Agent = class {
7384
7713
  }
7385
7714
  );
7386
7715
  } catch (error) {
7387
- logger16.debug({ error }, "Failed to track agent reasoning");
7716
+ logger17.debug({ error }, "Failed to track agent reasoning");
7388
7717
  }
7389
7718
  }
7390
7719
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -7488,7 +7817,7 @@ var Agent = class {
7488
7817
  }
7489
7818
  );
7490
7819
  } catch (error) {
7491
- logger16.debug({ error }, "Failed to track agent reasoning");
7820
+ logger17.debug({ error }, "Failed to track agent reasoning");
7492
7821
  }
7493
7822
  }
7494
7823
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -7780,7 +8109,7 @@ ${output}${structureHintsFormatted}`;
7780
8109
  };
7781
8110
 
7782
8111
  // src/agents/generateTaskHandler.ts
7783
- var logger17 = getLogger("generateTaskHandler");
8112
+ var logger18 = getLogger("generateTaskHandler");
7784
8113
  var createTaskHandler = (config, credentialStoreRegistry) => {
7785
8114
  return async (task) => {
7786
8115
  try {
@@ -7833,7 +8162,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
7833
8162
  }
7834
8163
  })
7835
8164
  ]);
7836
- logger17.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
8165
+ logger18.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
7837
8166
  const enhancedInternalRelations = await Promise.all(
7838
8167
  internalRelations.map(async (relation) => {
7839
8168
  try {
@@ -7862,7 +8191,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
7862
8191
  return { ...relation, description: enhancedDescription };
7863
8192
  }
7864
8193
  } catch (error) {
7865
- logger17.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
8194
+ logger18.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
7866
8195
  }
7867
8196
  return relation;
7868
8197
  })
@@ -7957,12 +8286,16 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
7957
8286
  },
7958
8287
  credentialStoreRegistry
7959
8288
  );
8289
+ const artifactStreamRequestId = task.context?.metadata?.streamRequestId;
8290
+ if (artifactStreamRequestId && artifactComponents.length > 0) {
8291
+ graphSessionManager.updateArtifactComponents(artifactStreamRequestId, artifactComponents);
8292
+ }
7960
8293
  let contextId = task.context?.conversationId;
7961
8294
  if (!contextId || contextId === "default" || contextId === "") {
7962
8295
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
7963
8296
  if (taskIdMatch) {
7964
8297
  contextId = taskIdMatch[1];
7965
- logger17.info(
8298
+ logger18.info(
7966
8299
  {
7967
8300
  taskId: task.id,
7968
8301
  extractedContextId: contextId,
@@ -7978,7 +8311,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
7978
8311
  const isDelegation = task.context?.metadata?.isDelegation === true;
7979
8312
  agent.setDelegationStatus(isDelegation);
7980
8313
  if (isDelegation) {
7981
- logger17.info(
8314
+ logger18.info(
7982
8315
  { agentId: config.agentId, taskId: task.id },
7983
8316
  "Delegated agent - streaming disabled"
7984
8317
  );
@@ -8200,7 +8533,7 @@ async function getRegisteredGraph(executionContext) {
8200
8533
 
8201
8534
  // src/routes/agents.ts
8202
8535
  var app = new OpenAPIHono();
8203
- var logger18 = getLogger("agents");
8536
+ var logger19 = getLogger("agents");
8204
8537
  app.openapi(
8205
8538
  createRoute({
8206
8539
  method: "get",
@@ -8238,7 +8571,7 @@ app.openapi(
8238
8571
  tracestate: c.req.header("tracestate"),
8239
8572
  baggage: c.req.header("baggage")
8240
8573
  };
8241
- logger18.info(
8574
+ logger19.info(
8242
8575
  {
8243
8576
  otelHeaders,
8244
8577
  path: c.req.path,
@@ -8250,7 +8583,7 @@ app.openapi(
8250
8583
  const { tenantId, projectId, graphId, agentId } = executionContext;
8251
8584
  console.dir("executionContext", executionContext);
8252
8585
  if (agentId) {
8253
- logger18.info(
8586
+ logger19.info(
8254
8587
  {
8255
8588
  message: "getRegisteredAgent (agent-level)",
8256
8589
  tenantId,
@@ -8262,7 +8595,7 @@ app.openapi(
8262
8595
  );
8263
8596
  const credentialStores = c.get("credentialStores");
8264
8597
  const agent = await getRegisteredAgent(executionContext, credentialStores);
8265
- logger18.info({ agent }, "agent registered: well-known agent.json");
8598
+ logger19.info({ agent }, "agent registered: well-known agent.json");
8266
8599
  if (!agent) {
8267
8600
  throw createApiError({
8268
8601
  code: "not_found",
@@ -8271,7 +8604,7 @@ app.openapi(
8271
8604
  }
8272
8605
  return c.json(agent.agentCard);
8273
8606
  } else {
8274
- logger18.info(
8607
+ logger19.info(
8275
8608
  {
8276
8609
  message: "getRegisteredGraph (graph-level)",
8277
8610
  tenantId,
@@ -8297,7 +8630,7 @@ app.post("/a2a", async (c) => {
8297
8630
  tracestate: c.req.header("tracestate"),
8298
8631
  baggage: c.req.header("baggage")
8299
8632
  };
8300
- logger18.info(
8633
+ logger19.info(
8301
8634
  {
8302
8635
  otelHeaders,
8303
8636
  path: c.req.path,
@@ -8308,7 +8641,7 @@ app.post("/a2a", async (c) => {
8308
8641
  const executionContext = getRequestExecutionContext(c);
8309
8642
  const { tenantId, projectId, graphId, agentId } = executionContext;
8310
8643
  if (agentId) {
8311
- logger18.info(
8644
+ logger19.info(
8312
8645
  {
8313
8646
  message: "a2a (agent-level)",
8314
8647
  tenantId,
@@ -8332,7 +8665,7 @@ app.post("/a2a", async (c) => {
8332
8665
  }
8333
8666
  return a2aHandler(c, agent);
8334
8667
  } else {
8335
- logger18.info(
8668
+ logger19.info(
8336
8669
  {
8337
8670
  message: "a2a (graph-level)",
8338
8671
  tenantId,
@@ -8381,14 +8714,14 @@ app.post("/a2a", async (c) => {
8381
8714
  }
8382
8715
  });
8383
8716
  var agents_default = app;
8384
- var logger19 = getLogger("Transfer");
8717
+ var logger20 = getLogger("Transfer");
8385
8718
  async function executeTransfer({
8386
8719
  tenantId,
8387
8720
  threadId,
8388
8721
  projectId,
8389
8722
  targetAgentId
8390
8723
  }) {
8391
- logger19.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
8724
+ logger20.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
8392
8725
  await setActiveAgentForThread(dbClient_default)({
8393
8726
  scopes: { tenantId, projectId },
8394
8727
  threadId,
@@ -8970,7 +9303,7 @@ function createMCPStreamHelper() {
8970
9303
  }
8971
9304
 
8972
9305
  // src/handlers/executionHandler.ts
8973
- var logger20 = getLogger("ExecutionHandler");
9306
+ var logger21 = getLogger("ExecutionHandler");
8974
9307
  var ExecutionHandler = class {
8975
9308
  constructor() {
8976
9309
  // Hardcoded error limit - separate from configurable stopWhen
@@ -9006,7 +9339,7 @@ var ExecutionHandler = class {
9006
9339
  if (emitOperations) {
9007
9340
  graphSessionManager.enableEmitOperations(requestId2);
9008
9341
  }
9009
- logger20.info(
9342
+ logger21.info(
9010
9343
  { sessionId: requestId2, graphId, conversationId, emitOperations },
9011
9344
  "Created GraphSession for message execution"
9012
9345
  );
@@ -9021,7 +9354,7 @@ var ExecutionHandler = class {
9021
9354
  );
9022
9355
  }
9023
9356
  } catch (error) {
9024
- logger20.error(
9357
+ logger21.error(
9025
9358
  {
9026
9359
  error: error instanceof Error ? error.message : "Unknown error",
9027
9360
  stack: error instanceof Error ? error.stack : void 0
@@ -9037,7 +9370,7 @@ var ExecutionHandler = class {
9037
9370
  try {
9038
9371
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
9039
9372
  const taskId = `task_${conversationId}-${requestId2}`;
9040
- logger20.info(
9373
+ logger21.info(
9041
9374
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
9042
9375
  "Attempting to create or reuse existing task"
9043
9376
  );
@@ -9061,7 +9394,7 @@ var ExecutionHandler = class {
9061
9394
  agent_id: currentAgentId
9062
9395
  }
9063
9396
  });
9064
- logger20.info(
9397
+ logger21.info(
9065
9398
  {
9066
9399
  taskId,
9067
9400
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -9070,27 +9403,27 @@ var ExecutionHandler = class {
9070
9403
  );
9071
9404
  } catch (error) {
9072
9405
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
9073
- logger20.info(
9406
+ logger21.info(
9074
9407
  { taskId, error: error.message },
9075
9408
  "Task already exists, fetching existing task"
9076
9409
  );
9077
9410
  const existingTask = await getTask(dbClient_default)({ id: taskId });
9078
9411
  if (existingTask) {
9079
9412
  task = existingTask;
9080
- logger20.info(
9413
+ logger21.info(
9081
9414
  { taskId, existingTask },
9082
9415
  "Successfully reused existing task from race condition"
9083
9416
  );
9084
9417
  } else {
9085
- logger20.error({ taskId, error }, "Task constraint failed but task not found");
9418
+ logger21.error({ taskId, error }, "Task constraint failed but task not found");
9086
9419
  throw error;
9087
9420
  }
9088
9421
  } else {
9089
- logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
9422
+ logger21.error({ taskId, error }, "Failed to create task due to non-constraint error");
9090
9423
  throw error;
9091
9424
  }
9092
9425
  }
9093
- logger20.debug(
9426
+ logger21.debug(
9094
9427
  {
9095
9428
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9096
9429
  executionType: "create_initial_task",
@@ -9108,7 +9441,7 @@ var ExecutionHandler = class {
9108
9441
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
9109
9442
  while (iterations < maxTransfers) {
9110
9443
  iterations++;
9111
- logger20.info(
9444
+ logger21.info(
9112
9445
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
9113
9446
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
9114
9447
  );
@@ -9116,10 +9449,10 @@ var ExecutionHandler = class {
9116
9449
  scopes: { tenantId, projectId },
9117
9450
  conversationId
9118
9451
  });
9119
- logger20.info({ activeAgent }, "activeAgent");
9452
+ logger21.info({ activeAgent }, "activeAgent");
9120
9453
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
9121
9454
  currentAgentId = activeAgent.activeAgentId;
9122
- logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9455
+ logger21.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9123
9456
  }
9124
9457
  const agentBaseUrl = `${baseUrl}/agents`;
9125
9458
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -9160,13 +9493,13 @@ var ExecutionHandler = class {
9160
9493
  });
9161
9494
  if (!messageResponse?.result) {
9162
9495
  errorCount++;
9163
- logger20.error(
9496
+ logger21.error(
9164
9497
  { currentAgentId, iterations, errorCount },
9165
9498
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9166
9499
  );
9167
9500
  if (errorCount >= this.MAX_ERRORS) {
9168
9501
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9169
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9502
+ logger21.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9170
9503
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9171
9504
  if (task) {
9172
9505
  await updateTask(dbClient_default)({
@@ -9191,7 +9524,7 @@ var ExecutionHandler = class {
9191
9524
  const transferResponse = messageResponse.result;
9192
9525
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
9193
9526
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
9194
- logger20.info({ targetAgentId, transferReason }, "transfer response");
9527
+ logger21.info({ targetAgentId, transferReason }, "transfer response");
9195
9528
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
9196
9529
  const { success, targetAgentId: newAgentId } = await executeTransfer({
9197
9530
  projectId,
@@ -9202,7 +9535,7 @@ var ExecutionHandler = class {
9202
9535
  if (success) {
9203
9536
  fromAgentId = currentAgentId;
9204
9537
  currentAgentId = newAgentId;
9205
- logger20.info(
9538
+ logger21.info(
9206
9539
  {
9207
9540
  transferFrom: fromAgentId,
9208
9541
  transferTo: currentAgentId,
@@ -9220,7 +9553,7 @@ var ExecutionHandler = class {
9220
9553
  const graphSessionData = graphSessionManager.getSession(requestId2);
9221
9554
  if (graphSessionData) {
9222
9555
  const sessionSummary = graphSessionData.getSummary();
9223
- logger20.info(sessionSummary, "GraphSession data after completion");
9556
+ logger21.info(sessionSummary, "GraphSession data after completion");
9224
9557
  }
9225
9558
  let textContent = "";
9226
9559
  for (const part of responseParts) {
@@ -9274,22 +9607,22 @@ var ExecutionHandler = class {
9274
9607
  }
9275
9608
  });
9276
9609
  const updateTaskEnd = Date.now();
9277
- logger20.info(
9610
+ logger21.info(
9278
9611
  { duration: updateTaskEnd - updateTaskStart },
9279
9612
  "Completed updateTask operation"
9280
9613
  );
9281
9614
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
9282
9615
  await sseHelper.complete();
9283
- logger20.info({}, "Ending GraphSession and cleaning up");
9616
+ logger21.info({}, "Ending GraphSession and cleaning up");
9284
9617
  graphSessionManager.endSession(requestId2);
9285
- logger20.info({}, "Cleaning up streamHelper");
9618
+ logger21.info({}, "Cleaning up streamHelper");
9286
9619
  unregisterStreamHelper(requestId2);
9287
9620
  let response;
9288
9621
  if (sseHelper instanceof MCPStreamHelper) {
9289
9622
  const captured = sseHelper.getCapturedResponse();
9290
9623
  response = captured.text || "No response content";
9291
9624
  }
9292
- logger20.info({}, "ExecutionHandler returning success");
9625
+ logger21.info({}, "ExecutionHandler returning success");
9293
9626
  return { success: true, iterations, response };
9294
9627
  } catch (error) {
9295
9628
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
@@ -9300,13 +9633,13 @@ var ExecutionHandler = class {
9300
9633
  });
9301
9634
  }
9302
9635
  errorCount++;
9303
- logger20.warn(
9636
+ logger21.warn(
9304
9637
  { iterations, errorCount },
9305
9638
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9306
9639
  );
9307
9640
  if (errorCount >= this.MAX_ERRORS) {
9308
9641
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9309
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9642
+ logger21.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9310
9643
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9311
9644
  if (task) {
9312
9645
  await updateTask(dbClient_default)({
@@ -9327,7 +9660,7 @@ var ExecutionHandler = class {
9327
9660
  }
9328
9661
  }
9329
9662
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
9330
- logger20.error({ maxTransfers, iterations }, errorMessage);
9663
+ logger21.error({ maxTransfers, iterations }, errorMessage);
9331
9664
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
9332
9665
  if (task) {
9333
9666
  await updateTask(dbClient_default)({
@@ -9346,7 +9679,7 @@ var ExecutionHandler = class {
9346
9679
  unregisterStreamHelper(requestId2);
9347
9680
  return { success: false, error: errorMessage, iterations };
9348
9681
  } catch (error) {
9349
- logger20.error({ error }, "Error in execution handler");
9682
+ logger21.error({ error }, "Error in execution handler");
9350
9683
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
9351
9684
  await sseHelper.writeOperation(
9352
9685
  errorOp(`Execution error: ${errorMessage}`, currentAgentId || "system")
@@ -9373,7 +9706,7 @@ var ExecutionHandler = class {
9373
9706
 
9374
9707
  // src/routes/chat.ts
9375
9708
  var app2 = new OpenAPIHono();
9376
- var logger21 = getLogger("completionsHandler");
9709
+ var logger22 = getLogger("completionsHandler");
9377
9710
  var chatCompletionsRoute = createRoute({
9378
9711
  method: "post",
9379
9712
  path: "/completions",
@@ -9491,7 +9824,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9491
9824
  tracestate: c.req.header("tracestate"),
9492
9825
  baggage: c.req.header("baggage")
9493
9826
  };
9494
- logger21.info(
9827
+ logger22.info(
9495
9828
  {
9496
9829
  otelHeaders,
9497
9830
  path: c.req.path,
@@ -9584,7 +9917,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9584
9917
  dbClient: dbClient_default,
9585
9918
  credentialStores
9586
9919
  });
9587
- logger21.info(
9920
+ logger22.info(
9588
9921
  {
9589
9922
  tenantId,
9590
9923
  projectId,
@@ -9632,7 +9965,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9632
9965
  try {
9633
9966
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
9634
9967
  await sseHelper.writeRole();
9635
- logger21.info({ agentId }, "Starting execution");
9968
+ logger22.info({ agentId }, "Starting execution");
9636
9969
  const emitOperationsHeader = c.req.header("x-emit-operations");
9637
9970
  const emitOperations = emitOperationsHeader === "true";
9638
9971
  const executionHandler = new ExecutionHandler();
@@ -9645,7 +9978,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9645
9978
  sseHelper,
9646
9979
  emitOperations
9647
9980
  });
9648
- logger21.info(
9981
+ logger22.info(
9649
9982
  { result },
9650
9983
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
9651
9984
  );
@@ -9659,7 +9992,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9659
9992
  }
9660
9993
  await sseHelper.complete();
9661
9994
  } catch (error) {
9662
- logger21.error(
9995
+ logger22.error(
9663
9996
  {
9664
9997
  error: error instanceof Error ? error.message : error,
9665
9998
  stack: error instanceof Error ? error.stack : void 0
@@ -9676,12 +10009,12 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9676
10009
  );
9677
10010
  await sseHelper.complete();
9678
10011
  } catch (streamError) {
9679
- logger21.error({ streamError }, "Failed to write error to stream");
10012
+ logger22.error({ streamError }, "Failed to write error to stream");
9680
10013
  }
9681
10014
  }
9682
10015
  });
9683
10016
  } catch (error) {
9684
- logger21.error(
10017
+ logger22.error(
9685
10018
  {
9686
10019
  error: error instanceof Error ? error.message : error,
9687
10020
  stack: error instanceof Error ? error.stack : void 0
@@ -9705,7 +10038,7 @@ var getMessageText = (content) => {
9705
10038
  };
9706
10039
  var chat_default = app2;
9707
10040
  var app3 = new OpenAPIHono();
9708
- var logger22 = getLogger("chatDataStream");
10041
+ var logger23 = getLogger("chatDataStream");
9709
10042
  var chatDataStreamRoute = createRoute({
9710
10043
  method: "post",
9711
10044
  path: "/chat",
@@ -9822,7 +10155,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
9822
10155
  });
9823
10156
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
9824
10157
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
9825
- logger22.info({ userText, lastUserMessage }, "userText");
10158
+ logger23.info({ userText, lastUserMessage }, "userText");
9826
10159
  const messageSpan = trace.getActiveSpan();
9827
10160
  if (messageSpan) {
9828
10161
  messageSpan.setAttributes({
@@ -9867,7 +10200,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
9867
10200
  await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
9868
10201
  }
9869
10202
  } catch (err) {
9870
- logger22.error({ err }, "Streaming error");
10203
+ logger23.error({ err }, "Streaming error");
9871
10204
  await streamHelper.writeOperation(errorOp("Internal server error", "system"));
9872
10205
  } finally {
9873
10206
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -9888,7 +10221,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
9888
10221
  )
9889
10222
  );
9890
10223
  } catch (error) {
9891
- logger22.error({ error }, "chatDataStream error");
10224
+ logger23.error({ error }, "chatDataStream error");
9892
10225
  throw createApiError({
9893
10226
  code: "internal_server_error",
9894
10227
  message: "Failed to process chat completion"
@@ -9899,7 +10232,7 @@ var chatDataStream_default = app3;
9899
10232
  function createMCPSchema(schema) {
9900
10233
  return schema;
9901
10234
  }
9902
- var logger23 = getLogger("mcp");
10235
+ var logger24 = getLogger("mcp");
9903
10236
  var _MockResponseSingleton = class _MockResponseSingleton {
9904
10237
  constructor() {
9905
10238
  __publicField(this, "mockRes");
@@ -9954,21 +10287,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
9954
10287
  id: 0
9955
10288
  });
9956
10289
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
9957
- logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
10290
+ logger24.info({ sessionId }, "Spoofing initialization message to set transport state");
9958
10291
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
9959
10292
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
9960
10293
  try {
9961
10294
  await transport.handleRequest(req, mockRes, spoofInitMessage);
9962
- logger23.info({ sessionId }, "Successfully spoofed initialization");
10295
+ logger24.info({ sessionId }, "Successfully spoofed initialization");
9963
10296
  } catch (spoofError) {
9964
- logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10297
+ logger24.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
9965
10298
  }
9966
10299
  };
9967
10300
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
9968
10301
  const sessionId = req.headers["mcp-session-id"];
9969
- logger23.info({ sessionId }, "Received MCP session ID");
10302
+ logger24.info({ sessionId }, "Received MCP session ID");
9970
10303
  if (!sessionId) {
9971
- logger23.info({ body }, "Missing session ID");
10304
+ logger24.info({ body }, "Missing session ID");
9972
10305
  res.writeHead(400).end(
9973
10306
  JSON.stringify({
9974
10307
  jsonrpc: "2.0",
@@ -9994,7 +10327,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
9994
10327
  scopes: { tenantId, projectId },
9995
10328
  conversationId: sessionId
9996
10329
  });
9997
- logger23.info(
10330
+ logger24.info(
9998
10331
  {
9999
10332
  sessionId,
10000
10333
  conversationFound: !!conversation,
@@ -10005,7 +10338,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
10005
10338
  "Conversation lookup result"
10006
10339
  );
10007
10340
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
10008
- logger23.info(
10341
+ logger24.info(
10009
10342
  { sessionId, conversationId: conversation?.id },
10010
10343
  "MCP session not found or invalid"
10011
10344
  );
@@ -10066,7 +10399,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
10066
10399
  requestId: requestId2,
10067
10400
  sseHelper: mcpStreamHelper
10068
10401
  });
10069
- logger23.info(
10402
+ logger24.info(
10070
10403
  { result },
10071
10404
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
10072
10405
  );
@@ -10150,7 +10483,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
10150
10483
  dbClient: dbClient_default,
10151
10484
  credentialStores
10152
10485
  });
10153
- logger23.info(
10486
+ logger24.info(
10154
10487
  {
10155
10488
  tenantId,
10156
10489
  projectId,
@@ -10212,7 +10545,7 @@ var validateRequestParameters = (c) => {
10212
10545
  };
10213
10546
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
10214
10547
  const { tenantId, projectId, graphId } = executionContext;
10215
- logger23.info({ body }, "Received initialization request");
10548
+ logger24.info({ body }, "Received initialization request");
10216
10549
  const sessionId = getConversationId();
10217
10550
  const agentGraph = await getAgentGraphWithDefaultAgent(dbClient_default)({
10218
10551
  scopes: { tenantId, projectId, graphId }
@@ -10252,7 +10585,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10252
10585
  }
10253
10586
  }
10254
10587
  });
10255
- logger23.info(
10588
+ logger24.info(
10256
10589
  { sessionId, conversationId: conversation.id },
10257
10590
  "Created MCP session as conversation"
10258
10591
  );
@@ -10261,9 +10594,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10261
10594
  });
10262
10595
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
10263
10596
  await server.connect(transport);
10264
- logger23.info({ sessionId }, "Server connected for initialization");
10597
+ logger24.info({ sessionId }, "Server connected for initialization");
10265
10598
  res.setHeader("Mcp-Session-Id", sessionId);
10266
- logger23.info(
10599
+ logger24.info(
10267
10600
  {
10268
10601
  sessionId,
10269
10602
  bodyMethod: body?.method,
@@ -10272,7 +10605,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10272
10605
  "About to handle initialization request"
10273
10606
  );
10274
10607
  await transport.handleRequest(req, res, body);
10275
- logger23.info({ sessionId }, "Successfully handled initialization request");
10608
+ logger24.info({ sessionId }, "Successfully handled initialization request");
10276
10609
  return toFetchResponse(res);
10277
10610
  };
10278
10611
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -10300,8 +10633,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10300
10633
  sessionId,
10301
10634
  conversation.metadata?.session_data?.mcpProtocolVersion
10302
10635
  );
10303
- logger23.info({ sessionId }, "Server connected and transport initialized");
10304
- logger23.info(
10636
+ logger24.info({ sessionId }, "Server connected and transport initialized");
10637
+ logger24.info(
10305
10638
  {
10306
10639
  sessionId,
10307
10640
  bodyKeys: Object.keys(body || {}),
@@ -10315,9 +10648,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10315
10648
  );
10316
10649
  try {
10317
10650
  await transport.handleRequest(req, res, body);
10318
- logger23.info({ sessionId }, "Successfully handled MCP request");
10651
+ logger24.info({ sessionId }, "Successfully handled MCP request");
10319
10652
  } catch (transportError) {
10320
- logger23.error(
10653
+ logger24.error(
10321
10654
  {
10322
10655
  sessionId,
10323
10656
  error: transportError,
@@ -10368,13 +10701,13 @@ app4.openapi(
10368
10701
  }
10369
10702
  const { executionContext } = paramValidation;
10370
10703
  const body = c.get("requestBody") || {};
10371
- logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
10704
+ logger24.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
10372
10705
  const isInitRequest = body.method === "initialize";
10373
10706
  const { req, res } = toReqRes(c.req.raw);
10374
10707
  const validatedContext = c.get("validatedContext") || {};
10375
10708
  const credentialStores = c.get("credentialStores");
10376
- logger23.info({ validatedContext }, "Validated context");
10377
- logger23.info({ req }, "request");
10709
+ logger24.info({ validatedContext }, "Validated context");
10710
+ logger24.info({ req }, "request");
10378
10711
  if (isInitRequest) {
10379
10712
  return await handleInitializationRequest(
10380
10713
  body,
@@ -10396,7 +10729,7 @@ app4.openapi(
10396
10729
  );
10397
10730
  }
10398
10731
  } catch (e) {
10399
- logger23.error(
10732
+ logger24.error(
10400
10733
  {
10401
10734
  error: e instanceof Error ? e.message : e,
10402
10735
  stack: e instanceof Error ? e.stack : void 0
@@ -10408,7 +10741,7 @@ app4.openapi(
10408
10741
  }
10409
10742
  );
10410
10743
  app4.get("/", async (c) => {
10411
- logger23.info({}, "Received GET MCP request");
10744
+ logger24.info({}, "Received GET MCP request");
10412
10745
  return c.json(
10413
10746
  {
10414
10747
  jsonrpc: "2.0",
@@ -10422,7 +10755,7 @@ app4.get("/", async (c) => {
10422
10755
  );
10423
10756
  });
10424
10757
  app4.delete("/", async (c) => {
10425
- logger23.info({}, "Received DELETE MCP request");
10758
+ logger24.info({}, "Received DELETE MCP request");
10426
10759
  return c.json(
10427
10760
  {
10428
10761
  jsonrpc: "2.0",
@@ -10435,7 +10768,7 @@ app4.delete("/", async (c) => {
10435
10768
  var mcp_default = app4;
10436
10769
 
10437
10770
  // src/app.ts
10438
- var logger24 = getLogger("agents-run-api");
10771
+ var logger25 = getLogger("agents-run-api");
10439
10772
  function createExecutionHono(serverConfig, credentialStores) {
10440
10773
  const app6 = new OpenAPIHono();
10441
10774
  app6.use("*", otel());
@@ -10451,7 +10784,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10451
10784
  const body = await c.req.json();
10452
10785
  c.set("requestBody", body);
10453
10786
  } catch (error) {
10454
- logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
10787
+ logger25.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
10455
10788
  }
10456
10789
  }
10457
10790
  return next();
@@ -10502,8 +10835,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10502
10835
  if (!isExpectedError) {
10503
10836
  const errorMessage = err instanceof Error ? err.message : String(err);
10504
10837
  const errorStack = err instanceof Error ? err.stack : void 0;
10505
- if (logger24) {
10506
- logger24.error(
10838
+ if (logger25) {
10839
+ logger25.error(
10507
10840
  {
10508
10841
  error: err,
10509
10842
  message: errorMessage,
@@ -10515,8 +10848,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10515
10848
  );
10516
10849
  }
10517
10850
  } else {
10518
- if (logger24) {
10519
- logger24.error(
10851
+ if (logger25) {
10852
+ logger25.error(
10520
10853
  {
10521
10854
  error: err,
10522
10855
  path: c.req.path,
@@ -10533,8 +10866,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10533
10866
  const response = err.getResponse();
10534
10867
  return response;
10535
10868
  } catch (responseError) {
10536
- if (logger24) {
10537
- logger24.error({ error: responseError }, "Error while handling HTTPException response");
10869
+ if (logger25) {
10870
+ logger25.error({ error: responseError }, "Error while handling HTTPException response");
10538
10871
  }
10539
10872
  }
10540
10873
  }
@@ -10568,7 +10901,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10568
10901
  app6.use("*", async (c, next) => {
10569
10902
  const executionContext = c.get("executionContext");
10570
10903
  if (!executionContext) {
10571
- logger24.debug({}, "Empty execution context");
10904
+ logger25.debug({}, "Empty execution context");
10572
10905
  return next();
10573
10906
  }
10574
10907
  const { tenantId, projectId, graphId } = executionContext;
@@ -10577,7 +10910,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10577
10910
  if (requestBody) {
10578
10911
  conversationId = requestBody.conversationId;
10579
10912
  if (!conversationId) {
10580
- logger24.debug({ requestBody }, "No conversation ID found in request body");
10913
+ logger25.debug({ requestBody }, "No conversation ID found in request body");
10581
10914
  }
10582
10915
  }
10583
10916
  const entries = Object.fromEntries(
@@ -10592,7 +10925,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10592
10925
  })
10593
10926
  );
10594
10927
  if (!Object.keys(entries).length) {
10595
- logger24.debug({}, "Empty entries for baggage");
10928
+ logger25.debug({}, "Empty entries for baggage");
10596
10929
  return next();
10597
10930
  }
10598
10931
  const bag = Object.entries(entries).reduce(