@inkeep/agents-run-api 0.0.0-dev-20260113172432 → 0.0.0-dev-20260115183047

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +2 -1
  2. package/dist/a2a/client.d.ts +3 -1
  3. package/dist/a2a/client.js +23 -9
  4. package/dist/a2a/handlers.js +11 -5
  5. package/dist/a2a/transfer.d.ts +6 -1
  6. package/dist/a2a/transfer.js +10 -6
  7. package/dist/agents/Agent.d.ts +8 -4
  8. package/dist/agents/Agent.js +226 -92
  9. package/dist/agents/ToolSessionManager.js +2 -2
  10. package/dist/agents/generateTaskHandler.d.ts +4 -9
  11. package/dist/agents/generateTaskHandler.js +107 -246
  12. package/dist/agents/relationTools.d.ts +19 -8
  13. package/dist/agents/relationTools.js +105 -14
  14. package/dist/agents/types.d.ts +4 -2
  15. package/dist/agents/versions/v1/Phase1Config.d.ts +4 -3
  16. package/dist/agents/versions/v1/Phase1Config.js +33 -20
  17. package/dist/constants/execution-limits/index.js +1 -1
  18. package/dist/context/ContextFetcher.d.ts +68 -0
  19. package/dist/context/ContextFetcher.js +276 -0
  20. package/dist/context/ContextResolver.d.ts +56 -0
  21. package/dist/context/ContextResolver.js +273 -0
  22. package/dist/context/context.d.ts +19 -0
  23. package/dist/context/context.js +108 -0
  24. package/dist/context/contextCache.d.ts +56 -0
  25. package/dist/context/contextCache.js +175 -0
  26. package/dist/context/index.d.ts +6 -0
  27. package/dist/context/index.js +7 -0
  28. package/dist/context/validation.d.ts +39 -0
  29. package/dist/context/validation.js +255 -0
  30. package/dist/create-app.d.ts +2 -2
  31. package/dist/create-app.js +7 -2
  32. package/dist/data/agent.d.ts +2 -2
  33. package/dist/data/agent.js +17 -22
  34. package/dist/data/agents.d.ts +2 -2
  35. package/dist/data/agents.js +34 -42
  36. package/dist/data/conversations.d.ts +2 -1
  37. package/dist/data/conversations.js +7 -8
  38. package/dist/data/db/dbClient.d.ts +2 -2
  39. package/dist/data/db/dbClient.js +2 -10
  40. package/dist/env.d.ts +6 -2
  41. package/dist/env.js +3 -1
  42. package/dist/handlers/executionHandler.d.ts +3 -2
  43. package/dist/handlers/executionHandler.js +46 -22
  44. package/dist/index.d.ts +3 -3
  45. package/dist/middleware/api-key-auth.d.ts +4 -10
  46. package/dist/middleware/api-key-auth.js +164 -163
  47. package/dist/middleware/index.d.ts +3 -2
  48. package/dist/middleware/index.js +3 -2
  49. package/dist/middleware/projectConfig.d.ts +19 -0
  50. package/dist/middleware/projectConfig.js +80 -0
  51. package/dist/routes/agents.d.ts +2 -1
  52. package/dist/routes/agents.js +7 -13
  53. package/dist/routes/chat.d.ts +2 -1
  54. package/dist/routes/chat.js +29 -52
  55. package/dist/routes/chatDataStream.d.ts +2 -1
  56. package/dist/routes/chatDataStream.js +28 -30
  57. package/dist/routes/mcp.d.ts +2 -1
  58. package/dist/routes/mcp.js +25 -37
  59. package/dist/services/AgentSession.d.ts +5 -7
  60. package/dist/services/AgentSession.js +25 -34
  61. package/dist/services/ArtifactParser.d.ts +2 -2
  62. package/dist/services/ArtifactParser.js +2 -2
  63. package/dist/services/ArtifactService.d.ts +2 -3
  64. package/dist/services/ArtifactService.js +23 -20
  65. package/dist/services/BaseCompressor.js +2 -2
  66. package/dist/services/IncrementalStreamParser.d.ts +2 -2
  67. package/dist/services/IncrementalStreamParser.js +2 -2
  68. package/dist/services/ResponseFormatter.d.ts +2 -2
  69. package/dist/services/ResponseFormatter.js +2 -2
  70. package/dist/services/evaluationHttpClient.d.ts +21 -0
  71. package/dist/services/evaluationHttpClient.js +48 -0
  72. package/dist/services/evaluationRunConfigMatcher.d.ts +6 -0
  73. package/dist/services/evaluationRunConfigMatcher.js +7 -0
  74. package/dist/tools/NativeSandboxExecutor.js +1 -1
  75. package/dist/tools/distill-conversation-history-tool.js +2 -2
  76. package/dist/tools/distill-conversation-tool.js +2 -2
  77. package/dist/types/execution-context.d.ts +8 -14
  78. package/dist/types/execution-context.js +3 -2
  79. package/dist/utils/model-resolver.d.ts +2 -2
  80. package/dist/utils/model-resolver.js +3 -13
  81. package/dist/utils/project.d.ts +207 -0
  82. package/dist/utils/project.js +315 -0
  83. package/dist/utils/token-estimator.d.ts +6 -52
  84. package/dist/utils/token-estimator.js +2 -38
  85. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { getLogger } from "../logger.js";
1
+ import { getLogger as getLogger$1 } from "../logger.js";
2
2
  import dbClient_default from "../data/db/dbClient.js";
3
3
  import { ARTIFACT_GENERATION_BACKOFF_INITIAL_MS, ARTIFACT_GENERATION_BACKOFF_MAX_MS, ARTIFACT_GENERATION_MAX_RETRIES, ARTIFACT_SESSION_MAX_PENDING, ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES, STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS, STATUS_UPDATE_DEFAULT_NUM_EVENTS } from "../constants/execution-limits/index.js";
4
4
  import { toolSessionManager } from "../agents/ToolSessionManager.js";
@@ -9,12 +9,12 @@ import { getStreamHelper } from "../utils/stream-registry.js";
9
9
  import { ArtifactService } from "./ArtifactService.js";
10
10
  import { ArtifactParser } from "./ArtifactParser.js";
11
11
  import { z } from "@hono/zod-openapi";
12
- import { CONVERSATION_HISTORY_DEFAULT_LIMIT, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, ModelFactory, getLedgerArtifacts, getSubAgentById } from "@inkeep/agents-core";
12
+ import { CONVERSATION_HISTORY_DEFAULT_LIMIT, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, ModelFactory, getLedgerArtifacts } from "@inkeep/agents-core";
13
13
  import { SpanStatusCode } from "@opentelemetry/api";
14
14
  import { Output, generateText } from "ai";
15
15
 
16
16
  //#region src/services/AgentSession.ts
17
- const logger = getLogger("AgentSession");
17
+ const logger = getLogger$1("AgentSession");
18
18
  /**
19
19
  * Tracks all agent operations and interactions for a single message
20
20
  * Now includes intelligent status update functionality
@@ -36,30 +36,26 @@ var AgentSession = class {
36
36
  artifactService;
37
37
  artifactParser;
38
38
  isEmitOperations = false;
39
- constructor(sessionId, messageId, agentId, tenantId, projectId, contextId) {
39
+ constructor(sessionId, messageId, executionContext, contextId) {
40
40
  this.sessionId = sessionId;
41
41
  this.messageId = messageId;
42
- this.agentId = agentId;
43
- this.tenantId = tenantId;
44
- this.projectId = projectId;
42
+ this.executionContext = executionContext;
45
43
  this.contextId = contextId;
46
44
  logger.debug({
47
45
  sessionId,
48
46
  messageId,
49
- agentId
47
+ agentId: executionContext.agentId
50
48
  }, "AgentSession created");
51
- if (tenantId && projectId) {
52
- toolSessionManager.createSessionWithId(sessionId, tenantId, projectId, contextId || "default", `task_${contextId}-${messageId}`);
49
+ if (executionContext.tenantId && executionContext.projectId) {
50
+ toolSessionManager.createSessionWithId(sessionId, executionContext.tenantId, executionContext.projectId, contextId || "default", `task_${contextId}-${messageId}`);
53
51
  this.artifactService = new ArtifactService({
54
- tenantId,
55
- projectId,
52
+ executionContext,
56
53
  sessionId,
57
54
  contextId,
58
55
  taskId: `task_${contextId}-${messageId}`,
59
56
  streamRequestId: sessionId
60
57
  });
61
- this.artifactParser = new ArtifactParser(tenantId, {
62
- projectId,
58
+ this.artifactParser = new ArtifactParser(executionContext, {
63
59
  sessionId,
64
60
  contextId,
65
61
  taskId: `task_${contextId}-${messageId}`,
@@ -67,6 +63,7 @@ var AgentSession = class {
67
63
  artifactService: this.artifactService
68
64
  });
69
65
  }
66
+ this.executionContext = executionContext;
70
67
  }
71
68
  /**
72
69
  * Enable emit operations to send data operations
@@ -303,7 +300,7 @@ var AgentSession = class {
303
300
  return {
304
301
  sessionId: this.sessionId,
305
302
  messageId: this.messageId,
306
- agentId: this.agentId,
303
+ agentId: this.executionContext.agentId,
307
304
  totalEvents: this.events.length,
308
305
  eventCounts,
309
306
  agentCounts,
@@ -377,7 +374,7 @@ var AgentSession = class {
377
374
  logger.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
378
375
  return;
379
376
  }
380
- if (!this.agentId) {
377
+ if (!this.executionContext.agentId) {
381
378
  logger.warn({ sessionId: this.sessionId }, "No agent ID - cannot generate update");
382
379
  return;
383
380
  }
@@ -485,6 +482,7 @@ var AgentSession = class {
485
482
  * Generate structured status update using configured data components
486
483
  */
487
484
  async generateStructuredStatusUpdate(newEvents, elapsedTime, statusComponents, summarizerModel, previousSummaries = []) {
485
+ const { tenantId, projectId } = this.executionContext;
488
486
  return tracer.startActiveSpan("agent_session.generate_structured_update", { attributes: {
489
487
  "agent_session.id": this.sessionId,
490
488
  "events.count": newEvents.length,
@@ -496,10 +494,10 @@ var AgentSession = class {
496
494
  try {
497
495
  const userVisibleActivities = this.extractUserVisibleActivities(newEvents);
498
496
  let conversationContext = "";
499
- if (this.tenantId && this.projectId) try {
497
+ if (tenantId && projectId) try {
500
498
  const conversationHistory = await getFormattedConversationHistory({
501
- tenantId: this.tenantId,
502
- projectId: this.projectId,
499
+ tenantId,
500
+ projectId,
503
501
  conversationId: this.contextId || "default",
504
502
  options: {
505
503
  limit: CONVERSATION_HISTORY_DEFAULT_LIMIT,
@@ -833,14 +831,8 @@ Make the name extremely specific to what this tool call actually returned, not g
833
831
  let modelToUse = this.statusUpdateState?.summarizerModel;
834
832
  if (!modelToUse?.model?.trim()) if (!this.statusUpdateState?.baseModel?.model?.trim()) {
835
833
  if (artifactData.subAgentId && artifactData.tenantId && artifactData.projectId) try {
836
- const agentData = await getSubAgentById(dbClient_default)({
837
- scopes: {
838
- tenantId: artifactData.tenantId,
839
- projectId: artifactData.projectId,
840
- agentId: this.agentId || ""
841
- },
842
- subAgentId: artifactData.subAgentId
843
- });
834
+ const subAgentId = artifactData.subAgentId;
835
+ const agentData = this.executionContext.project.agents[this.executionContext.agentId].subAgents?.[subAgentId];
844
836
  if (agentData && "models" in agentData && agentData.models?.base?.model) {
845
837
  modelToUse = agentData.models.base;
846
838
  logger.info({
@@ -986,8 +978,7 @@ Make the name extremely specific to what this tool call actually returned, not g
986
978
  if (!mainSaveSucceeded) try {
987
979
  if (artifactData.tenantId && artifactData.projectId) {
988
980
  await new ArtifactService({
989
- tenantId: artifactData.tenantId,
990
- projectId: artifactData.projectId,
981
+ executionContext: this.executionContext,
991
982
  contextId: artifactData.contextId || "unknown",
992
983
  taskId: artifactData.taskId,
993
984
  sessionId: this.sessionId
@@ -1080,16 +1071,16 @@ var AgentSessionManager = class {
1080
1071
  /**
1081
1072
  * Create a new session for a message
1082
1073
  */
1083
- createSession(messageId, agentId, tenantId, projectId, contextId) {
1074
+ createSession(messageId, executionContext, contextId) {
1084
1075
  const sessionId = messageId;
1085
- const session = new AgentSession(sessionId, messageId, agentId, tenantId, projectId, contextId);
1076
+ const session = new AgentSession(sessionId, messageId, executionContext, contextId);
1086
1077
  this.sessions.set(sessionId, session);
1087
1078
  logger.info({
1088
1079
  sessionId,
1089
1080
  messageId,
1090
- agentId,
1091
- tenantId,
1092
- projectId,
1081
+ agentId: executionContext.agentId,
1082
+ tenantId: executionContext.tenantId,
1083
+ projectId: executionContext.projectId,
1093
1084
  contextId
1094
1085
  }, "AgentSession created");
1095
1086
  return sessionId;
@@ -1,5 +1,5 @@
1
1
  import { ArtifactFullData, ArtifactService, ArtifactSummaryData } from "./ArtifactService.js";
2
- import { ArtifactComponentApiInsert } from "@inkeep/agents-core";
2
+ import { ArtifactComponentApiInsert, FullExecutionContext } from "@inkeep/agents-core";
3
3
 
4
4
  //#region src/services/ArtifactParser.d.ts
5
5
  interface StreamPart {
@@ -34,7 +34,7 @@ declare class ArtifactParser {
34
34
  private static readonly ARTIFACT_PATTERNS;
35
35
  private static readonly INCOMPLETE_CREATE_REGEX;
36
36
  private artifactService;
37
- constructor(tenantId: string, options?: {
37
+ constructor(executionContext: FullExecutionContext, options?: {
38
38
  sessionId?: string;
39
39
  taskId?: string;
40
40
  projectId?: string;
@@ -33,10 +33,10 @@ var ArtifactParser = class ArtifactParser {
33
33
  ];
34
34
  static INCOMPLETE_CREATE_REGEX = /<artifact:create(?![^>]*(?:\/>|<\/artifact:create>))/;
35
35
  artifactService;
36
- constructor(tenantId, options) {
36
+ constructor(executionContext, options) {
37
37
  if (options?.artifactService) this.artifactService = options.artifactService;
38
38
  else this.artifactService = new ArtifactService({
39
- tenantId,
39
+ executionContext,
40
40
  ...options
41
41
  });
42
42
  }
@@ -1,4 +1,4 @@
1
- import { ArtifactComponentApiInsert } from "@inkeep/agents-core";
1
+ import { ArtifactComponentApiInsert, FullExecutionContext } from "@inkeep/agents-core";
2
2
 
3
3
  //#region src/services/ArtifactService.d.ts
4
4
  interface ArtifactSummaryData {
@@ -25,10 +25,9 @@ interface ArtifactCreateRequest {
25
25
  detailsSelector?: Record<string, string>;
26
26
  }
27
27
  interface ArtifactServiceContext {
28
- tenantId: string;
28
+ executionContext: FullExecutionContext;
29
29
  sessionId?: string;
30
30
  taskId?: string;
31
- projectId?: string;
32
31
  contextId?: string;
33
32
  artifactComponents?: ArtifactComponentApiInsert[];
34
33
  streamRequestId?: string;
@@ -1,4 +1,4 @@
1
- import { getLogger } from "../logger.js";
1
+ import { getLogger as getLogger$1 } from "../logger.js";
2
2
  import dbClient_default from "../data/db/dbClient.js";
3
3
  import { toolSessionManager } from "../agents/ToolSessionManager.js";
4
4
  import { extractFullFields, extractPreviewFields } from "../utils/schema-validation.js";
@@ -7,7 +7,7 @@ import { getLedgerArtifacts, getTask, listTaskIdsByContextId, upsertLedgerArtifa
7
7
  import jmespath from "jmespath";
8
8
 
9
9
  //#region src/services/ArtifactService.ts
10
- const logger = getLogger("ArtifactService");
10
+ const logger = getLogger$1("ArtifactService");
11
11
  /**
12
12
  * Service class responsible for artifact business logic operations
13
13
  * Handles database persistence, tool result extraction, and artifact management
@@ -36,18 +36,18 @@ var ArtifactService = class ArtifactService {
36
36
  */
37
37
  async getContextArtifacts(contextId) {
38
38
  const artifacts = /* @__PURE__ */ new Map();
39
+ const { tenantId, projectId } = this.context.executionContext;
39
40
  try {
40
41
  const taskIds = await listTaskIdsByContextId(dbClient_default)({ contextId });
41
42
  for (const taskId of taskIds) {
42
- const task = await getTask(dbClient_default)({ id: taskId });
43
- if (!task) {
43
+ if (!await getTask(dbClient_default)({ id: taskId })) {
44
44
  logger.warn({ taskId }, "Task not found when fetching artifacts");
45
45
  continue;
46
46
  }
47
47
  const taskArtifacts = await getLedgerArtifacts(dbClient_default)({
48
48
  scopes: {
49
- tenantId: this.context.tenantId,
50
- projectId: task.projectId
49
+ tenantId,
50
+ projectId
51
51
  },
52
52
  taskId
53
53
  });
@@ -140,6 +140,7 @@ var ArtifactService = class ArtifactService {
140
140
  */
141
141
  async getArtifactSummary(artifactId, toolCallId, artifactMap) {
142
142
  const key = `${artifactId}:${toolCallId}`;
143
+ const { tenantId, projectId } = this.context.executionContext;
143
144
  if (this.context.streamRequestId) {
144
145
  const cachedArtifact = await agentSessionManager.getArtifactCache(this.context.streamRequestId, key);
145
146
  if (cachedArtifact) return this.formatArtifactSummaryData(cachedArtifact, artifactId, toolCallId);
@@ -153,7 +154,7 @@ var ArtifactService = class ArtifactService {
153
154
  return this.formatArtifactSummaryData(artifact, artifactId, toolCallId);
154
155
  }
155
156
  try {
156
- if (!this.context.projectId || !this.context.taskId) {
157
+ if (!projectId || !this.context.taskId) {
157
158
  logger.warn({
158
159
  artifactId,
159
160
  toolCallId
@@ -163,8 +164,8 @@ var ArtifactService = class ArtifactService {
163
164
  let artifacts = [];
164
165
  artifacts = await getLedgerArtifacts(dbClient_default)({
165
166
  scopes: {
166
- tenantId: this.context.tenantId,
167
- projectId: this.context.projectId
167
+ tenantId,
168
+ projectId
168
169
  },
169
170
  artifactId,
170
171
  toolCallId
@@ -172,8 +173,8 @@ var ArtifactService = class ArtifactService {
172
173
  if (artifacts.length > 0) return this.formatArtifactSummaryData(artifacts[0], artifactId, toolCallId);
173
174
  artifacts = await getLedgerArtifacts(dbClient_default)({
174
175
  scopes: {
175
- tenantId: this.context.tenantId,
176
- projectId: this.context.projectId
176
+ tenantId,
177
+ projectId
177
178
  },
178
179
  artifactId,
179
180
  taskId: this.context.taskId
@@ -194,6 +195,7 @@ var ArtifactService = class ArtifactService {
194
195
  */
195
196
  async getArtifactFull(artifactId, toolCallId, artifactMap) {
196
197
  const key = `${artifactId}:${toolCallId}`;
198
+ const { tenantId, projectId } = this.context.executionContext;
197
199
  if (this.context.streamRequestId) {
198
200
  const cachedArtifact = await agentSessionManager.getArtifactCache(this.context.streamRequestId, key);
199
201
  if (cachedArtifact) return this.formatArtifactFullData(cachedArtifact, artifactId, toolCallId);
@@ -207,7 +209,7 @@ var ArtifactService = class ArtifactService {
207
209
  return this.formatArtifactFullData(artifact, artifactId, toolCallId);
208
210
  }
209
211
  try {
210
- if (!this.context.projectId || !this.context.taskId) {
212
+ if (!projectId || !this.context.taskId) {
211
213
  logger.warn({
212
214
  artifactId,
213
215
  toolCallId
@@ -217,8 +219,8 @@ var ArtifactService = class ArtifactService {
217
219
  let artifacts = [];
218
220
  artifacts = await getLedgerArtifacts(dbClient_default)({
219
221
  scopes: {
220
- tenantId: this.context.tenantId,
221
- projectId: this.context.projectId
222
+ tenantId,
223
+ projectId
222
224
  },
223
225
  artifactId,
224
226
  toolCallId
@@ -226,8 +228,8 @@ var ArtifactService = class ArtifactService {
226
228
  if (artifacts.length > 0) return this.formatArtifactFullData(artifacts[0], artifactId, toolCallId);
227
229
  artifacts = await getLedgerArtifacts(dbClient_default)({
228
230
  scopes: {
229
- tenantId: this.context.tenantId,
230
- projectId: this.context.projectId
231
+ tenantId,
232
+ projectId
231
233
  },
232
234
  artifactId,
233
235
  taskId: this.context.taskId
@@ -447,8 +449,8 @@ var ArtifactService = class ArtifactService {
447
449
  },
448
450
  schemaFound: false
449
451
  },
450
- tenantId: this.context.tenantId,
451
- projectId: this.context.projectId,
452
+ tenantId: this.context.executionContext.tenantId,
453
+ projectId: this.context.executionContext.projectId,
452
454
  contextId: this.context.contextId,
453
455
  pendingGeneration: true
454
456
  });
@@ -501,6 +503,7 @@ var ArtifactService = class ArtifactService {
501
503
  async saveArtifact(artifact) {
502
504
  let summaryData = artifact.summaryData || artifact.data;
503
505
  let fullData = artifact.data;
506
+ const { tenantId, projectId } = this.context.executionContext;
504
507
  if (this.context.artifactComponents) {
505
508
  const artifactComponent = this.context.artifactComponents.find((ac) => ac.name === artifact.type);
506
509
  if (artifactComponent?.props) try {
@@ -534,8 +537,8 @@ var ArtifactService = class ArtifactService {
534
537
  };
535
538
  const result = await upsertLedgerArtifact(dbClient_default)({
536
539
  scopes: {
537
- tenantId: this.context.tenantId,
538
- projectId: this.context.projectId
540
+ tenantId,
541
+ projectId
539
542
  },
540
543
  contextId: this.context.contextId,
541
544
  taskId: this.context.taskId,
@@ -1,4 +1,4 @@
1
- import { getLogger } from "../logger.js";
1
+ import { getLogger as getLogger$1 } from "../logger.js";
2
2
  import dbClient_default from "../data/db/dbClient.js";
3
3
  import { distillConversation } from "../tools/distill-conversation-tool.js";
4
4
  import { getCompressionConfigForModel } from "../utils/model-context-utils.js";
@@ -9,7 +9,7 @@ import { SpanStatusCode } from "@opentelemetry/api";
9
9
  import { randomUUID } from "crypto";
10
10
 
11
11
  //#region src/services/BaseCompressor.ts
12
- const logger = getLogger("BaseCompressor");
12
+ const logger = getLogger$1("BaseCompressor");
13
13
  /**
14
14
  * Base compressor class containing shared functionality for all compression types
15
15
  */
@@ -1,5 +1,6 @@
1
1
  import { StreamHelper } from "../utils/stream-helpers.js";
2
2
  import { StreamPart } from "./ArtifactParser.js";
3
+ import { FullExecutionContext } from "@inkeep/agents-core";
3
4
 
4
5
  //#region src/services/IncrementalStreamParser.d.ts
5
6
 
@@ -25,10 +26,9 @@ declare class IncrementalStreamParser {
25
26
  private static readonly MAX_SNAPSHOT_SIZE;
26
27
  private static readonly MAX_STREAMED_SIZE;
27
28
  private static readonly MAX_COLLECTED_PARTS;
28
- constructor(streamHelper: StreamHelper, tenantId: string, contextId: string, artifactParserOptions?: {
29
+ constructor(streamHelper: StreamHelper, executionContext: FullExecutionContext, contextId: string, artifactParserOptions?: {
29
30
  sessionId?: string;
30
31
  taskId?: string;
31
- projectId?: string;
32
32
  artifactComponents?: any[];
33
33
  streamRequestId?: string;
34
34
  subAgentId?: string;
@@ -27,7 +27,7 @@ var IncrementalStreamParser = class IncrementalStreamParser {
27
27
  static MAX_SNAPSHOT_SIZE = STREAM_PARSER_MAX_SNAPSHOT_SIZE;
28
28
  static MAX_STREAMED_SIZE = STREAM_PARSER_MAX_STREAMED_SIZE;
29
29
  static MAX_COLLECTED_PARTS = STREAM_PARSER_MAX_COLLECTED_PARTS;
30
- constructor(streamHelper, tenantId, contextId, artifactParserOptions) {
30
+ constructor(streamHelper, executionContext, contextId, artifactParserOptions) {
31
31
  this.streamHelper = streamHelper;
32
32
  this.contextId = contextId;
33
33
  this.subAgentId = artifactParserOptions?.subAgentId;
@@ -42,7 +42,7 @@ var IncrementalStreamParser = class IncrementalStreamParser {
42
42
  if (artifactParserOptions?.streamRequestId && typeof agentSessionManager.getArtifactService === "function") try {
43
43
  sharedArtifactService = agentSessionManager.getArtifactService(artifactParserOptions.streamRequestId);
44
44
  } catch (_error) {}
45
- this.artifactParser = new ArtifactParser(tenantId, {
45
+ this.artifactParser = new ArtifactParser(executionContext, {
46
46
  ...artifactParserOptions,
47
47
  contextId,
48
48
  artifactService: sharedArtifactService
@@ -1,4 +1,4 @@
1
- import { MessageContent } from "@inkeep/agents-core";
1
+ import { FullExecutionContext, MessageContent } from "@inkeep/agents-core";
2
2
 
3
3
  //#region src/services/ResponseFormatter.d.ts
4
4
 
@@ -9,7 +9,7 @@ import { MessageContent } from "@inkeep/agents-core";
9
9
  declare class ResponseFormatter {
10
10
  private artifactParser;
11
11
  private subAgentId?;
12
- constructor(tenantId: string, artifactParserOptions?: {
12
+ constructor(executionContext: FullExecutionContext, artifactParserOptions?: {
13
13
  sessionId?: string;
14
14
  taskId?: string;
15
15
  projectId?: string;
@@ -12,7 +12,7 @@ const logger = getLogger("ResponseFormatter");
12
12
  var ResponseFormatter = class {
13
13
  artifactParser;
14
14
  subAgentId;
15
- constructor(tenantId, artifactParserOptions) {
15
+ constructor(executionContext, artifactParserOptions) {
16
16
  this.subAgentId = artifactParserOptions?.subAgentId;
17
17
  if (artifactParserOptions?.streamRequestId) {
18
18
  const sessionParser = agentSessionManager.getArtifactParser(artifactParserOptions.streamRequestId);
@@ -25,7 +25,7 @@ var ResponseFormatter = class {
25
25
  if (artifactParserOptions?.streamRequestId && typeof agentSessionManager.getArtifactService === "function") try {
26
26
  sharedArtifactService = agentSessionManager.getArtifactService(artifactParserOptions.streamRequestId);
27
27
  } catch (_error) {}
28
- this.artifactParser = new ArtifactParser(tenantId, {
28
+ this.artifactParser = new ArtifactParser(executionContext, {
29
29
  ...artifactParserOptions,
30
30
  artifactService: sharedArtifactService
31
31
  });
@@ -0,0 +1,21 @@
1
+ //#region src/services/evaluationHttpClient.d.ts
2
+ /**
3
+ * HTTP client for triggering evaluations via the eval-api.
4
+ * This avoids importing @inkeep/agents-eval-api directly, which would
5
+ * bundle the workflow code and cause issues on Vercel.
6
+ */
7
+ type TriggerConversationEvaluationParams = {
8
+ tenantId: string;
9
+ projectId: string;
10
+ conversationId: string;
11
+ userId?: string;
12
+ };
13
+ /**
14
+ * Trigger conversation evaluation via HTTP call to eval-api.
15
+ * The eval-api handles ALL evaluation logic: finding run configs, checking sample rates,
16
+ * creating evaluation runs, and executing evaluators.
17
+ * This is a fire-and-forget operation - we don't wait for the evaluation to complete.
18
+ */
19
+ declare function triggerConversationEvaluationHttp(params: TriggerConversationEvaluationParams): Promise<void>;
20
+ //#endregion
21
+ export { triggerConversationEvaluationHttp };
@@ -0,0 +1,48 @@
1
+ import { env } from "../env.js";
2
+ import { getLogger as getLogger$1 } from "../logger.js";
3
+ import { EvalApiClient, InternalServices } from "@inkeep/agents-core";
4
+
5
+ //#region src/services/evaluationHttpClient.ts
6
+ /**
7
+ * HTTP client for triggering evaluations via the eval-api.
8
+ * This avoids importing @inkeep/agents-eval-api directly, which would
9
+ * bundle the workflow code and cause issues on Vercel.
10
+ */
11
+ const logger = getLogger$1("evaluationHttpClient");
12
+ /**
13
+ * Trigger conversation evaluation via HTTP call to eval-api.
14
+ * The eval-api handles ALL evaluation logic: finding run configs, checking sample rates,
15
+ * creating evaluation runs, and executing evaluators.
16
+ * This is a fire-and-forget operation - we don't wait for the evaluation to complete.
17
+ */
18
+ async function triggerConversationEvaluationHttp(params) {
19
+ const evalApiClient = new EvalApiClient({
20
+ apiUrl: env.INKEEP_AGENTS_EVAL_API_URL,
21
+ tenantId: params.tenantId,
22
+ projectId: params.projectId,
23
+ auth: {
24
+ mode: "internalService",
25
+ internalServiceName: InternalServices.INKEEP_AGENTS_RUN_API
26
+ },
27
+ userId: params.userId
28
+ });
29
+ try {
30
+ const response = await evalApiClient.triggerConversationEvaluation({ conversationId: params.conversationId });
31
+ if (!response.success) {
32
+ logger.error({
33
+ error: response.message,
34
+ ...params
35
+ }, "Failed to trigger conversation evaluation via HTTP");
36
+ throw new Error(response.message);
37
+ }
38
+ logger.info({ conversationId: params.conversationId }, "Conversation evaluation triggered via HTTP");
39
+ } catch (error) {
40
+ logger.error({
41
+ error,
42
+ ...params
43
+ }, "Error triggering conversation evaluation via HTTP");
44
+ }
45
+ }
46
+
47
+ //#endregion
48
+ export { triggerConversationEvaluationHttp };
@@ -0,0 +1,6 @@
1
+ import { conversations } from "@inkeep/agents-core";
2
+
3
+ //#region src/services/evaluationRunConfigMatcher.d.ts
4
+ declare function evaluationRunConfigMatchesConversation(runConfig: any, conversation: typeof conversations.$inferSelect): Promise<boolean>;
5
+ //#endregion
6
+ export { evaluationRunConfigMatchesConversation };
@@ -0,0 +1,7 @@
1
+ //#region src/services/evaluationRunConfigMatcher.ts
2
+ async function evaluationRunConfigMatchesConversation(runConfig, conversation) {
3
+ return true;
4
+ }
5
+
6
+ //#endregion
7
+ export { evaluationRunConfigMatchesConversation };
@@ -1,8 +1,8 @@
1
1
  import { getLogger } from "../logger.js";
2
2
  import { FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT, FUNCTION_TOOL_SANDBOX_CLEANUP_INTERVAL_MS, FUNCTION_TOOL_SANDBOX_MAX_OUTPUT_SIZE_BYTES, FUNCTION_TOOL_SANDBOX_MAX_USE_COUNT, FUNCTION_TOOL_SANDBOX_POOL_TTL_MS, FUNCTION_TOOL_SANDBOX_QUEUE_WAIT_TIMEOUT_MS } from "../constants/execution-limits/index.js";
3
3
  import { createExecutionWrapper, parseExecutionResult } from "./sandbox-utils.js";
4
- import { spawn } from "node:child_process";
5
4
  import { createHash } from "node:crypto";
5
+ import { spawn } from "node:child_process";
6
6
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
7
7
  import { tmpdir } from "node:os";
8
8
  import { join } from "node:path";
@@ -1,10 +1,10 @@
1
- import { getLogger } from "../logger.js";
1
+ import { getLogger as getLogger$1 } from "../logger.js";
2
2
  import { ModelFactory } from "@inkeep/agents-core";
3
3
  import { Output, generateText } from "ai";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/tools/distill-conversation-history-tool.ts
7
- const logger = getLogger("distill-conversation-history-tool");
7
+ const logger = getLogger$1("distill-conversation-history-tool");
8
8
  /**
9
9
  * Conversation History Summary Schema - structured object for replacing entire conversation histories
10
10
  */
@@ -1,10 +1,10 @@
1
- import { getLogger } from "../logger.js";
1
+ import { getLogger as getLogger$1 } from "../logger.js";
2
2
  import { ModelFactory } from "@inkeep/agents-core";
3
3
  import { Output, generateText } from "ai";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/tools/distill-conversation-tool.ts
7
- const logger = getLogger("distill-conversation-tool");
7
+ const logger = getLogger$1("distill-conversation-tool");
8
8
  /**
9
9
  * Conversation Summary Schema - structured object for maintaining conversation context
10
10
  */
@@ -1,4 +1,4 @@
1
- import { ExecutionContext } from "@inkeep/agents-core";
1
+ import { BaseExecutionContext, FullExecutionContext } from "@inkeep/agents-core";
2
2
 
3
3
  //#region src/types/execution-context.d.ts
4
4
 
@@ -6,27 +6,21 @@ import { ExecutionContext } from "@inkeep/agents-core";
6
6
  * Extract userId from execution context metadata (when available)
7
7
  * Only available when request originates from an authenticated user session (e.g., playground)
8
8
  */
9
- declare function getUserIdFromContext(ctx: ExecutionContext): string | undefined;
9
+ declare function getUserIdFromContext(ctx: FullExecutionContext): string | undefined;
10
10
  /**
11
11
  * Create execution context from middleware values
12
12
  */
13
- declare function createExecutionContext(params: {
13
+ declare function createBaseExecutionContext(params: {
14
14
  apiKey: string;
15
15
  tenantId: string;
16
16
  projectId: string;
17
17
  agentId: string;
18
18
  apiKeyId: string;
19
- subAgentId?: string;
20
19
  baseUrl?: string;
21
- metadata?: {
22
- teamDelegation?: boolean;
23
- originAgentId?: string;
24
- initiatedBy?: {
25
- type: 'user' | 'api_key';
26
- id: string;
27
- };
28
- };
29
- }): ExecutionContext;
20
+ subAgentId?: string;
21
+ ref?: string;
22
+ metadata?: BaseExecutionContext['metadata'];
23
+ }): BaseExecutionContext;
30
24
  interface CommonSandboxConfig {
31
25
  runtime: 'node22' | 'typescript';
32
26
  timeout?: number;
@@ -43,4 +37,4 @@ interface VercelSandboxConfig extends CommonSandboxConfig {
43
37
  }
44
38
  type SandboxConfig = NativeSandboxConfig | VercelSandboxConfig;
45
39
  //#endregion
46
- export { NativeSandboxConfig, SandboxConfig, VercelSandboxConfig, createExecutionContext, getUserIdFromContext };
40
+ export { NativeSandboxConfig, SandboxConfig, VercelSandboxConfig, createBaseExecutionContext, getUserIdFromContext };
@@ -10,7 +10,7 @@ function getUserIdFromContext(ctx) {
10
10
  /**
11
11
  * Create execution context from middleware values
12
12
  */
13
- function createExecutionContext(params) {
13
+ function createBaseExecutionContext(params) {
14
14
  return {
15
15
  apiKey: params.apiKey,
16
16
  tenantId: params.tenantId,
@@ -19,9 +19,10 @@ function createExecutionContext(params) {
19
19
  baseUrl: params.baseUrl || process.env.API_URL || "http://localhost:3003",
20
20
  apiKeyId: params.apiKeyId,
21
21
  subAgentId: params.subAgentId,
22
+ ref: params.ref,
22
23
  metadata: params.metadata || {}
23
24
  };
24
25
  }
25
26
 
26
27
  //#endregion
27
- export { createExecutionContext, getUserIdFromContext };
28
+ export { createBaseExecutionContext, getUserIdFromContext };
@@ -1,6 +1,6 @@
1
- import { Models, SubAgentSelect } from "@inkeep/agents-core";
1
+ import { FullAgentSubAgentSelectWithRelationIds, FullExecutionContext, Models } from "@inkeep/agents-core";
2
2
 
3
3
  //#region src/utils/model-resolver.d.ts
4
- declare function resolveModelConfig(agentId: string, subAgent: SubAgentSelect): Promise<Models>;
4
+ declare function resolveModelConfig(executionContext: FullExecutionContext, subAgent: FullAgentSubAgentSelectWithRelationIds): Promise<Models>;
5
5
  //#endregion
6
6
  export { resolveModelConfig };