@inkeep/agents-api 0.0.1 → 0.43.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 (150) hide show
  1. package/dist/.well-known/workflow/v1/flow.cjs +43 -106
  2. package/dist/.well-known/workflow/v1/flow.cjs.debug.json +2 -4
  3. package/dist/.well-known/workflow/v1/manifest.debug.json +17 -55
  4. package/dist/.well-known/workflow/v1/step.cjs +45938 -45976
  5. package/dist/.well-known/workflow/v1/step.cjs.debug.json +2 -4
  6. package/dist/_virtual/rolldown_runtime.js +7 -0
  7. package/dist/createApp.js +40 -12
  8. package/dist/domains/evals/api/.well-known/workflow/v1/flow.d.ts +4 -0
  9. package/dist/domains/evals/api/.well-known/workflow/v1/flow.js +12 -0
  10. package/dist/domains/evals/api/.well-known/workflow/v1/step.d.ts +4 -0
  11. package/dist/domains/evals/api/.well-known/workflow/v1/step.js +12 -0
  12. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  13. package/dist/domains/evals/routes/index.d.ts +2 -2
  14. package/dist/domains/evals/scripts/build-workflow.js +2 -2
  15. package/dist/domains/evals/workflow/functions/evaluateConversation.d.ts +4 -1
  16. package/dist/domains/evals/workflow/functions/evaluateConversation.js +2 -1
  17. package/dist/domains/evals/workflow/functions/runDatasetItem.d.ts +4 -1
  18. package/dist/domains/evals/workflow/functions/runDatasetItem.js +2 -1
  19. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  20. package/dist/domains/evals/workflow/world.js +3 -2
  21. package/dist/domains/github/config.d.ts +14 -0
  22. package/dist/domains/github/config.js +47 -0
  23. package/dist/domains/github/index.d.ts +12 -0
  24. package/dist/domains/github/index.js +18 -0
  25. package/dist/domains/github/installation.d.ts +34 -0
  26. package/dist/domains/github/installation.js +172 -0
  27. package/dist/domains/github/jwks.d.ts +20 -0
  28. package/dist/domains/github/jwks.js +85 -0
  29. package/dist/domains/github/oidcToken.d.ts +22 -0
  30. package/dist/domains/github/oidcToken.js +140 -0
  31. package/dist/domains/github/routes/tokenExchange.d.ts +7 -0
  32. package/dist/domains/github/routes/tokenExchange.js +130 -0
  33. package/dist/domains/manage/index.js +0 -2
  34. package/dist/domains/manage/routes/agent.js +9 -4
  35. package/dist/domains/manage/routes/agentFull.js +9 -6
  36. package/dist/domains/manage/routes/apiKeys.js +1 -2
  37. package/dist/domains/manage/routes/artifactComponents.js +5 -5
  38. package/dist/domains/manage/routes/cliAuth.js +3 -3
  39. package/dist/domains/manage/routes/contextConfigs.js +5 -5
  40. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  41. package/dist/domains/manage/routes/credentialStores.js +2 -2
  42. package/dist/domains/manage/routes/credentials.js +6 -7
  43. package/dist/domains/manage/routes/dataComponents.js +6 -7
  44. package/dist/domains/manage/routes/externalAgents.js +1 -2
  45. package/dist/domains/manage/routes/index.d.ts +2 -2
  46. package/dist/domains/manage/routes/index.js +4 -0
  47. package/dist/domains/manage/routes/invitations.js +1 -1
  48. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  49. package/dist/domains/manage/routes/playgroundToken.js +1 -2
  50. package/dist/domains/manage/routes/projectFull.js +33 -11
  51. package/dist/domains/manage/routes/projectMembers.js +16 -35
  52. package/dist/domains/manage/routes/projectPermissions.js +17 -10
  53. package/dist/domains/manage/routes/projects.js +4 -5
  54. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  55. package/dist/domains/manage/routes/signoz.js +6 -3
  56. package/dist/domains/manage/routes/subAgentArtifactComponents.js +5 -5
  57. package/dist/domains/manage/routes/subAgentDataComponents.js +5 -5
  58. package/dist/domains/manage/routes/subAgentExternalAgentRelations.js +5 -5
  59. package/dist/domains/manage/routes/subAgentFunctionTools.js +5 -5
  60. package/dist/domains/manage/routes/subAgentRelations.js +6 -6
  61. package/dist/domains/manage/routes/subAgentTeamAgentRelations.js +6 -6
  62. package/dist/domains/manage/routes/subAgentToolRelations.js +6 -6
  63. package/dist/domains/manage/routes/subAgents.js +5 -5
  64. package/dist/domains/manage/routes/tools.js +24 -3
  65. package/dist/domains/manage/routes/triggers.js +82 -25
  66. package/dist/domains/manage/routes/userOrganizations.js +4 -4
  67. package/dist/domains/manage/routes/{agentToolRelations.d.ts → userProjectMemberships.d.ts} +1 -1
  68. package/dist/domains/manage/routes/userProjectMemberships.js +45 -0
  69. package/dist/domains/mcp/routes/mcp.d.ts +7 -0
  70. package/dist/domains/mcp/routes/mcp.js +45 -0
  71. package/dist/domains/run/a2a/handlers.js +2 -10
  72. package/dist/domains/run/a2a/types.d.ts +2 -6
  73. package/dist/domains/run/agents/Agent.d.ts +1 -0
  74. package/dist/domains/run/agents/Agent.js +207 -44
  75. package/dist/domains/run/agents/generateTaskHandler.js +14 -2
  76. package/dist/domains/run/context/ContextFetcher.js +8 -7
  77. package/dist/domains/run/context/ContextResolver.js +1 -1
  78. package/dist/domains/run/handlers/executionHandler.d.ts +3 -1
  79. package/dist/domains/run/handlers/executionHandler.js +149 -84
  80. package/dist/domains/run/routes/agents.js +1 -1
  81. package/dist/domains/run/routes/chat.js +47 -1
  82. package/dist/domains/run/routes/chatDataStream.js +107 -14
  83. package/dist/domains/run/routes/webhooks.js +40 -329
  84. package/dist/domains/run/services/AgentSession.d.ts +3 -0
  85. package/dist/domains/run/services/AgentSession.js +9 -0
  86. package/dist/domains/run/services/BaseCompressor.js +1 -1
  87. package/dist/domains/run/services/ToolApprovalUiBus.d.ts +28 -0
  88. package/dist/domains/run/services/ToolApprovalUiBus.js +44 -0
  89. package/dist/domains/run/services/TriggerService.d.ts +31 -0
  90. package/dist/domains/run/services/TriggerService.js +543 -0
  91. package/dist/domains/run/tools/NativeSandboxExecutor.d.ts +3 -2
  92. package/dist/domains/run/tools/NativeSandboxExecutor.js +76 -48
  93. package/dist/domains/run/tools/SandboxExecutorFactory.d.ts +11 -1
  94. package/dist/domains/run/tools/SandboxExecutorFactory.js +27 -3
  95. package/dist/domains/run/tools/VercelSandboxExecutor.d.ts +3 -11
  96. package/dist/domains/run/tools/VercelSandboxExecutor.js +137 -127
  97. package/dist/domains/run/types/xml.d.ts +1 -5
  98. package/dist/domains/run/utils/stream-helpers.d.ts +134 -0
  99. package/dist/domains/run/utils/stream-helpers.js +182 -0
  100. package/dist/factory.d.ts +278 -272
  101. package/dist/index.d.ts +275 -269
  102. package/dist/index.js +16 -1
  103. package/dist/initialization.js +9 -2
  104. package/dist/middleware/cors.js +1 -1
  105. package/dist/middleware/evalsAuth.d.ts +2 -2
  106. package/dist/middleware/manageAuth.d.ts +2 -2
  107. package/dist/middleware/projectAccess.d.ts +4 -11
  108. package/dist/middleware/projectAccess.js +1 -17
  109. package/dist/middleware/projectConfig.d.ts +3 -3
  110. package/dist/middleware/requirePermission.d.ts +2 -2
  111. package/dist/middleware/runAuth.d.ts +4 -4
  112. package/dist/middleware/sessionAuth.d.ts +3 -3
  113. package/dist/middleware/tenantAccess.d.ts +2 -2
  114. package/dist/middleware/tenantAccess.js +4 -4
  115. package/dist/middleware/tracing.d.ts +3 -3
  116. package/dist/openapi.d.ts +35 -1
  117. package/dist/openapi.js +39 -95
  118. package/dist/routes/healthChecks.d.ts +10 -0
  119. package/dist/routes/healthChecks.js +75 -0
  120. package/dist/templates/v1/phase1/system-prompt.js +1 -1
  121. package/dist/templates/v1/phase1/thinking-preparation.js +1 -1
  122. package/dist/templates/v1/phase1/tool.js +1 -1
  123. package/dist/templates/v1/phase2/data-component.js +1 -1
  124. package/dist/templates/v1/phase2/data-components.js +1 -1
  125. package/dist/templates/v1/phase2/system-prompt.js +1 -1
  126. package/dist/templates/v1/shared/artifact-retrieval-guidance.js +1 -1
  127. package/dist/templates/v1/shared/artifact.js +1 -1
  128. package/dist/types/app.d.ts +2 -0
  129. package/dist/utils/healthChecks.d.ts +8 -0
  130. package/dist/utils/healthChecks.js +38 -0
  131. package/dist/utils/signozHelpers.d.ts +2 -2
  132. package/dist/utils/signozHelpers.js +15 -3
  133. package/package.json +25 -28
  134. package/dist/domains/evals/services/startEvaluation.d.ts +0 -19
  135. package/dist/domains/evals/services/startEvaluation.js +0 -18
  136. package/dist/domains/index.d.ts +0 -4
  137. package/dist/domains/index.js +0 -5
  138. package/dist/domains/manage/routes/agentToolRelations.js +0 -289
  139. package/dist/domains/run/agents/ModelFactory.d.ts +0 -63
  140. package/dist/domains/run/agents/ModelFactory.js +0 -194
  141. package/dist/domains/run/data/agent.d.ts +0 -7
  142. package/dist/domains/run/data/agent.js +0 -67
  143. package/dist/domains/run/services/evaluationRunConfigMatcher.d.ts +0 -4
  144. package/dist/domains/run/services/evaluationRunConfigMatcher.js +0 -7
  145. package/dist/domains/run/utils/cleanup.d.ts +0 -21
  146. package/dist/domains/run/utils/cleanup.js +0 -59
  147. package/dist/utils/tempApiKeys.d.ts +0 -17
  148. package/dist/utils/tempApiKeys.js +0 -26
  149. package/dist/utils/workflowApiHelpers.d.ts +0 -1
  150. package/dist/utils/workflowApiHelpers.js +0 -1
@@ -1,4 +1,4 @@
1
- //#region templates/v1/shared/artifact-retrieval-guidance.md
1
+ //#region templates/v1/shared/artifact-retrieval-guidance.md?raw
2
2
  var artifact_retrieval_guidance_default = "ARTIFACT RETRIEVAL: ACCESSING EXISTING ARTIFACT DATA\n\n🚨 **CRITICAL: ALWAYS CHECK EXISTING ARTIFACTS FIRST** 🚨\nBefore creating new artifacts, ALWAYS examine existing artifacts to see if they contain relevant information for the current topic or question.\n\nYou CAN and SHOULD retrieve information from existing artifacts to answer user questions.\nAvailable artifacts contain structured data that you can access in two ways:\n\n1. **SUMMARY DATA**: Read the summary_data directly from available artifacts for basic information\n2. **FULL DATA**: Use the get_artifact tool to retrieve complete artifact data (both summary_data and full_data) when you need detailed information\n\n**REUSE EXISTING ARTIFACTS WHEN POSSIBLE:**\n- Look for artifacts with similar topics, names, or descriptions\n- Check if existing artifacts can answer the current question\n- Use existing artifact data instead of creating duplicates\n- Only create new artifacts if existing ones don't contain the needed information\n- Prioritize reusing relevant existing artifacts over creating new ones\n\nHOW TO USE ARTIFACT DATA:\n- Read summary_data from available artifacts for quick answers\n- Use get_artifact tool when you need comprehensive details\n- Extract specific information to answer user questions accurately\n- Reference artifacts when citing the information source\n- Combine information from multiple existing artifacts when relevant\n\n🚨 **MANDATORY CITATION POLICY** 🚨\nEVERY piece of information from existing artifacts MUST be properly cited:\n- When referencing information from existing artifacts = MUST cite with artifact reference\n- When discussing artifact data = MUST cite the artifact source \n- When using artifact information = MUST reference the artifact\n- NO INFORMATION from existing artifacts can be presented without proper citation\n\nCITATION PLACEMENT RULES:\n- ALWAYS place artifact citations AFTER complete thoughts and punctuation\n- Never interrupt a sentence or thought with an artifact citation\n- Complete your sentence or thought, add punctuation, THEN add the citation\n- This maintains natural reading flow and professional presentation\n\n✅ CORRECT EXAMPLES:\n- \"The API uses OAuth 2.0 authentication. <artifact:create id='auth-doc' ...> This process involves three main steps...\"\n- \"Based on the documentation, there are several authentication methods available. <artifact:create id='auth-methods' ...> The recommended approach is OAuth 2.0.\"\n\n❌ WRONG EXAMPLES:\n- \"The API uses <artifact:create id='auth-doc' ...> OAuth 2.0 authentication which involves...\"\n- \"According to <artifact:create id='auth-doc' ...>, the authentication method is OAuth 2.0.\"\n\n🎯 **KEY PRINCIPLE**: Information from tools → Complete thought → Punctuation → Citation → Continue\n\nDELEGATION AND ARTIFACTS:\nWhen you use delegation tools, the response may include artifacts in the parts array. These appear as objects with:\n- kind: \"data\"\n- data: { artifactId, toolCallId, name, description, type, artifactSummary }\n\nThese artifacts become immediately available for you to reference using the artifactId and toolCallId from the response.\nPresent delegation results naturally without mentioning the delegation process itself.\n\nIMPORTANT: All sub-agents can retrieve and use information from existing artifacts when the agent has artifact components, regardless of whether the individual agent or sub-agents can create new artifacts.";
3
3
 
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- //#region templates/v1/shared/artifact.xml
1
+ //#region templates/v1/shared/artifact.xml?raw
2
2
  var artifact_default = "<artifact>\n <name>{{ARTIFACT_NAME}}</name>\n <description>{{ARTIFACT_DESCRIPTION}}</description>\n <task_id>{{TASK_ID}}</task_id>\n <artifact_id>{{ARTIFACT_ID}}</artifact_id>\n <tool_call_id>{{TOOL_CALL_ID}}</tool_call_id>\n <summary_data>{{ARTIFACT_SUMMARY}}</summary_data>\n <!-- NOTE: This shows summary/preview data only. Use get_reference_artifact tool to get complete artifact data if needed. -->\n</artifact> ";
3
3
 
4
4
  //#endregion
@@ -38,6 +38,8 @@ type ManageAppVariables = AppVariables & {
38
38
  db: AgentsManageDatabaseClient;
39
39
  auth: ReturnType<typeof createAuth> | null;
40
40
  resolvedRef: ResolvedRef;
41
+ /** Cached by projectFull middleware to avoid duplicate DB lookup for PUT upsert */
42
+ isProjectCreate?: boolean;
41
43
  };
42
44
  type AppConfig = {
43
45
  serverConfig: ServerConfig;
@@ -0,0 +1,8 @@
1
+ import { AgentsRunDatabaseClient } from "@inkeep/agents-core";
2
+ import { Pool } from "pg";
3
+
4
+ //#region src/utils/healthChecks.d.ts
5
+ declare function checkManageDb(pool: Pool): Promise<boolean>;
6
+ declare function checkRunDb(client: AgentsRunDatabaseClient): Promise<boolean>;
7
+ //#endregion
8
+ export { checkManageDb, checkRunDb };
@@ -0,0 +1,38 @@
1
+ //#region src/utils/healthChecks.ts
2
+ const HEALTH_CHECK_TIMEOUT_MS = 5e3;
3
+ async function withTimeout(promise, timeoutMs) {
4
+ let timeoutId;
5
+ const timeoutPromise = new Promise((_, reject) => {
6
+ timeoutId = setTimeout(() => {
7
+ reject(/* @__PURE__ */ new Error(`Health check timed out after ${timeoutMs}ms`));
8
+ }, timeoutMs);
9
+ });
10
+ try {
11
+ return await Promise.race([promise, timeoutPromise]);
12
+ } finally {
13
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
14
+ }
15
+ }
16
+ async function checkManageDb(pool) {
17
+ try {
18
+ await withTimeout(pool.query("SELECT 1"), HEALTH_CHECK_TIMEOUT_MS);
19
+ return true;
20
+ } catch {
21
+ return false;
22
+ }
23
+ }
24
+ async function checkRunDb(client) {
25
+ try {
26
+ if ("$client" in client && client.$client) {
27
+ const pool = client.$client;
28
+ await withTimeout(pool.query("SELECT 1"), HEALTH_CHECK_TIMEOUT_MS);
29
+ return true;
30
+ }
31
+ return false;
32
+ } catch {
33
+ return false;
34
+ }
35
+ }
36
+
37
+ //#endregion
38
+ export { checkManageDb, checkRunDb };
@@ -4,6 +4,6 @@
4
4
  * This modifies the query payload to ensure all builder queries include
5
5
  * a server-side project.id filter, preventing client-side filter bypass.
6
6
  */
7
- declare function enforceProjectFilter(payload: any, projectId: string): any;
7
+ declare function enforceSecurityFilters(payload: any, tenantId: string, projectId?: string): any;
8
8
  //#endregion
9
- export { enforceProjectFilter };
9
+ export { enforceSecurityFilters };
@@ -4,7 +4,7 @@
4
4
  * This modifies the query payload to ensure all builder queries include
5
5
  * a server-side project.id filter, preventing client-side filter bypass.
6
6
  */
7
- function enforceProjectFilter(payload, projectId) {
7
+ function enforceSecurityFilters(payload, tenantId, projectId) {
8
8
  const modifiedPayload = JSON.parse(JSON.stringify(payload));
9
9
  if (modifiedPayload.compositeQuery?.builderQueries) for (const queryKey in modifiedPayload.compositeQuery.builderQueries) {
10
10
  const query = modifiedPayload.compositeQuery.builderQueries[queryKey];
@@ -12,8 +12,20 @@ function enforceProjectFilter(payload, projectId) {
12
12
  op: "AND",
13
13
  items: []
14
14
  };
15
- query.filters.items = query.filters.items.filter((item) => item.key?.key !== "project.id");
15
+ query.filters.items = query.filters.items.filter((item) => item.key?.key !== "tenant.id" && item.key?.key !== "project.id");
16
16
  query.filters.items.push({
17
+ key: {
18
+ key: "tenant.id",
19
+ dataType: "string",
20
+ type: "tag",
21
+ isColumn: false,
22
+ isJSON: false,
23
+ id: "false"
24
+ },
25
+ op: "=",
26
+ value: tenantId
27
+ });
28
+ if (projectId) query.filters.items.push({
17
29
  key: {
18
30
  key: "project.id",
19
31
  dataType: "string",
@@ -30,4 +42,4 @@ function enforceProjectFilter(payload, projectId) {
30
42
  }
31
43
 
32
44
  //#endregion
33
- export { enforceProjectFilter };
45
+ export { enforceSecurityFilters };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-api",
3
- "version": "0.0.1",
3
+ "version": "0.43.0",
4
4
  "description": "Unified Inkeep Agents API - combines management, runtime, and evaluation capabilities",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -31,36 +31,12 @@
31
31
  },
32
32
  "type": "module",
33
33
  "license": "SEE LICENSE IN LICENSE.md",
34
- "scripts": {
35
- "workflow:build": "tsx src/domains/evals/scripts/build-workflow.ts",
36
- "well-known:copy": "tsx scripts/copy-well-known.ts",
37
- "dev": "pnpm workflow:build && vite",
38
- "build": "pnpm workflow:build && tsdown && pnpm well-known:copy",
39
- "start": "node dist/index.js",
40
- "test": "vitest --run --config vitest.config.ts",
41
- "test:integration": "vitest --run --config vitest.integration.config.ts",
42
- "test:watch": "vitest",
43
- "test:coverage": "vitest --run --coverage",
44
- "openapi:update-snapshot": "UPDATE_OPENAPI_SNAPSHOT=true vitest --run src/__tests__/openapi.test.ts",
45
- "typecheck": "tsc --noEmit",
46
- "typecheck:watch": "tsc --noEmit --watch",
47
- "lint": "biome lint --error-on-warnings",
48
- "lint:fix": "biome check --write"
49
- },
50
34
  "dependencies": {
51
- "@ai-sdk/anthropic": "3.0.7",
52
- "@ai-sdk/gateway": "3.0.9",
53
35
  "@ai-sdk/google": "3.0.4",
54
- "@ai-sdk/openai": "3.0.7",
55
- "@ai-sdk/openai-compatible": "2.0.4",
56
36
  "@hono/mcp": "^0.1.5",
57
- "@hono/otel": "^0.4.0",
58
37
  "@hono/swagger-ui": "^0.5.1",
59
38
  "@hono/zod-openapi": "^1.1.5",
60
- "@inkeep/agents-core": "workspace:^",
61
- "@inkeep/agents-manage-mcp": "workspace:^",
62
39
  "@modelcontextprotocol/sdk": "^1.25.2",
63
- "@openrouter/ai-sdk-provider": "^1.2.0",
64
40
  "@opentelemetry/api": "^1.9.0",
65
41
  "@opentelemetry/auto-instrumentations-node": "^0.64.1",
66
42
  "@opentelemetry/baggage-span-processor": "^0.4.0",
@@ -71,6 +47,7 @@
71
47
  "@opentelemetry/sdk-node": "^0.205.0",
72
48
  "@opentelemetry/sdk-trace-base": "^2.1.0",
73
49
  "@opentelemetry/semantic-conventions": "^1.37.0",
50
+ "@vercel/functions": "^1.4.0",
74
51
  "@vercel/sandbox": "^0.0.24",
75
52
  "@workflow/builders": "4.0.1-beta.27",
76
53
  "@workflow/world-local": "4.0.1-beta.19",
@@ -84,10 +61,14 @@
84
61
  "hono": "^4.10.4",
85
62
  "hono-pino": "^0.10.1",
86
63
  "jmespath": "^0.16.0",
64
+ "jose": "^6.1.0",
87
65
  "llm-info": "^1.0.69",
88
66
  "openid-client": "^6.8.1",
89
67
  "pg": "^8.16.3",
90
- "workflow": "4.0.1-beta.33"
68
+ "workflow": "4.0.1-beta.33",
69
+ "@inkeep/agents-core": "^0.43.0",
70
+ "@inkeep/agents-mcp": "^0.43.0",
71
+ "@inkeep/agents-manage-mcp": "^0.43.0"
91
72
  },
92
73
  "peerDependencies": {
93
74
  "@hono/zod-openapi": "^1.1.5",
@@ -107,7 +88,6 @@
107
88
  "vite-tsconfig-paths": "^5.1.4",
108
89
  "vitest": "^3.2.4"
109
90
  },
110
- "packageManager": "pnpm@10.11.0",
111
91
  "publishConfig": {
112
92
  "access": "public",
113
93
  "registry": "https://registry.npmjs.org/"
@@ -122,5 +102,22 @@
122
102
  "type": "git",
123
103
  "url": "git+https://github.com/inkeep/agents.git",
124
104
  "directory": "agents-api"
105
+ },
106
+ "scripts": {
107
+ "knip": "knip --directory .. --workspace agents-api --config agents-api/knip.config.ts --dependencies --files",
108
+ "workflow:build": "tsx src/domains/evals/scripts/build-workflow.ts",
109
+ "well-known:copy": "tsx scripts/copy-well-known.ts",
110
+ "dev": "pnpm workflow:build && vite",
111
+ "build": "pnpm workflow:build && tsdown && pnpm well-known:copy",
112
+ "start": "node dist/index.js",
113
+ "test": "vitest --run --config vitest.config.ts",
114
+ "test:integration": "vitest --run --config vitest.integration.config.ts",
115
+ "test:watch": "vitest",
116
+ "test:coverage": "vitest --run --coverage",
117
+ "openapi:update-snapshot": "UPDATE_OPENAPI_SNAPSHOT=true vitest --run src/__tests__/openapi.test.ts",
118
+ "typecheck": "tsc --noEmit",
119
+ "typecheck:watch": "tsc --noEmit --watch",
120
+ "lint": "biome lint --error-on-warnings",
121
+ "lint:fix": "biome check --write"
125
122
  }
126
- }
123
+ }
@@ -1,19 +0,0 @@
1
- //#region src/domains/evals/services/startEvaluation.d.ts
2
- /**
3
- * Service to start evaluation workflows.
4
- * This encapsulates the workflow logic so consumers don't need to import workflow packages.
5
- */
6
- interface StartEvaluationParams {
7
- tenantId: string;
8
- projectId: string;
9
- conversationId: string;
10
- evaluatorIds: string[];
11
- evaluationRunId: string;
12
- }
13
- /**
14
- * Start an evaluation workflow for a conversation.
15
- * This is a convenience wrapper that handles workflow initialization internally.
16
- */
17
- declare function startConversationEvaluation(params: StartEvaluationParams): Promise<void>;
18
- //#endregion
19
- export { StartEvaluationParams, startConversationEvaluation };
@@ -1,18 +0,0 @@
1
- import { evaluateConversationWorkflow } from "../workflow/functions/evaluateConversation.js";
2
- import { start } from "workflow/api";
3
-
4
- //#region src/domains/evals/services/startEvaluation.ts
5
- /**
6
- * Service to start evaluation workflows.
7
- * This encapsulates the workflow logic so consumers don't need to import workflow packages.
8
- */
9
- /**
10
- * Start an evaluation workflow for a conversation.
11
- * This is a convenience wrapper that handles workflow initialization internally.
12
- */
13
- async function startConversationEvaluation(params) {
14
- await start(evaluateConversationWorkflow, [params]);
15
- }
16
-
17
- //#endregion
18
- export { startConversationEvaluation };
@@ -1,4 +0,0 @@
1
- import { createEvalRoutes, evalRoutes } from "./evals/index.js";
2
- import { createManageRoutes, manageRoutes } from "./manage/index.js";
3
- import { createRunRoutes, runRoutes } from "./run/index.js";
4
- export { createEvalRoutes, createManageRoutes, createRunRoutes, evalRoutes, manageRoutes, runRoutes };
@@ -1,5 +0,0 @@
1
- import { createEvalRoutes, evalRoutes } from "./evals/index.js";
2
- import { createManageRoutes, manageRoutes } from "./manage/index.js";
3
- import { createRunRoutes, runRoutes } from "./run/index.js";
4
-
5
- export { createEvalRoutes, createManageRoutes, createRunRoutes, evalRoutes, manageRoutes, runRoutes };
@@ -1,289 +0,0 @@
1
- import { requireProjectPermission } from "../../../middleware/projectAccess.js";
2
- import { speakeasyOffsetLimitPagination } from "../../../utils/speakeasy.js";
3
- import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
4
- import { ErrorResponseSchema, PaginationQueryParamsSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, commonGetErrorResponses, createAgentToolRelation, createApiError, deleteAgentToolRelation, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentsForTool, listAgentToolRelations, updateAgentToolRelation } from "@inkeep/agents-core";
5
-
6
- //#region src/domains/manage/routes/agentToolRelations.ts
7
- const app = new OpenAPIHono();
8
- app.use("/", async (c, next) => {
9
- if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
10
- return next();
11
- });
12
- app.use("/:id", async (c, next) => {
13
- if (c.req.method === "PUT") return requireProjectPermission("edit")(c, next);
14
- if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
15
- return next();
16
- });
17
- app.openapi(createRoute({
18
- method: "get",
19
- path: "/",
20
- summary: "List Agent Tool Relations",
21
- operationId: "list-agent-tool-relations",
22
- tags: ["Agent Tool Relations"],
23
- request: {
24
- params: TenantProjectAgentParamsSchema,
25
- query: PaginationQueryParamsSchema.extend({
26
- subAgentId: z.string().optional(),
27
- toolId: z.string().optional()
28
- })
29
- },
30
- responses: {
31
- 200: {
32
- description: "List of agent tool relations retrieved successfully",
33
- content: { "application/json": { schema: SubAgentToolRelationListResponse } }
34
- },
35
- ...commonGetErrorResponses
36
- },
37
- ...speakeasyOffsetLimitPagination
38
- }), async (c) => {
39
- const db = c.get("db");
40
- const { tenantId, projectId, agentId } = c.req.valid("param");
41
- const { page, limit, subAgentId, toolId } = c.req.valid("query");
42
- let result;
43
- if (subAgentId) {
44
- const dbResult = await getAgentToolRelationByAgent(db)({
45
- scopes: {
46
- tenantId,
47
- projectId,
48
- agentId,
49
- subAgentId
50
- },
51
- pagination: {
52
- page,
53
- limit
54
- }
55
- });
56
- result = {
57
- data: dbResult.data,
58
- pagination: dbResult.pagination
59
- };
60
- } else if (toolId) {
61
- const dbResult = await getAgentToolRelationByTool(db)({
62
- scopes: {
63
- tenantId,
64
- projectId,
65
- agentId
66
- },
67
- toolId,
68
- pagination: {
69
- page,
70
- limit
71
- }
72
- });
73
- result = {
74
- data: dbResult.data,
75
- pagination: dbResult.pagination
76
- };
77
- } else {
78
- const dbResult = await listAgentToolRelations(db)({
79
- scopes: {
80
- tenantId,
81
- projectId,
82
- agentId
83
- },
84
- pagination: {
85
- page,
86
- limit
87
- }
88
- });
89
- result = {
90
- data: dbResult.data,
91
- pagination: dbResult.pagination
92
- };
93
- }
94
- return c.json(result);
95
- });
96
- app.openapi(createRoute({
97
- method: "get",
98
- path: "/{id}",
99
- summary: "Get Agent Tool Relation",
100
- operationId: "get-agent-tool-relation",
101
- tags: ["Agent Tool Relations"],
102
- request: { params: TenantProjectAgentIdParamsSchema },
103
- responses: {
104
- 200: {
105
- description: "Agent tool relation found",
106
- content: { "application/json": { schema: SubAgentToolRelationResponse } }
107
- },
108
- ...commonGetErrorResponses
109
- }
110
- }), async (c) => {
111
- const db = c.get("db");
112
- const { tenantId, projectId, agentId, id } = c.req.valid("param");
113
- const agentToolRelation = await getAgentToolRelationById(db)({
114
- scopes: {
115
- tenantId,
116
- projectId,
117
- agentId,
118
- subAgentId: id
119
- },
120
- relationId: id
121
- });
122
- if (!agentToolRelation) throw createApiError({
123
- code: "not_found",
124
- message: "Agent tool relation not found"
125
- });
126
- return c.json({ data: agentToolRelation });
127
- });
128
- app.openapi(createRoute({
129
- method: "get",
130
- path: "/tool/{toolId}/agents",
131
- summary: "Get Agents for Tool",
132
- operationId: "get-agents-for-tool",
133
- tags: ["Agent Tool Relations"],
134
- request: {
135
- params: TenantProjectAgentParamsSchema.extend({ toolId: z.string() }),
136
- query: PaginationQueryParamsSchema
137
- },
138
- responses: {
139
- 200: {
140
- description: "Agents for tool retrieved successfully",
141
- content: { "application/json": { schema: SubAgentToolRelationListResponse } }
142
- },
143
- ...commonGetErrorResponses
144
- }
145
- }), async (c) => {
146
- const db = c.get("db");
147
- const { tenantId, projectId, agentId, toolId } = c.req.valid("param");
148
- const { page, limit } = c.req.valid("query");
149
- const dbResult = await getAgentsForTool(db)({
150
- scopes: {
151
- tenantId,
152
- projectId,
153
- agentId
154
- },
155
- toolId,
156
- pagination: {
157
- page,
158
- limit
159
- }
160
- });
161
- return c.json(dbResult);
162
- });
163
- app.openapi(createRoute({
164
- method: "post",
165
- path: "/",
166
- summary: "Create Agent Tool Relation",
167
- operationId: "create-agent-tool-relation",
168
- tags: ["Agent Tool Relations"],
169
- request: {
170
- params: TenantProjectAgentParamsSchema,
171
- body: { content: { "application/json": { schema: SubAgentToolRelationApiInsertSchema } } }
172
- },
173
- responses: {
174
- 201: {
175
- description: "Agent tool relation created successfully",
176
- content: { "application/json": { schema: SubAgentToolRelationResponse } }
177
- },
178
- ...commonGetErrorResponses
179
- }
180
- }), async (c) => {
181
- const db = c.get("db");
182
- const { tenantId, projectId, agentId } = c.req.valid("param");
183
- const body = c.req.valid("json");
184
- if ((await listAgentToolRelations(db)({
185
- scopes: {
186
- tenantId,
187
- projectId,
188
- agentId
189
- },
190
- pagination: { limit: 1e3 }
191
- })).data.some((relation) => {
192
- const typedRelation = relation;
193
- return typedRelation.subAgentId === body.subAgentId && typedRelation.toolId === body.toolId;
194
- })) throw createApiError({
195
- code: "unprocessable_entity",
196
- message: "Agent tool relation already exists"
197
- });
198
- try {
199
- const agentToolRelation = await createAgentToolRelation(db)({
200
- scopes: {
201
- tenantId,
202
- projectId,
203
- agentId
204
- },
205
- data: body
206
- });
207
- return c.json({ data: agentToolRelation }, 201);
208
- } catch (error) {
209
- if (error?.cause?.code === "23503") throw createApiError({
210
- code: "bad_request",
211
- message: "Invalid agent ID or tool ID - referenced entity does not exist"
212
- });
213
- throw error;
214
- }
215
- });
216
- app.openapi(createRoute({
217
- method: "put",
218
- path: "/{id}",
219
- summary: "Update Agent Tool Relation",
220
- operationId: "update-agent-tool-relation",
221
- tags: ["Agent Tool Relations"],
222
- request: {
223
- params: TenantProjectAgentIdParamsSchema,
224
- body: { content: { "application/json": { schema: SubAgentToolRelationApiUpdateSchema } } }
225
- },
226
- responses: {
227
- 200: {
228
- description: "Agent tool relation updated successfully",
229
- content: { "application/json": { schema: SubAgentToolRelationResponse } }
230
- },
231
- ...commonGetErrorResponses
232
- }
233
- }), async (c) => {
234
- const db = c.get("db");
235
- const { tenantId, projectId, agentId, id } = c.req.valid("param");
236
- const body = await c.req.valid("json");
237
- if (Object.keys(body).length === 0) throw createApiError({
238
- code: "bad_request",
239
- message: "No fields to update"
240
- });
241
- const updatedSubAgentToolRelation = await updateAgentToolRelation(db)({
242
- scopes: {
243
- tenantId,
244
- projectId,
245
- agentId
246
- },
247
- relationId: id,
248
- data: body
249
- });
250
- if (!updatedSubAgentToolRelation) throw createApiError({
251
- code: "not_found",
252
- message: "Agent tool relation not found"
253
- });
254
- return c.json({ data: updatedSubAgentToolRelation });
255
- });
256
- app.openapi(createRoute({
257
- method: "delete",
258
- path: "/{id}",
259
- summary: "Delete Agent Tool Relation",
260
- operationId: "delete-agent-tool-relation",
261
- tags: ["Agent Tool Relations"],
262
- request: { params: TenantProjectAgentIdParamsSchema },
263
- responses: {
264
- 204: { description: "Agent tool relation deleted successfully" },
265
- 404: {
266
- description: "Agent tool relation not found",
267
- content: { "application/json": { schema: ErrorResponseSchema } }
268
- }
269
- }
270
- }), async (c) => {
271
- const db = c.get("db");
272
- const { tenantId, projectId, agentId, id } = c.req.valid("param");
273
- if (!await deleteAgentToolRelation(db)({
274
- scopes: {
275
- tenantId,
276
- projectId,
277
- agentId
278
- },
279
- relationId: id
280
- })) throw createApiError({
281
- code: "not_found",
282
- message: "Agent tool relation not found"
283
- });
284
- return c.body(null, 204);
285
- });
286
- var agentToolRelations_default = app;
287
-
288
- //#endregion
289
- export { agentToolRelations_default as default };
@@ -1,63 +0,0 @@
1
- import { LanguageModel } from "ai";
2
-
3
- //#region src/domains/run/agents/ModelFactory.d.ts
4
- interface ModelSettings {
5
- model?: string;
6
- providerOptions?: Record<string, unknown>;
7
- }
8
- /**
9
- * Factory for creating AI SDK language models from configuration
10
- * Supports multiple providers and AI Gateway integration
11
- */
12
- declare class ModelFactory {
13
- /**
14
- * Create a provider instance with custom configuration
15
- * Returns a provider with at least languageModel method
16
- */
17
- private static createProvider;
18
- /**
19
- * Extract provider configuration from providerOptions
20
- * Only includes settings that go to the provider constructor (baseURL, apiKey, etc.)
21
- */
22
- private static extractProviderConfig;
23
- /**
24
- * Create a language model instance from configuration
25
- * Throws error if no config provided - models must be configured at project level
26
- */
27
- static createModel(config: ModelSettings): LanguageModel;
28
- /**
29
- * Built-in providers that have special handling
30
- */
31
- private static readonly BUILT_IN_PROVIDERS;
32
- /**
33
- * Parse model string to extract provider and model name
34
- * Examples: "anthropic/claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" }
35
- * "openrouter/anthropic/claude-sonnet-4" -> { provider: "openrouter", modelName: "anthropic/claude-sonnet-4" }
36
- * "claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" } (default to anthropic)
37
- */
38
- static parseModelString(modelString: string): {
39
- provider: string;
40
- modelName: string;
41
- };
42
- /**
43
- * Get generation parameters from provider options
44
- * These are parameters that get passed to generateText/streamText calls
45
- */
46
- static getGenerationParams(providerOptions?: Record<string, unknown>): Record<string, unknown>;
47
- /**
48
- * Prepare complete generation configuration from model settings
49
- * Returns model instance and generation parameters ready to spread into generateText/streamText
50
- * Includes maxDuration if specified in provider options (in seconds, following Vercel standard)
51
- */
52
- static prepareGenerationConfig(modelSettings?: ModelSettings): {
53
- model: LanguageModel;
54
- maxDuration?: number;
55
- } & Record<string, unknown>;
56
- /**
57
- * Validate model settingsuration
58
- * Basic validation only - let AI SDK handle parameter-specific validation
59
- */
60
- static validateConfig(config: ModelSettings): string[];
61
- }
62
- //#endregion
63
- export { ModelFactory, ModelSettings };