@inkeep/agents-api 0.46.0 → 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.
- package/dist/.well-known/workflow/v1/flow.cjs +44 -44
- package/dist/.well-known/workflow/v1/flow.cjs.debug.json +2 -2
- package/dist/.well-known/workflow/v1/step.cjs +167 -172
- package/dist/.well-known/workflow/v1/step.cjs.debug.json +2 -2
- package/dist/createApp.d.ts +2 -2
- package/dist/createApp.js +1 -3
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/evals/services/EvaluationService.js +1 -2
- package/dist/domains/evals/workflow/routes.d.ts +2 -2
- package/dist/domains/manage/index.js +4 -2
- package/dist/domains/manage/routes/availableAgents.d.ts +2 -2
- package/dist/domains/manage/routes/availableAgents.js +2 -2
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/invitations.d.ts +2 -2
- package/dist/domains/manage/routes/invitations.js +59 -0
- package/dist/domains/manage/routes/mcp.d.ts +2 -2
- package/dist/domains/manage/routes/passwordResetLinks.d.ts +10 -0
- package/dist/domains/manage/routes/passwordResetLinks.js +61 -0
- package/dist/domains/manage/routes/signoz.d.ts +2 -2
- package/dist/domains/manage/routes/users.d.ts +10 -0
- package/dist/domains/manage/routes/users.js +78 -0
- package/dist/domains/mcp/routes/mcp.d.ts +2 -2
- package/dist/domains/run/a2a/client.d.ts +0 -2
- package/dist/domains/run/a2a/client.js +5 -7
- package/dist/domains/run/agents/Agent.d.ts +41 -15
- package/dist/domains/run/agents/Agent.js +127 -281
- package/dist/domains/run/agents/generateTaskHandler.js +10 -5
- package/dist/domains/run/agents/relationTools.js +1 -3
- package/dist/domains/run/agents/types.d.ts +2 -1
- package/dist/domains/run/agents/versions/v1/{Phase1Config.d.ts → PromptConfig.d.ts} +5 -4
- package/dist/domains/run/agents/versions/v1/{Phase1Config.js → PromptConfig.js} +36 -19
- package/dist/domains/run/handlers/executionHandler.js +8 -12
- package/dist/factory.d.ts +55 -21
- package/dist/index.d.ts +124 -90
- package/dist/middleware/evalsAuth.d.ts +2 -2
- package/dist/middleware/projectAccess.d.ts +2 -2
- package/dist/middleware/projectConfig.d.ts +3 -3
- package/dist/middleware/requirePermission.d.ts +2 -2
- package/dist/middleware/runAuth.d.ts +4 -4
- package/dist/middleware/sessionAuth.d.ts +3 -3
- package/dist/middleware/tenantAccess.d.ts +2 -2
- package/dist/middleware/tracing.d.ts +3 -3
- package/dist/templates/v1/prompt/system-prompt.js +5 -0
- package/dist/templates/v1/{phase1 → prompt}/tool.js +1 -1
- package/dist/templates/v1/shared/artifact-retrieval-guidance.js +1 -1
- package/dist/templates/v1/{phase2 → shared}/data-component.js +1 -1
- package/dist/templates/v1/{phase2 → shared}/data-components.js +1 -1
- package/package.json +5 -5
- package/dist/domains/manage/routes/userOrganizations.d.ts +0 -10
- package/dist/domains/manage/routes/userOrganizations.js +0 -29
- package/dist/domains/run/agents/versions/v1/Phase2Config.d.ts +0 -33
- package/dist/domains/run/agents/versions/v1/Phase2Config.js +0 -341
- package/dist/templates/v1/phase1/system-prompt.js +0 -5
- package/dist/templates/v1/phase1/thinking-preparation.js +0 -5
- package/dist/templates/v1/phase2/system-prompt.js +0 -5
- package/dist/utils/in-process-fetch.d.ts +0 -22
- package/dist/utils/in-process-fetch.js +0 -32
package/dist/createApp.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "./logger.js";
|
|
2
2
|
import { env } from "./env.js";
|
|
3
|
-
import { getInProcessFetch, registerAppFetch } from "./utils/in-process-fetch.js";
|
|
4
3
|
import { evalRoutes } from "./domains/evals/index.js";
|
|
5
4
|
import { workflowRoutes } from "./domains/evals/workflow/routes.js";
|
|
6
5
|
import { sessionAuth, sessionContext } from "./middleware/sessionAuth.js";
|
|
@@ -182,7 +181,7 @@ function createAgentsHono(config) {
|
|
|
182
181
|
headers: new Headers(c.req.raw.headers),
|
|
183
182
|
body: bodyBuffer
|
|
184
183
|
});
|
|
185
|
-
return
|
|
184
|
+
return fetch(forwardedRequest);
|
|
186
185
|
});
|
|
187
186
|
app.route("/evals", evalRoutes);
|
|
188
187
|
app.route("/work-apps/github", githubRoutes);
|
|
@@ -194,7 +193,6 @@ function createAgentsHono(config) {
|
|
|
194
193
|
});
|
|
195
194
|
const base = new Hono();
|
|
196
195
|
base.route("/", app);
|
|
197
|
-
registerAppFetch(base.request.bind(base));
|
|
198
196
|
return base;
|
|
199
197
|
}
|
|
200
198
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono15 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/datasetTriggers.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
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
|
|
2
|
+
import * as hono16 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono16.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -3,7 +3,6 @@ import { env } from "../../../env.js";
|
|
|
3
3
|
import manageDbClient_default from "../../../data/db/manageDbClient.js";
|
|
4
4
|
import manageDbPool_default from "../../../data/db/manageDbPool.js";
|
|
5
5
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
6
|
-
import { getInProcessFetch } from "../../../utils/in-process-fetch.js";
|
|
7
6
|
import { ModelFactory, createEvaluationResult, createEvaluationRun, filterConversationsForJob, generateId, getConversationHistory, getEvaluationJobConfigById, getEvaluationJobConfigEvaluatorRelations, getEvaluatorById, getFullAgent, getProjectScopedRef, resolveRef, updateEvaluationResult, withRef } from "@inkeep/agents-core";
|
|
8
7
|
import { generateObject, generateText } from "ai";
|
|
9
8
|
import { z } from "zod";
|
|
@@ -87,7 +86,7 @@ var EvaluationService = class {
|
|
|
87
86
|
datasetRunId,
|
|
88
87
|
conversationId
|
|
89
88
|
}, "Running dataset item through chat API");
|
|
90
|
-
const response = await
|
|
89
|
+
const response = await fetch(chatUrl, {
|
|
91
90
|
method: "POST",
|
|
92
91
|
headers: headers$1,
|
|
93
92
|
body: JSON.stringify(chatPayload)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
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<
|
|
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
|
|
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
|
|
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
|
|
2
|
+
import * as hono14 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/availableAgents.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
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,
|
|
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
|
|
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
|
|
2
|
+
import * as hono17 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/conversations.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
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
|
|
2
|
+
import * as hono18 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
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
|
|
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
|
-
},
|
|
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
|
|
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<
|
|
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
|
|
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
|
-
},
|
|
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
|
|
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<
|
|
5
|
+
declare const app: Hono<hono_types7.BlankEnv, hono_types7.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -20,7 +20,6 @@ interface A2AClientOptions {
|
|
|
20
20
|
retryConfig?: RetryConfig;
|
|
21
21
|
ref?: ResolvedRef;
|
|
22
22
|
headers?: Record<string, string>;
|
|
23
|
-
fetchFn?: typeof fetch;
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
25
|
* A2AClient is a TypeScript HTTP client for interacting with A2A-compliant agents.
|
|
@@ -65,7 +64,6 @@ declare class A2AClient {
|
|
|
65
64
|
private requestIdCounter;
|
|
66
65
|
private serviceEndpointUrl?;
|
|
67
66
|
private options;
|
|
68
|
-
private fetchFn;
|
|
69
67
|
/**
|
|
70
68
|
* Constructs an A2AClient instance.
|
|
71
69
|
* It initiates fetching the agent card from the provided agent baseUrl.
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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<
|
|
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 };
|