@inkeep/agents-run-api 0.0.0-dev-20251222193909 → 0.0.0-dev-20251222215156

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 (173) hide show
  1. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/phase1/system-prompt.js +5 -0
  2. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/phase1/thinking-preparation.js +5 -0
  3. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/phase1/tool.js +5 -0
  4. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/phase2/data-component.js +5 -0
  5. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/phase2/data-components.js +5 -0
  6. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/phase2/system-prompt.js +5 -0
  7. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/shared/artifact-retrieval-guidance.js +5 -0
  8. package/dist/_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/shared/artifact.js +5 -0
  9. package/dist/a2a/client.d.ts +184 -0
  10. package/dist/a2a/client.js +510 -0
  11. package/dist/a2a/handlers.d.ts +7 -0
  12. package/dist/a2a/handlers.js +559 -0
  13. package/dist/a2a/transfer.d.ts +22 -0
  14. package/dist/a2a/transfer.js +46 -0
  15. package/dist/a2a/types.d.ts +79 -0
  16. package/dist/a2a/types.js +22 -0
  17. package/dist/agents/Agent.d.ts +220 -0
  18. package/dist/agents/Agent.js +1938 -0
  19. package/dist/agents/ModelFactory.d.ts +63 -0
  20. package/dist/agents/ModelFactory.js +194 -0
  21. package/dist/agents/SystemPromptBuilder.d.ts +21 -0
  22. package/dist/agents/SystemPromptBuilder.js +48 -0
  23. package/dist/agents/ToolSessionManager.d.ts +63 -0
  24. package/dist/agents/ToolSessionManager.js +146 -0
  25. package/dist/agents/generateTaskHandler.d.ts +49 -0
  26. package/dist/agents/generateTaskHandler.js +512 -0
  27. package/dist/agents/relationTools.d.ts +57 -0
  28. package/dist/agents/relationTools.js +262 -0
  29. package/dist/agents/types.d.ts +28 -0
  30. package/dist/agents/types.js +1 -0
  31. package/dist/agents/versions/v1/Phase1Config.d.ts +26 -0
  32. package/dist/agents/versions/v1/Phase1Config.js +413 -0
  33. package/dist/agents/versions/v1/Phase2Config.d.ts +31 -0
  34. package/dist/agents/versions/v1/Phase2Config.js +330 -0
  35. package/dist/constants/execution-limits/defaults.d.ts +47 -0
  36. package/dist/constants/execution-limits/defaults.js +48 -0
  37. package/dist/constants/execution-limits/index.d.ts +6 -0
  38. package/dist/constants/execution-limits/index.js +16 -0
  39. package/dist/create-app.d.ts +9 -0
  40. package/dist/create-app.js +195 -0
  41. package/dist/data/agent.d.ts +7 -0
  42. package/dist/data/agent.js +72 -0
  43. package/dist/data/agents.d.ts +34 -0
  44. package/dist/data/agents.js +139 -0
  45. package/dist/data/conversations.d.ts +88 -0
  46. package/dist/{conversations2.js → data/conversations.js} +42 -7
  47. package/dist/data/db/dbClient.d.ts +6 -0
  48. package/dist/data/db/dbClient.js +17 -0
  49. package/dist/env.d.ts +57 -0
  50. package/dist/env.js +1 -2
  51. package/dist/handlers/executionHandler.d.ts +39 -0
  52. package/dist/handlers/executionHandler.js +456 -0
  53. package/dist/index.d.ts +8 -29
  54. package/dist/index.js +5 -11487
  55. package/dist/instrumentation.d.ts +1 -2
  56. package/dist/instrumentation.js +66 -3
  57. package/dist/{logger2.js → logger.d.ts} +1 -2
  58. package/dist/logger.js +1 -1
  59. package/dist/middleware/api-key-auth.d.ts +26 -0
  60. package/dist/middleware/api-key-auth.js +240 -0
  61. package/dist/middleware/index.d.ts +2 -0
  62. package/dist/middleware/index.js +3 -0
  63. package/dist/openapi.d.ts +4 -0
  64. package/dist/openapi.js +54 -0
  65. package/dist/routes/agents.d.ts +12 -0
  66. package/dist/routes/agents.js +147 -0
  67. package/dist/routes/chat.d.ts +13 -0
  68. package/dist/routes/chat.js +293 -0
  69. package/dist/routes/chatDataStream.d.ts +13 -0
  70. package/dist/routes/chatDataStream.js +352 -0
  71. package/dist/routes/mcp.d.ts +13 -0
  72. package/dist/routes/mcp.js +495 -0
  73. package/dist/services/AgentSession.d.ts +356 -0
  74. package/dist/services/AgentSession.js +1208 -0
  75. package/dist/services/ArtifactParser.d.ts +105 -0
  76. package/dist/services/ArtifactParser.js +338 -0
  77. package/dist/services/ArtifactService.d.ts +123 -0
  78. package/dist/services/ArtifactService.js +611 -0
  79. package/dist/services/IncrementalStreamParser.d.ts +98 -0
  80. package/dist/services/IncrementalStreamParser.js +327 -0
  81. package/dist/services/MidGenerationCompressor.d.ts +91 -0
  82. package/dist/services/MidGenerationCompressor.js +375 -0
  83. package/dist/services/PendingToolApprovalManager.d.ts +62 -0
  84. package/dist/services/PendingToolApprovalManager.js +133 -0
  85. package/dist/services/ResponseFormatter.d.ts +39 -0
  86. package/dist/services/ResponseFormatter.js +152 -0
  87. package/dist/tools/NativeSandboxExecutor.d.ts +38 -0
  88. package/dist/tools/NativeSandboxExecutor.js +432 -0
  89. package/dist/tools/SandboxExecutorFactory.d.ts +36 -0
  90. package/dist/tools/SandboxExecutorFactory.js +80 -0
  91. package/dist/tools/VercelSandboxExecutor.d.ts +71 -0
  92. package/dist/tools/VercelSandboxExecutor.js +340 -0
  93. package/dist/tools/distill-conversation-tool.d.ts +41 -0
  94. package/dist/tools/distill-conversation-tool.js +156 -0
  95. package/dist/tools/sandbox-utils.d.ts +18 -0
  96. package/dist/tools/sandbox-utils.js +53 -0
  97. package/dist/types/chat.d.ts +27 -0
  98. package/dist/types/chat.js +1 -0
  99. package/dist/types/execution-context.d.ts +46 -0
  100. package/dist/types/execution-context.js +27 -0
  101. package/dist/types/xml.d.ts +5 -0
  102. package/dist/utils/SchemaProcessor.d.ts +52 -0
  103. package/dist/utils/SchemaProcessor.js +182 -0
  104. package/dist/utils/agent-operations.d.ts +62 -0
  105. package/dist/utils/agent-operations.js +53 -0
  106. package/dist/utils/artifact-component-schema.d.ts +42 -0
  107. package/dist/utils/artifact-component-schema.js +186 -0
  108. package/dist/utils/cleanup.d.ts +21 -0
  109. package/dist/utils/cleanup.js +59 -0
  110. package/dist/utils/data-component-schema.d.ts +2 -0
  111. package/dist/utils/data-component-schema.js +3 -0
  112. package/dist/utils/default-status-schemas.d.ts +20 -0
  113. package/dist/utils/default-status-schemas.js +24 -0
  114. package/dist/utils/json-postprocessor.d.ts +13 -0
  115. package/dist/{json-postprocessor.cjs → utils/json-postprocessor.js} +1 -2
  116. package/dist/utils/model-context-utils.d.ts +31 -0
  117. package/dist/utils/model-context-utils.js +149 -0
  118. package/dist/utils/model-resolver.d.ts +6 -0
  119. package/dist/utils/model-resolver.js +34 -0
  120. package/dist/utils/schema-validation.d.ts +44 -0
  121. package/dist/utils/schema-validation.js +97 -0
  122. package/dist/utils/stream-helpers.d.ts +197 -0
  123. package/dist/utils/stream-helpers.js +518 -0
  124. package/dist/utils/stream-registry.d.ts +22 -0
  125. package/dist/utils/stream-registry.js +34 -0
  126. package/dist/utils/token-estimator.d.ts +69 -0
  127. package/dist/utils/token-estimator.js +53 -0
  128. package/dist/utils/tracer.d.ts +7 -0
  129. package/dist/utils/tracer.js +7 -0
  130. package/package.json +4 -20
  131. package/dist/SandboxExecutorFactory.cjs +0 -895
  132. package/dist/SandboxExecutorFactory.js +0 -893
  133. package/dist/SandboxExecutorFactory.js.map +0 -1
  134. package/dist/chunk-VBDAOXYI.cjs +0 -927
  135. package/dist/chunk-VBDAOXYI.js +0 -832
  136. package/dist/chunk-VBDAOXYI.js.map +0 -1
  137. package/dist/chunk.cjs +0 -34
  138. package/dist/conversations.cjs +0 -7
  139. package/dist/conversations.js +0 -7
  140. package/dist/conversations2.cjs +0 -209
  141. package/dist/conversations2.js.map +0 -1
  142. package/dist/dbClient.cjs +0 -9676
  143. package/dist/dbClient.js +0 -9670
  144. package/dist/dbClient.js.map +0 -1
  145. package/dist/dbClient2.cjs +0 -5
  146. package/dist/dbClient2.js +0 -5
  147. package/dist/env.cjs +0 -59
  148. package/dist/env.js.map +0 -1
  149. package/dist/execution-limits.cjs +0 -260
  150. package/dist/execution-limits.js +0 -63
  151. package/dist/execution-limits.js.map +0 -1
  152. package/dist/index.cjs +0 -11512
  153. package/dist/index.d.cts +0 -36
  154. package/dist/index.d.cts.map +0 -1
  155. package/dist/index.d.ts.map +0 -1
  156. package/dist/index.js.map +0 -1
  157. package/dist/instrumentation.cjs +0 -12
  158. package/dist/instrumentation.d.cts +0 -18
  159. package/dist/instrumentation.d.cts.map +0 -1
  160. package/dist/instrumentation.d.ts.map +0 -1
  161. package/dist/instrumentation2.cjs +0 -116
  162. package/dist/instrumentation2.js +0 -69
  163. package/dist/instrumentation2.js.map +0 -1
  164. package/dist/json-postprocessor.js +0 -20
  165. package/dist/json-postprocessor.js.map +0 -1
  166. package/dist/logger.cjs +0 -5
  167. package/dist/logger2.cjs +0 -1
  168. package/dist/nodefs.cjs +0 -29
  169. package/dist/nodefs.js +0 -27
  170. package/dist/nodefs.js.map +0 -1
  171. package/dist/opfs-ahp.cjs +0 -367
  172. package/dist/opfs-ahp.js +0 -368
  173. package/dist/opfs-ahp.js.map +0 -1
@@ -0,0 +1,22 @@
1
+ //#region src/a2a/types.ts
2
+ /**
3
+ * Type guard to check if a Task contains transfer data
4
+ */
5
+ function isTransferTask(result) {
6
+ if (!("artifacts" in result) || !result.artifacts) return false;
7
+ return result.artifacts.some((artifact) => artifact.parts.some((part) => {
8
+ if (part.kind !== "data" || !part.data) return false;
9
+ return typeof part.data === "object" && "type" in part.data && part.data.type === "transfer";
10
+ }));
11
+ }
12
+ /**
13
+ * Helper to safely extract transfer data from a TransferTask
14
+ * Returns null if no transfer data found
15
+ */
16
+ function extractTransferData(task) {
17
+ for (const artifact of task.artifacts) for (const part of artifact.parts) if (part.kind === "data" && part.data?.type === "transfer") return part.data;
18
+ return null;
19
+ }
20
+
21
+ //#endregion
22
+ export { extractTransferData, isTransferTask };
@@ -0,0 +1,220 @@
1
+ import { SandboxConfig } from "../types/execution-context.js";
2
+ import { StreamHelper } from "../utils/stream-helpers.js";
3
+ import { AgentConversationHistoryConfig, Artifact, ArtifactComponentApiInsert, CredentialStoreRegistry, DataComponentApiInsert, McpTool, Models, SubAgentStopWhen } from "@inkeep/agents-core";
4
+ import { ToolSet } from "ai";
5
+
6
+ //#region src/agents/Agent.d.ts
7
+
8
+ /**
9
+ * Creates a stopWhen condition that stops when any tool call name starts with the given prefix
10
+ * @param prefix - The prefix to check for in tool call names
11
+ * @returns A function that can be used as a stopWhen condition
12
+ */
13
+ declare function hasToolCallWithPrefix(prefix: string): ({
14
+ steps
15
+ }: {
16
+ steps: Array<any>;
17
+ }) => any;
18
+ type AgentConfig = {
19
+ id: string;
20
+ tenantId: string;
21
+ projectId: string;
22
+ agentId: string;
23
+ relationId?: string;
24
+ baseUrl: string;
25
+ apiKey?: string;
26
+ apiKeyId?: string;
27
+ name: string;
28
+ description?: string;
29
+ prompt?: string;
30
+ subAgentRelations: AgentConfig[];
31
+ transferRelations: AgentConfig[];
32
+ delegateRelations: DelegateRelation[];
33
+ tools?: McpTool[];
34
+ artifacts?: Record<string, Artifact>;
35
+ functionTools?: Array<{
36
+ name: string;
37
+ description: string;
38
+ execute: (params: any) => Promise<any>;
39
+ parameters?: Record<string, any>;
40
+ schema?: any;
41
+ }>;
42
+ contextConfigId?: string;
43
+ dataComponents?: DataComponentApiInsert[];
44
+ artifactComponents?: ArtifactComponentApiInsert[];
45
+ conversationHistoryConfig?: AgentConversationHistoryConfig;
46
+ models?: Models;
47
+ stopWhen?: SubAgentStopWhen;
48
+ sandboxConfig?: SandboxConfig;
49
+ /** User ID for user-scoped credential lookup (from temp JWT) */
50
+ userId?: string;
51
+ };
52
+ type ExternalAgentRelationConfig = {
53
+ relationId: string;
54
+ id: string;
55
+ name: string;
56
+ description: string;
57
+ baseUrl: string;
58
+ credentialReferenceId?: string | null;
59
+ headers?: Record<string, string> | null;
60
+ relationType: string;
61
+ };
62
+ type TeamAgentRelationConfig = {
63
+ relationId: string;
64
+ id: string;
65
+ name: string;
66
+ description: string;
67
+ baseUrl: string;
68
+ headers?: Record<string, string> | null;
69
+ };
70
+ type DelegateRelation = {
71
+ type: 'internal';
72
+ config: AgentConfig;
73
+ } | {
74
+ type: 'external';
75
+ config: ExternalAgentRelationConfig;
76
+ } | {
77
+ type: 'team';
78
+ config: TeamAgentRelationConfig;
79
+ };
80
+ type ToolType = 'transfer' | 'delegation' | 'mcp' | 'tool';
81
+ declare class Agent {
82
+ #private;
83
+ private config;
84
+ private systemPromptBuilder;
85
+ private credentialStuffer?;
86
+ private streamHelper?;
87
+ private streamRequestId?;
88
+ private conversationId?;
89
+ private delegationId?;
90
+ private artifactComponents;
91
+ private isDelegatedAgent;
92
+ private contextResolver?;
93
+ private credentialStoreRegistry?;
94
+ private mcpClientCache;
95
+ private mcpConnectionLocks;
96
+ private currentCompressor;
97
+ constructor(config: AgentConfig, credentialStoreRegistry?: CredentialStoreRegistry);
98
+ /**
99
+ * Get the maximum number of generation steps for this agent
100
+ * Uses agent's stopWhen.stepCountIs config or defaults to AGENT_EXECUTION_MAX_GENERATION_STEPS
101
+ */
102
+ private getMaxGenerationSteps;
103
+ /**
104
+ * Sanitizes tool names at runtime for AI SDK compatibility.
105
+ * The AI SDK requires tool names to match pattern ^[a-zA-Z0-9_-]{1,128}$
106
+ */
107
+ private sanitizeToolsForAISDK;
108
+ /**
109
+ * Get the primary model settings for text generation and thinking
110
+ * Requires model to be configured at project level
111
+ */
112
+ private getPrimaryModel;
113
+ /**
114
+ * Get the model settings for structured output generation
115
+ * Falls back to base model if structured output not configured
116
+ */
117
+ private getStructuredOutputModel;
118
+ /**
119
+ * Get the model settings for summarization/distillation
120
+ * Falls back to base model if summarizer not configured
121
+ */
122
+ private getSummarizerModel;
123
+ setConversationId(conversationId: string): void;
124
+ /**
125
+ * Simple compression fallback: drop oldest messages to fit under token limit
126
+ */
127
+ private simpleCompression;
128
+ /**
129
+ * Set delegation status for this agent instance
130
+ */
131
+ setDelegationStatus(isDelegated: boolean): void;
132
+ /**
133
+ * Set delegation ID for this agent instance
134
+ */
135
+ setDelegationId(delegationId: string | undefined): void;
136
+ /**
137
+ * Get streaming helper if this agent should stream to user
138
+ * Returns undefined for delegated agents to prevent streaming data operations to user
139
+ */
140
+ getStreamingHelper(): StreamHelper | undefined;
141
+ /**
142
+ * Wraps a tool with streaming lifecycle tracking (start, complete, error) and AgentSession recording
143
+ */
144
+ private wrapToolWithStreaming;
145
+ getRelationTools(runtimeContext?: {
146
+ contextId: string;
147
+ metadata: {
148
+ conversationId: string;
149
+ threadId: string;
150
+ streamRequestId?: string;
151
+ streamBaseUrl?: string;
152
+ apiKey?: string;
153
+ baseUrl?: string;
154
+ };
155
+ }, sessionId?: string): any;
156
+ getMcpTools(sessionId?: string, streamRequestId?: string): Promise<ToolSet>;
157
+ /**
158
+ * Convert database McpTool to builder MCPToolConfig format
159
+ */
160
+ private convertToMCPToolConfig;
161
+ getMcpTool(tool: McpTool): Promise<{
162
+ tools: Record<string, any>;
163
+ toolPolicies: Record<string, {
164
+ needsApproval?: boolean;
165
+ }>;
166
+ mcpServerId: string;
167
+ mcpServerName: string;
168
+ }>;
169
+ private createMcpConnection;
170
+ getFunctionTools(sessionId?: string, streamRequestId?: string): Promise<ToolSet>;
171
+ /**
172
+ * Get resolved context using ContextResolver - will return cached data or fetch fresh data as needed
173
+ */
174
+ getResolvedContext(conversationId: string, headers?: Record<string, unknown>): Promise<Record<string, unknown> | null>;
175
+ /**
176
+ * Get the agent prompt for this agent's agent
177
+ */
178
+ private getPrompt;
179
+ /**
180
+ * Check if any agent in the agent has artifact components configured
181
+ */
182
+ private hasAgentArtifactComponents;
183
+ /**
184
+ * Build adaptive system prompt for Phase 2 structured output generation
185
+ * based on configured data components and artifact components across the agent
186
+ */
187
+ private buildPhase2SystemPrompt;
188
+ private buildSystemPrompt;
189
+ private getArtifactTools;
190
+ private createThinkingCompleteTool;
191
+ private getDefaultTools;
192
+ private getStreamRequestId;
193
+ /**
194
+ * Format tool result for storage in conversation history
195
+ */
196
+ private formatToolResult;
197
+ /**
198
+ * Get the conversation ID for storing tool results
199
+ * Always uses the real conversation ID - delegation filtering happens at query time
200
+ */
201
+ private getToolResultConversationId;
202
+ /**
203
+ * Analyze tool result structure and add helpful path hints for artifact creation
204
+ * Only adds hints when artifact components are available
205
+ */
206
+ private enhanceToolResultWithStructureHints;
207
+ private agentHasArtifactComponents;
208
+ generate(userMessage: string, runtimeContext?: {
209
+ contextId: string;
210
+ metadata: {
211
+ conversationId: string;
212
+ threadId: string;
213
+ taskId: string;
214
+ streamRequestId: string;
215
+ apiKey?: string;
216
+ };
217
+ }): Promise<any>;
218
+ }
219
+ //#endregion
220
+ export { Agent, AgentConfig, DelegateRelation, ExternalAgentRelationConfig, TeamAgentRelationConfig, ToolType, hasToolCallWithPrefix };