@inkeep/agents-api 0.45.3 → 0.46.1

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 (53) hide show
  1. package/dist/.well-known/workflow/v1/flow.cjs +44 -44
  2. package/dist/.well-known/workflow/v1/flow.cjs.debug.json +2 -2
  3. package/dist/.well-known/workflow/v1/manifest.debug.json +14 -14
  4. package/dist/.well-known/workflow/v1/step.cjs +166 -158
  5. package/dist/.well-known/workflow/v1/step.cjs.debug.json +2 -2
  6. package/dist/createApp.d.ts +2 -2
  7. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  8. package/dist/domains/evals/routes/index.d.ts +2 -2
  9. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  10. package/dist/domains/manage/index.js +4 -2
  11. package/dist/domains/manage/routes/availableAgents.d.ts +2 -2
  12. package/dist/domains/manage/routes/availableAgents.js +2 -2
  13. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  14. package/dist/domains/manage/routes/index.d.ts +2 -2
  15. package/dist/domains/manage/routes/invitations.d.ts +2 -2
  16. package/dist/domains/manage/routes/invitations.js +59 -0
  17. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  18. package/dist/domains/manage/routes/passwordResetLinks.d.ts +10 -0
  19. package/dist/domains/manage/routes/passwordResetLinks.js +61 -0
  20. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  21. package/dist/domains/manage/routes/users.d.ts +10 -0
  22. package/dist/domains/manage/routes/users.js +78 -0
  23. package/dist/domains/mcp/routes/mcp.d.ts +2 -2
  24. package/dist/domains/run/agents/Agent.d.ts +41 -15
  25. package/dist/domains/run/agents/Agent.js +127 -281
  26. package/dist/domains/run/agents/generateTaskHandler.js +10 -5
  27. package/dist/domains/run/agents/types.d.ts +2 -1
  28. package/dist/domains/run/agents/versions/v1/{Phase1Config.d.ts → PromptConfig.d.ts} +5 -4
  29. package/dist/domains/run/agents/versions/v1/{Phase1Config.js → PromptConfig.js} +36 -19
  30. package/dist/factory.d.ts +58 -24
  31. package/dist/index.d.ts +128 -94
  32. package/dist/middleware/evalsAuth.d.ts +2 -2
  33. package/dist/middleware/manageAuth.d.ts +2 -2
  34. package/dist/middleware/projectAccess.d.ts +2 -2
  35. package/dist/middleware/projectConfig.d.ts +3 -3
  36. package/dist/middleware/requirePermission.d.ts +2 -2
  37. package/dist/middleware/runAuth.d.ts +4 -4
  38. package/dist/middleware/sessionAuth.d.ts +3 -3
  39. package/dist/middleware/tenantAccess.d.ts +2 -2
  40. package/dist/middleware/tracing.d.ts +3 -3
  41. package/dist/templates/v1/prompt/system-prompt.js +5 -0
  42. package/dist/templates/v1/{phase1 → prompt}/tool.js +1 -1
  43. package/dist/templates/v1/shared/artifact-retrieval-guidance.js +1 -1
  44. package/dist/templates/v1/{phase2 → shared}/data-component.js +1 -1
  45. package/dist/templates/v1/{phase2 → shared}/data-components.js +1 -1
  46. package/package.json +5 -5
  47. package/dist/domains/manage/routes/userOrganizations.d.ts +0 -10
  48. package/dist/domains/manage/routes/userOrganizations.js +0 -29
  49. package/dist/domains/run/agents/versions/v1/Phase2Config.d.ts +0 -33
  50. package/dist/domains/run/agents/versions/v1/Phase2Config.js +0 -341
  51. package/dist/templates/v1/phase1/system-prompt.js +0 -5
  52. package/dist/templates/v1/phase1/thinking-preparation.js +0 -5
  53. package/dist/templates/v1/phase2/system-prompt.js +0 -5
@@ -1,10 +1,10 @@
1
1
  import { AppConfig } from "./types/app.js";
2
2
  import "./types/index.js";
3
3
  import { Hono } from "hono";
4
- import * as hono_types3 from "hono/types";
4
+ import * as hono_types0 from "hono/types";
5
5
 
6
6
  //#region src/createApp.d.ts
7
7
  declare const isWebhookRoute: (path: string) => boolean;
8
- declare function createAgentsHono(config: AppConfig): Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
8
+ declare function createAgentsHono(config: AppConfig): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { createAgentsHono, isWebhookRoute };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono16 from "hono";
2
+ import * as hono15 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/datasetTriggers.d.ts
5
- declare const app: OpenAPIHono<hono16.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono15.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono18 from "hono";
2
+ import * as hono16 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono18.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono16.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types12 from "hono/types";
2
+ import * as hono_types9 from "hono/types";
3
3
 
4
4
  //#region src/domains/evals/workflow/routes.d.ts
5
- declare const workflowRoutes: Hono<hono_types12.BlankEnv, hono_types12.BlankSchema, "/">;
5
+ declare const workflowRoutes: Hono<hono_types9.BlankEnv, hono_types9.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { workflowRoutes };
@@ -6,20 +6,22 @@ import invitations_default from "./routes/invitations.js";
6
6
  import mcp_default from "./routes/mcp.js";
7
7
  import mcpToolGithubAccess_default from "./routes/mcpToolGithubAccess.js";
8
8
  import oauth_default from "./routes/oauth.js";
9
+ import passwordResetLinks_default from "./routes/passwordResetLinks.js";
9
10
  import playgroundToken_default from "./routes/playgroundToken.js";
10
11
  import projectFull_default from "./routes/projectFull.js";
11
12
  import projectGithubAccess_default from "./routes/projectGithubAccess.js";
12
13
  import signoz_default from "./routes/signoz.js";
13
- import userOrganizations_default from "./routes/userOrganizations.js";
14
+ import users_default from "./routes/users.js";
14
15
  import { OpenAPIHono } from "@hono/zod-openapi";
15
16
 
16
17
  //#region src/domains/manage/index.ts
17
18
  function createManageRoutes() {
18
19
  const app = new OpenAPIHono();
19
- app.route("/api/users/:userId/organizations", userOrganizations_default);
20
+ app.route("/api/users", users_default);
20
21
  app.route("/api/cli", cliAuth_default);
21
22
  app.route("/api/invitations", invitations_default);
22
23
  app.route("/tenants/:tenantId", routes_default);
24
+ app.route("/tenants/:tenantId/password-reset-links", passwordResetLinks_default);
23
25
  app.route("/tenants/:tenantId/playground/token", playgroundToken_default);
24
26
  app.route("/tenants/:tenantId/signoz", signoz_default);
25
27
  app.route("/tenants/:tenantId/github", github_default);
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono17 from "hono";
2
+ import * as hono14 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/availableAgents.d.ts
5
- declare const app: OpenAPIHono<hono17.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono14.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -2,7 +2,7 @@ import { getLogger as getLogger$1 } from "../../../logger.js";
2
2
  import { env } from "../../../env.js";
3
3
  import manageDbClient_default from "../../../data/db/manageDbClient.js";
4
4
  import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
5
- import { createApiError, listAgentsAcrossProjectBranches, listUsableProjectIds, verifyTempToken } from "@inkeep/agents-core";
5
+ import { createApiError, listAgentsAcrossProjectMainBranches, listUsableProjectIds, verifyTempToken } from "@inkeep/agents-core";
6
6
 
7
7
  //#region src/domains/manage/routes/availableAgents.ts
8
8
  const logger = getLogger$1("availableAgents");
@@ -77,7 +77,7 @@ app.openapi(createRoute({
77
77
  const { userId, tenantId } = user;
78
78
  const projectIds = await listUsableProjectIds({ userId });
79
79
  if (projectIds.length === 0) return c.json({ data: [] });
80
- const agents = await listAgentsAcrossProjectBranches(manageDbClient_default, {
80
+ const agents = await listAgentsAcrossProjectMainBranches(manageDbClient_default, {
81
81
  tenantId,
82
82
  projectIds
83
83
  });
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono8 from "hono";
2
+ import * as hono17 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/conversations.d.ts
5
- declare const app: OpenAPIHono<hono8.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono17.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono15 from "hono";
2
+ import * as hono18 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono15.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono18.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,10 +1,10 @@
1
1
  import { ManageAppVariables } from "../../../types/app.js";
2
2
  import { Hono } from "hono";
3
- import * as hono_types5 from "hono/types";
3
+ import * as hono_types11 from "hono/types";
4
4
 
5
5
  //#region src/domains/manage/routes/invitations.d.ts
6
6
  declare const invitationsRoutes: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types5.BlankSchema, "/">;
8
+ }, hono_types11.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { invitationsRoutes as default };
@@ -2,9 +2,68 @@ import runDbClient_default from "../../../data/db/runDbClient.js";
2
2
  import { sessionAuth } from "../../../middleware/sessionAuth.js";
3
3
  import { createApiError, getPendingInvitationsByEmail } from "@inkeep/agents-core";
4
4
  import { Hono } from "hono";
5
+ import { HTTPException } from "hono/http-exception";
5
6
 
6
7
  //#region src/domains/manage/routes/invitations.ts
7
8
  const invitationsRoutes = new Hono();
9
+ /**
10
+ * GET /api/invitations/verify?email=user@example.com&id=xxx
11
+ *
12
+ * Unauthenticated endpoint to validate an invitation exists and get preview info.
13
+ * Used by the accept-invitation page to pre-populate signup forms.
14
+ *
15
+ * Returns limited info: email, organizationName, organizationId, role, expiresAt
16
+ */
17
+ invitationsRoutes.get("/verify", async (c) => {
18
+ const email = c.req.query("email");
19
+ const invitationId = c.req.query("id");
20
+ if (!email) throw createApiError({
21
+ code: "bad_request",
22
+ message: "Email parameter is required"
23
+ });
24
+ if (!invitationId) throw createApiError({
25
+ code: "bad_request",
26
+ message: "Invitation ID parameter is required"
27
+ });
28
+ const auth = c.get("auth");
29
+ if (!auth) throw createApiError({
30
+ code: "internal_server_error",
31
+ message: "Auth not configured"
32
+ });
33
+ try {
34
+ const invitations = await auth.api.listUserInvitations({ query: { email } });
35
+ const invitation = Array.isArray(invitations) ? invitations.find((inv) => inv.id === invitationId) : null;
36
+ if (!invitation) throw createApiError({
37
+ code: "not_found",
38
+ message: "Invitation not found"
39
+ });
40
+ const expiresAt = invitation.expiresAt ? new Date(invitation.expiresAt) : null;
41
+ const isExpired = expiresAt && expiresAt < /* @__PURE__ */ new Date();
42
+ if (!(invitation.status === "pending")) throw createApiError({
43
+ code: "not_found",
44
+ message: "Invitation is no longer valid"
45
+ });
46
+ if (isExpired) throw createApiError({
47
+ code: "not_found",
48
+ message: "Invitation has expired"
49
+ });
50
+ return c.json({
51
+ valid: true,
52
+ email: invitation.email,
53
+ organizationName: invitation.organizationName || null,
54
+ organizationId: invitation.organizationId,
55
+ role: invitation.role,
56
+ expiresAt: invitation.expiresAt
57
+ });
58
+ } catch (error) {
59
+ if (error instanceof HTTPException) throw error;
60
+ console.error("[invitations/verify] Error fetching invitation:", error);
61
+ throw createApiError({
62
+ code: "internal_server_error",
63
+ message: "Failed to validate invitation"
64
+ });
65
+ }
66
+ });
8
67
  invitationsRoutes.use("*", sessionAuth());
9
68
  invitationsRoutes.get("/pending", async (c) => {
10
69
  const email = c.req.query("email");
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types6 from "hono/types";
2
+ import * as hono_types13 from "hono/types";
3
3
 
4
4
  //#region src/domains/manage/routes/mcp.d.ts
5
- declare const app: Hono<hono_types6.BlankEnv, hono_types6.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types13.BlankEnv, hono_types13.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -0,0 +1,10 @@
1
+ import { ManageAppVariables } from "../../../types/app.js";
2
+ import { Hono } from "hono";
3
+ import * as hono_types12 from "hono/types";
4
+
5
+ //#region src/domains/manage/routes/passwordResetLinks.d.ts
6
+ declare const passwordResetLinksRoutes: Hono<{
7
+ Variables: ManageAppVariables;
8
+ }, hono_types12.BlankSchema, "/">;
9
+ //#endregion
10
+ export { passwordResetLinksRoutes as default };
@@ -0,0 +1,61 @@
1
+ import { env } from "../../../env.js";
2
+ import { sessionAuth } from "../../../middleware/sessionAuth.js";
3
+ import { OrgRoles, createApiError, waitForPasswordResetLink } from "@inkeep/agents-core";
4
+ import { Hono } from "hono";
5
+
6
+ //#region src/domains/manage/routes/passwordResetLinks.ts
7
+ const passwordResetLinksRoutes = new Hono();
8
+ passwordResetLinksRoutes.use("*", sessionAuth());
9
+ passwordResetLinksRoutes.post("/", async (c) => {
10
+ const tenantId = c.req.param("tenantId");
11
+ const { email } = await c.req.json().catch(() => ({}));
12
+ const userId = c.get("userId");
13
+ if (!tenantId) throw createApiError({
14
+ code: "bad_request",
15
+ message: "Tenant ID is required"
16
+ });
17
+ if (!userId) throw createApiError({
18
+ code: "unauthorized",
19
+ message: "Authentication required"
20
+ });
21
+ if (!email) throw createApiError({
22
+ code: "bad_request",
23
+ message: "Email is required"
24
+ });
25
+ const tenantRole = c.get("tenantRole");
26
+ if (!tenantRole || tenantRole !== OrgRoles.ADMIN && tenantRole !== OrgRoles.OWNER) throw createApiError({
27
+ code: "forbidden",
28
+ message: "Admin access required"
29
+ });
30
+ const auth = c.get("auth");
31
+ if (!auth) throw createApiError({
32
+ code: "internal_server_error",
33
+ message: "Auth not configured"
34
+ });
35
+ if (!(await auth.api.listMembers({
36
+ query: { organizationId: tenantId },
37
+ headers: c.req.raw.headers
38
+ })).members.some((m) => m.user.email === email)) throw createApiError({
39
+ code: "forbidden",
40
+ message: "User is not a member of this organization"
41
+ });
42
+ const redirectTo = `${env.INKEEP_AGENTS_MANAGE_UI_URL || "http://localhost:3000"}/reset-password`;
43
+ const linkPromise = waitForPasswordResetLink(email);
44
+ await auth.api.requestPasswordReset({ body: {
45
+ email,
46
+ redirectTo
47
+ } });
48
+ try {
49
+ const link = await linkPromise;
50
+ return c.json({ url: link.url });
51
+ } catch {
52
+ throw createApiError({
53
+ code: "internal_server_error",
54
+ message: "Reset link not available"
55
+ });
56
+ }
57
+ });
58
+ var passwordResetLinks_default = passwordResetLinksRoutes;
59
+
60
+ //#endregion
61
+ export { passwordResetLinks_default as default };
@@ -1,10 +1,10 @@
1
1
  import { ManageAppVariables } from "../../../types/app.js";
2
2
  import { Hono } from "hono";
3
- import * as hono_types11 from "hono/types";
3
+ import * as hono_types5 from "hono/types";
4
4
 
5
5
  //#region src/domains/manage/routes/signoz.d.ts
6
6
  declare const app: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types11.BlankSchema, "/">;
8
+ }, hono_types5.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { app as default };
@@ -0,0 +1,10 @@
1
+ import { ManageAppVariables } from "../../../types/app.js";
2
+ import { Hono } from "hono";
3
+ import * as hono_types6 from "hono/types";
4
+
5
+ //#region src/domains/manage/routes/users.d.ts
6
+ declare const usersRoutes: Hono<{
7
+ Variables: ManageAppVariables;
8
+ }, hono_types6.BlankSchema, "/">;
9
+ //#endregion
10
+ export { usersRoutes as default };
@@ -0,0 +1,78 @@
1
+ import runDbClient_default from "../../../data/db/runDbClient.js";
2
+ import { sessionAuth } from "../../../middleware/sessionAuth.js";
3
+ import { OrgRoles, createApiError, getUserOrganizationsFromDb, getUserProvidersFromDb } from "@inkeep/agents-core";
4
+ import { Hono } from "hono";
5
+
6
+ //#region src/domains/manage/routes/users.ts
7
+ const usersRoutes = new Hono();
8
+ usersRoutes.use("*", sessionAuth());
9
+ /**
10
+ * GET /api/users/:userId/organizations
11
+ *
12
+ * List all organizations for a user.
13
+ * Only allows querying own organizations.
14
+ */
15
+ usersRoutes.get("/:userId/organizations", async (c) => {
16
+ const userId = c.req.param("userId");
17
+ const authenticatedUserId = c.get("userId");
18
+ if (!userId) throw createApiError({
19
+ code: "bad_request",
20
+ message: "User ID is required"
21
+ });
22
+ if (userId !== authenticatedUserId) throw createApiError({
23
+ code: "forbidden",
24
+ message: "Cannot access another user's organizations"
25
+ });
26
+ const userOrganizations = (await getUserOrganizationsFromDb(runDbClient_default)(userId)).map((org) => ({
27
+ ...org,
28
+ createdAt: org.createdAt.toISOString()
29
+ }));
30
+ return c.json(userOrganizations);
31
+ });
32
+ /**
33
+ * POST /api/users/providers
34
+ *
35
+ * Get authentication providers for a list of users.
36
+ * Returns which providers each user has (e.g., 'credential', 'google', 'auth0').
37
+ * Restricted to org admins/owners querying members of their organization.
38
+ *
39
+ * Body: { userIds: string[], organizationId: string }
40
+ * Response: UserProviderInfo[]
41
+ */
42
+ usersRoutes.post("/providers", async (c) => {
43
+ const { userIds, organizationId } = await c.req.json();
44
+ const authenticatedUserId = c.get("userId");
45
+ if (!organizationId) throw createApiError({
46
+ code: "bad_request",
47
+ message: "organizationId is required"
48
+ });
49
+ if (!userIds || !Array.isArray(userIds)) throw createApiError({
50
+ code: "bad_request",
51
+ message: "userIds array is required"
52
+ });
53
+ if (userIds.length === 0) return c.json([]);
54
+ const orgAccess = (await getUserOrganizationsFromDb(runDbClient_default)(authenticatedUserId)).find((org) => org.organizationId === organizationId);
55
+ if (!orgAccess) throw createApiError({
56
+ code: "forbidden",
57
+ message: "Access denied to this organization"
58
+ });
59
+ const role = orgAccess.role;
60
+ if (role !== OrgRoles.ADMIN && role !== OrgRoles.OWNER) throw createApiError({
61
+ code: "forbidden",
62
+ message: "Admin access required"
63
+ });
64
+ try {
65
+ const providers = await getUserProvidersFromDb(runDbClient_default)(userIds);
66
+ return c.json(providers);
67
+ } catch (error) {
68
+ console.error("[users/providers] Error fetching providers:", error);
69
+ throw createApiError({
70
+ code: "internal_server_error",
71
+ message: "Failed to fetch user providers"
72
+ });
73
+ }
74
+ });
75
+ var users_default = usersRoutes;
76
+
77
+ //#endregion
78
+ export { users_default as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types9 from "hono/types";
2
+ import * as hono_types7 from "hono/types";
3
3
 
4
4
  //#region src/domains/mcp/routes/mcp.d.ts
5
- declare const app: Hono<hono_types9.BlankEnv, hono_types9.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types7.BlankEnv, hono_types7.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -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 };