@inkeep/agents-api 0.46.0 → 0.47.0

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 (59) hide show
  1. package/dist/.well-known/workflow/v1/manifest.debug.json +5 -5
  2. package/dist/.well-known/workflow/v1/step.cjs +41 -43
  3. package/dist/createApp.d.ts +2 -2
  4. package/dist/createApp.js +1 -3
  5. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  6. package/dist/domains/evals/routes/index.d.ts +2 -2
  7. package/dist/domains/evals/services/EvaluationService.js +1 -2
  8. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  9. package/dist/domains/manage/index.js +4 -2
  10. package/dist/domains/manage/routes/availableAgents.d.ts +2 -2
  11. package/dist/domains/manage/routes/availableAgents.js +2 -2
  12. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  13. package/dist/domains/manage/routes/index.d.ts +2 -2
  14. package/dist/domains/manage/routes/invitations.d.ts +2 -2
  15. package/dist/domains/manage/routes/invitations.js +59 -0
  16. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  17. package/dist/domains/manage/routes/{userOrganizations.d.ts → passwordResetLinks.d.ts} +3 -3
  18. package/dist/domains/manage/routes/passwordResetLinks.js +61 -0
  19. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  20. package/dist/domains/manage/routes/users.d.ts +10 -0
  21. package/dist/domains/manage/routes/users.js +78 -0
  22. package/dist/domains/mcp/routes/mcp.d.ts +2 -2
  23. package/dist/domains/run/a2a/client.d.ts +0 -2
  24. package/dist/domains/run/a2a/client.js +5 -7
  25. package/dist/domains/run/agents/Agent.d.ts +41 -15
  26. package/dist/domains/run/agents/Agent.js +127 -281
  27. package/dist/domains/run/agents/generateTaskHandler.js +10 -5
  28. package/dist/domains/run/agents/relationTools.d.ts +2 -2
  29. package/dist/domains/run/agents/relationTools.js +1 -3
  30. package/dist/domains/run/agents/types.d.ts +2 -1
  31. package/dist/domains/run/agents/versions/v1/{Phase1Config.d.ts → PromptConfig.d.ts} +5 -4
  32. package/dist/domains/run/agents/versions/v1/{Phase1Config.js → PromptConfig.js} +36 -19
  33. package/dist/domains/run/handlers/executionHandler.js +8 -12
  34. package/dist/domains/run/utils/token-estimator.d.ts +2 -2
  35. package/dist/factory.d.ts +59 -25
  36. package/dist/index.d.ts +128 -94
  37. package/dist/middleware/evalsAuth.d.ts +2 -2
  38. package/dist/middleware/manageAuth.d.ts +2 -2
  39. package/dist/middleware/projectAccess.d.ts +2 -2
  40. package/dist/middleware/projectConfig.d.ts +3 -3
  41. package/dist/middleware/requirePermission.d.ts +2 -2
  42. package/dist/middleware/runAuth.d.ts +4 -4
  43. package/dist/middleware/sessionAuth.d.ts +3 -3
  44. package/dist/middleware/tenantAccess.d.ts +2 -2
  45. package/dist/middleware/tracing.d.ts +3 -3
  46. package/dist/templates/v1/prompt/system-prompt.js +5 -0
  47. package/dist/templates/v1/{phase1 → prompt}/tool.js +1 -1
  48. package/dist/templates/v1/shared/artifact-retrieval-guidance.js +1 -1
  49. package/dist/templates/v1/{phase2 → shared}/data-component.js +1 -1
  50. package/dist/templates/v1/{phase2 → shared}/data-components.js +1 -1
  51. package/package.json +6 -6
  52. package/dist/domains/manage/routes/userOrganizations.js +0 -29
  53. package/dist/domains/run/agents/versions/v1/Phase2Config.d.ts +0 -33
  54. package/dist/domains/run/agents/versions/v1/Phase2Config.js +0 -341
  55. package/dist/templates/v1/phase1/system-prompt.js +0 -5
  56. package/dist/templates/v1/phase1/thinking-preparation.js +0 -5
  57. package/dist/templates/v1/phase2/system-prompt.js +0 -5
  58. package/dist/utils/in-process-fetch.d.ts +0 -22
  59. package/dist/utils/in-process-fetch.js +0 -32
@@ -82,7 +82,6 @@ var A2AClient = class {
82
82
  requestIdCounter = 1;
83
83
  serviceEndpointUrl;
84
84
  options;
85
- fetchFn;
86
85
  /**
87
86
  * Constructs an A2AClient instance.
88
87
  * It initiates fetching the agent card from the provided agent baseUrl.
@@ -93,7 +92,6 @@ var A2AClient = class {
93
92
  */
94
93
  constructor(agentBaseUrl, options) {
95
94
  this.agentBaseUrl = agentBaseUrl.replace(/\/$/, "");
96
- this.fetchFn = options?.fetchFn ?? fetch;
97
95
  this.options = {
98
96
  retryConfig: {
99
97
  strategy: "backoff",
@@ -119,7 +117,7 @@ var A2AClient = class {
119
117
  agentBaseUrl: this.agentBaseUrl
120
118
  }, "agentCardUrl");
121
119
  try {
122
- const response = await this.fetchFn(url.toString(), { headers: {
120
+ const response = await fetch(url.toString(), { headers: {
123
121
  Accept: "application/json",
124
122
  ...this.options.headers || {}
125
123
  } });
@@ -146,7 +144,7 @@ var A2AClient = class {
146
144
  const agentCardUrl = `${agentBaseUrl.replace(/\/$/, "")}/.well-known/agent.json`;
147
145
  const url = new URL(agentCardUrl);
148
146
  if (this.options.ref) url.searchParams.set("ref", this.options.ref.name);
149
- const response = await this.fetchFn(url.toString(), { headers: {
147
+ const response = await fetch(url.toString(), { headers: {
150
148
  Accept: "application/json",
151
149
  ...this.options.headers || {}
152
150
  } });
@@ -286,7 +284,7 @@ var A2AClient = class {
286
284
  id: requestId
287
285
  };
288
286
  const httpResponse = await this.retry(async () => {
289
- return this.fetchFn(endpoint, {
287
+ return fetch(endpoint, {
290
288
  method: "POST",
291
289
  headers: {
292
290
  "Content-Type": "application/json",
@@ -349,7 +347,7 @@ var A2AClient = class {
349
347
  params,
350
348
  id: clientRequestId
351
349
  };
352
- const response = await this.fetchFn(endpoint, {
350
+ const response = await fetch(endpoint, {
353
351
  method: "POST",
354
352
  headers: {
355
353
  "Content-Type": "application/json",
@@ -424,7 +422,7 @@ var A2AClient = class {
424
422
  params,
425
423
  id: clientRequestId
426
424
  };
427
- const response = await this.fetchFn(endpoint, {
425
+ const response = await fetch(endpoint, {
428
426
  method: "POST",
429
427
  headers: {
430
428
  "Content-Type": "application/json",
@@ -1,7 +1,7 @@
1
1
  import { SandboxConfig } from "../types/executionContext.js";
2
2
  import { StreamHelper } from "../utils/stream-helpers.js";
3
- import { AgentConversationHistoryConfig, Artifact, ArtifactComponentApiInsert, CredentialStoreRegistry, DataComponentApiInsert, FullExecutionContext, McpTool, Models, ResolvedRef, SubAgentStopWhen } from "@inkeep/agents-core";
4
- import { ToolSet } from "ai";
3
+ import { AgentConversationHistoryConfig, Artifact, ArtifactComponentApiInsert, CredentialStoreRegistry, DataComponentApiInsert, FullExecutionContext, McpTool, MessageContent, Models, ResolvedRef, SubAgentStopWhen } from "@inkeep/agents-core";
4
+ import { FinishReason, StepResult, ToolSet } from "ai";
5
5
 
6
6
  //#region src/domains/run/agents/Agent.d.ts
7
7
 
@@ -15,6 +15,40 @@ declare function hasToolCallWithPrefix(prefix: string): ({
15
15
  }: {
16
16
  steps: Array<any>;
17
17
  }) => any;
18
+ /**
19
+ * Shape of a generation response after all Promise-based getters have been resolved.
20
+ *
21
+ * The AI SDK's `GenerateTextResult` and `StreamTextResult` classes expose properties
22
+ * like `text`, `steps`, `finishReason`, and `output` as **prototype getters** — not
23
+ * own enumerable properties. When one of these class instances is spread with `{ ...result }`,
24
+ * the spread operator copies only own enumerable properties and silently drops the getters,
25
+ * causing those fields to become `undefined` on the resulting plain object.
26
+ *
27
+ * This type represents the safely-resolved plain object produced by
28
+ * `resolveGenerationResponse`, where every needed getter has been awaited and
29
+ * assigned as a concrete own property.
30
+ */
31
+ interface ResolvedGenerationResponse {
32
+ steps: Array<StepResult<ToolSet>>;
33
+ text: string;
34
+ finishReason: FinishReason;
35
+ output?: any;
36
+ object?: any;
37
+ formattedContent?: MessageContent | null;
38
+ }
39
+ /**
40
+ * Resolves a generation response from either `generateText` or `streamText` into
41
+ * a plain object with all needed values as own properties.
42
+ *
43
+ * **Why this exists:** The AI SDK returns class instances whose key properties
44
+ * (`text`, `steps`, `finishReason`, `output`) are prototype getters.
45
+ * `StreamTextResult` getters return `PromiseLike` values; `GenerateTextResult`
46
+ * getters return direct values. In both cases, the spread operator `{ ...result }`
47
+ * silently drops them. This function uses `Promise.resolve()` to safely resolve
48
+ * both styles, then spreads them as explicit own properties so downstream code
49
+ * (and further spreads) never loses them.
50
+ */
51
+ declare function resolveGenerationResponse(response: Record<string, unknown>): Promise<ResolvedGenerationResponse>;
18
52
  type AgentConfig = {
19
53
  id: string;
20
54
  tenantId: string;
@@ -112,7 +146,7 @@ declare class Agent {
112
146
  */
113
147
  private sanitizeToolsForAISDK;
114
148
  /**
115
- * Get the primary model settings for text generation and thinking
149
+ * Get the primary model settings for text generation
116
150
  * Requires model to be configured at project level
117
151
  */
118
152
  private getPrimaryModel;
@@ -186,14 +220,11 @@ declare class Agent {
186
220
  */
187
221
  private hasAgentArtifactComponents;
188
222
  /**
189
- * Build adaptive system prompt for Phase 2 structured output generation
190
- * based on configured data components and artifact components across the agent
223
+ * Get the client's current time formatted in their timezone
191
224
  */
192
225
  private getClientCurrentTime;
193
- private buildPhase2SystemPrompt;
194
226
  private buildSystemPrompt;
195
227
  private getArtifactTools;
196
- private createThinkingCompleteTool;
197
228
  private getDefaultTools;
198
229
  private getStreamRequestId;
199
230
  private applyToolOverrides;
@@ -221,7 +252,7 @@ declare class Agent {
221
252
  streamRequestId: string;
222
253
  apiKey?: string;
223
254
  };
224
- }): Promise<any>;
255
+ }): Promise<ResolvedGenerationResponse>;
225
256
  /**
226
257
  * Setup generation context and initialize streaming helper
227
258
  */
@@ -254,12 +285,7 @@ declare class Agent {
254
285
  private setupStreamParser;
255
286
  private buildTelemetryConfig;
256
287
  private buildBaseGenerationConfig;
257
- private buildReasoningFlow;
258
288
  private buildDataComponentsSchema;
259
- private calculatePhase2Timeout;
260
- private buildPhase2Messages;
261
- private executeStreamingPhase2;
262
- private executeNonStreamingPhase2;
263
289
  private formatFinalResponse;
264
290
  private handleGenerationError;
265
291
  /**
@@ -267,8 +293,8 @@ declare class Agent {
267
293
  * Performs full cleanup of compression state when agent/session is ending
268
294
  */
269
295
  cleanupCompression(): void;
296
+ private handleStreamGeneration;
270
297
  private processStreamEvents;
271
- private formatStreamingResponse;
272
298
  }
273
299
  //#endregion
274
- export { Agent, AgentConfig, DelegateRelation, ExternalAgentRelationConfig, TeamAgentRelationConfig, ToolType, hasToolCallWithPrefix };
300
+ export { Agent, AgentConfig, DelegateRelation, ExternalAgentRelationConfig, ResolvedGenerationResponse, TeamAgentRelationConfig, ToolType, hasToolCallWithPrefix, resolveGenerationResponse };