@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,8 +1,6 @@
1
1
  {
2
2
  "stepFiles": [
3
- "/Users/andrew/Documents/code/agents/agents/agents-api/src/domains/evals/workflow/functions/runDatasetItem.ts",
4
- "/Users/andrew/Documents/code/agents/agents/agents-api/dist/domains/evals/workflow/functions/evaluateConversation.js",
5
- "/Users/andrew/Documents/code/agents/agents/agents-api/dist/domains/evals/workflow/functions/runDatasetItem.js",
6
- "/Users/andrew/Documents/code/agents/agents/agents-api/src/domains/evals/workflow/functions/evaluateConversation.ts"
3
+ "/home/runner/work/agents/agents/agents-api/src/domains/evals/workflow/functions/evaluateConversation.ts",
4
+ "/home/runner/work/agents/agents/agents-api/src/domains/evals/workflow/functions/runDatasetItem.ts"
7
5
  ]
8
6
  }
@@ -0,0 +1,7 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region rolldown:runtime
4
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
+
6
+ //#endregion
7
+ export { __require };
package/dist/createApp.js CHANGED
@@ -2,8 +2,10 @@ import { getLogger } from "./logger.js";
2
2
  import { env } from "./env.js";
3
3
  import { evalRoutes } from "./domains/evals/index.js";
4
4
  import { workflowRoutes } from "./domains/evals/workflow/routes.js";
5
+ import { githubRoutes } from "./domains/github/index.js";
5
6
  import { sessionAuth, sessionContext } from "./middleware/sessionAuth.js";
6
7
  import { manageRoutes } from "./domains/manage/index.js";
8
+ import mcp_default from "./domains/mcp/routes/mcp.js";
7
9
  import { flushBatchProcessor } from "./instrumentation.js";
8
10
  import { runRoutes } from "./domains/run/index.js";
9
11
  import { authCorsConfig, defaultCorsConfig, playgroundCorsConfig, runCorsConfig, signozCorsConfig } from "./middleware/cors.js";
@@ -18,7 +20,8 @@ import { evalApiKeyAuth } from "./middleware/evalsAuth.js";
18
20
  import { projectConfigMiddleware, projectConfigMiddlewareExcept } from "./middleware/projectConfig.js";
19
21
  import { executionBaggageMiddleware } from "./middleware/tracing.js";
20
22
  import { setupOpenAPIRoutes } from "./openapi.js";
21
- import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
23
+ import { healthChecksHandler } from "./routes/healthChecks.js";
24
+ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
22
25
  import { Hono } from "hono";
23
26
  import { cors } from "hono/cors";
24
27
  import { requestId } from "hono/request-id";
@@ -33,6 +36,11 @@ const isWebhookRoute = (path) => {
33
36
  function createAgentsHono(config) {
34
37
  const { serverConfig, credentialStores, auth, sandboxConfig } = config;
35
38
  const app = new OpenAPIHono();
39
+ const CapabilitiesResponseSchema = z.object({ sandbox: z.object({
40
+ configured: z.boolean().describe("Whether a sandbox provider is configured. Required for Function Tools execution."),
41
+ provider: z.enum(["native", "vercel"]).optional().describe("The configured sandbox provider, if enabled."),
42
+ runtime: z.enum(["node22", "typescript"]).optional().describe("The configured sandbox runtime, if enabled.")
43
+ }).describe("Sandbox execution capabilities (used by Function Tools).") }).describe("Optional server capabilities and configuration.").openapi("CapabilitiesResponseSchema");
36
44
  app.use("*", requestId());
37
45
  if (auth) {
38
46
  app.use("/api/auth/*", cors(authCorsConfig));
@@ -48,6 +56,7 @@ function createAgentsHono(config) {
48
56
  if (c.req.path.startsWith("/run/")) return next();
49
57
  if (c.req.path.includes("/playground/token")) return next();
50
58
  if (c.req.path.includes("/signoz/")) return next();
59
+ if (c.req.path.includes("/api/github/")) return next();
51
60
  return cors(defaultCorsConfig)(c, next);
52
61
  });
53
62
  app.use("*", async (c, next) => {
@@ -82,20 +91,11 @@ function createAgentsHono(config) {
82
91
  }));
83
92
  app.onError(errorHandler);
84
93
  app.use("*", sessionContext());
85
- app.openapi(createRoute({
86
- method: "get",
87
- path: "/health",
88
- operationId: "health",
89
- summary: "Health check",
90
- description: "Check if the management service is healthy",
91
- responses: { 204: { description: "Service is healthy" } }
92
- }), (c) => {
93
- return c.body(null, 204);
94
- });
94
+ app.route("/", healthChecksHandler);
95
95
  app.openapi(createRoute({
96
96
  method: "get",
97
97
  path: "/api/workflow/process",
98
- tags: ["workflow"],
98
+ tags: ["Workflows"],
99
99
  summary: "Process workflow jobs",
100
100
  description: "Keeps the workflow worker active to process queued jobs (called by cron)",
101
101
  responses: { 200: { description: "Processing complete" } }
@@ -114,6 +114,32 @@ function createAgentsHono(config) {
114
114
  if (c.req.header("Authorization")?.startsWith("Bearer ")) return manageApiKeyAuth()(c, next);
115
115
  return sessionAuth()(c, next);
116
116
  });
117
+ app.use("/manage/capabilities", async (c, next) => {
118
+ if (!auth || env.DISABLE_AUTH || isTestEnvironment()) {
119
+ await next();
120
+ return;
121
+ }
122
+ if (c.req.header("Authorization")?.startsWith("Bearer ")) return manageApiKeyAuth()(c, next);
123
+ return sessionAuth()(c, next);
124
+ });
125
+ app.openapi(createRoute({
126
+ method: "get",
127
+ path: "/manage/capabilities",
128
+ operationId: "capabilities",
129
+ summary: "Get server capabilities",
130
+ description: "Get information about optional server-side capabilities and configuration.",
131
+ responses: { 200: {
132
+ description: "Server capabilities",
133
+ content: { "application/json": { schema: CapabilitiesResponseSchema } }
134
+ } }
135
+ }), (c) => {
136
+ if (!sandboxConfig) return c.json({ sandbox: { configured: false } });
137
+ return c.json({ sandbox: {
138
+ configured: true,
139
+ provider: sandboxConfig.provider,
140
+ runtime: sandboxConfig.runtime
141
+ } });
142
+ });
117
143
  if (env.DISABLE_AUTH || isTestEnvironment()) app.use("/manage/tenants/:tenantId/*", async (c, next) => {
118
144
  const tenantId = c.req.param("tenantId");
119
145
  if (tenantId) {
@@ -156,6 +182,8 @@ function createAgentsHono(config) {
156
182
  return fetch(forwardedRequest);
157
183
  });
158
184
  app.route("/evals", evalRoutes);
185
+ app.route("/api/github", githubRoutes);
186
+ app.route("/mcp", mcp_default);
159
187
  setupOpenAPIRoutes(app);
160
188
  app.use("/run/*", async (_c, next) => {
161
189
  await next();
@@ -0,0 +1,4 @@
1
+ //#region src/domains/evals/api/.well-known/workflow/v1/flow.d.ts
2
+ declare function handler(req: Request): Promise<Response>;
3
+ //#endregion
4
+ export { handler as default };
@@ -0,0 +1,12 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region src/domains/evals/api/.well-known/workflow/v1/flow.ts
4
+ console.log("[WF CONSUMER] flow.ts loaded", (/* @__PURE__ */ new Date()).toISOString());
5
+ const flowModule = createRequire(import.meta.url)("../../../../dist/.well-known/workflow/v1/flow.cjs");
6
+ async function handler(req) {
7
+ console.log("[WF CONSUMER HIT] flow.ts", (/* @__PURE__ */ new Date()).toISOString(), req.method, req.url);
8
+ return flowModule.default(req);
9
+ }
10
+
11
+ //#endregion
12
+ export { handler as default };
@@ -0,0 +1,4 @@
1
+ //#region src/domains/evals/api/.well-known/workflow/v1/step.d.ts
2
+ declare function handler(req: Request): Promise<Response>;
3
+ //#endregion
4
+ export { handler as default };
@@ -0,0 +1,12 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region src/domains/evals/api/.well-known/workflow/v1/step.ts
4
+ console.log("[WF CONSUMER] step.ts loaded", (/* @__PURE__ */ new Date()).toISOString());
5
+ const stepModule = createRequire(import.meta.url)("../../../../dist/.well-known/workflow/v1/step.cjs");
6
+ async function handler(req) {
7
+ console.log("[WF CONSUMER HIT] step.ts", (/* @__PURE__ */ new Date()).toISOString(), req.method, req.url);
8
+ return stepModule.default(req);
9
+ }
10
+
11
+ //#endregion
12
+ export { handler as default };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono7 from "hono";
2
+ import * as hono12 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/datasetTriggers.d.ts
5
- declare const app: OpenAPIHono<hono7.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono12.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 hono1 from "hono";
2
+ import * as hono13 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono1.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono13.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -5,7 +5,7 @@ import { StandaloneBuilder } from "@workflow/builders";
5
5
  * Custom workflow build script that supports externalizing native modules.
6
6
  *
7
7
  * The default `workflow build` CLI doesn't expose the externalPackages option,
8
- * so we use the builder directly to exclude native modules like keytar.
8
+ * so we use the builder directly to exclude native modules like @napi-rs/keyring.
9
9
  */
10
10
  const config = {
11
11
  dirs: ["./src/domains/evals/workflow"],
@@ -14,7 +14,7 @@ const config = {
14
14
  stepsBundlePath: "./.well-known/workflow/v1/step.cjs",
15
15
  workflowsBundlePath: "./.well-known/workflow/v1/flow.cjs",
16
16
  webhookBundlePath: "./.well-known/workflow/v1/webhook.mjs",
17
- externalPackages: ["keytar"]
17
+ externalPackages: ["@napi-rs/keyring"]
18
18
  };
19
19
  async function build() {
20
20
  console.log("Building workflow bundles...");
@@ -13,7 +13,7 @@ type EvaluationPayload = {
13
13
  * - Do NOT call Node.js APIs directly here (no DB, no fs, etc.)
14
14
  * - All side effects must happen in step functions
15
15
  */
16
- declare function evaluateConversationWorkflow(payload: EvaluationPayload): Promise<{
16
+ declare function _evaluateConversationWorkflow(payload: EvaluationPayload): Promise<{
17
17
  success: boolean;
18
18
  reason: string;
19
19
  conversationId?: undefined;
@@ -24,5 +24,8 @@ declare function evaluateConversationWorkflow(payload: EvaluationPayload): Promi
24
24
  resultCount: number;
25
25
  reason?: undefined;
26
26
  }>;
27
+ declare const evaluateConversationWorkflow: typeof _evaluateConversationWorkflow & {
28
+ workflowId: string;
29
+ };
27
30
  //#endregion
28
31
  export { evaluateConversationWorkflow };
@@ -102,7 +102,7 @@ async function logStep(message, data) {
102
102
  * - Do NOT call Node.js APIs directly here (no DB, no fs, etc.)
103
103
  * - All side effects must happen in step functions
104
104
  */
105
- async function evaluateConversationWorkflow(payload) {
105
+ async function _evaluateConversationWorkflow(payload) {
106
106
  "use workflow";
107
107
  const { conversationId, evaluatorIds } = payload;
108
108
  await logStep("Starting conversation evaluation", payload);
@@ -129,6 +129,7 @@ async function evaluateConversationWorkflow(payload) {
129
129
  resultCount: results.length
130
130
  };
131
131
  }
132
+ const evaluateConversationWorkflow = Object.assign(_evaluateConversationWorkflow, { workflowId: "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//_evaluateConversationWorkflow" });
132
133
 
133
134
  //#endregion
134
135
  export { evaluateConversationWorkflow };
@@ -25,12 +25,15 @@ type RunDatasetItemPayload = {
25
25
  * Main workflow function - processes a single dataset item through the chat API.
26
26
  * Optionally runs evaluators on the resulting conversation.
27
27
  */
28
- declare function runDatasetItemWorkflow(payload: RunDatasetItemPayload): Promise<{
28
+ declare function _runDatasetItemWorkflow(payload: RunDatasetItemPayload): Promise<{
29
29
  success: boolean;
30
30
  datasetItemId: string;
31
31
  datasetRunId: string;
32
32
  conversationId: string | null;
33
33
  error: string | null;
34
34
  }>;
35
+ declare const runDatasetItemWorkflow: typeof _runDatasetItemWorkflow & {
36
+ workflowId: string;
37
+ };
35
38
  //#endregion
36
39
  export { runDatasetItemWorkflow };
@@ -173,7 +173,7 @@ async function logStep(message, data) {
173
173
  * Main workflow function - processes a single dataset item through the chat API.
174
174
  * Optionally runs evaluators on the resulting conversation.
175
175
  */
176
- async function runDatasetItemWorkflow(payload) {
176
+ async function _runDatasetItemWorkflow(payload) {
177
177
  "use workflow";
178
178
  const { datasetItemId, datasetRunId, agentId, evaluatorIds, evaluationRunId } = payload;
179
179
  await logStep("Starting dataset item processing", {
@@ -199,6 +199,7 @@ async function runDatasetItemWorkflow(payload) {
199
199
  error: result.error || null
200
200
  };
201
201
  }
202
+ const runDatasetItemWorkflow = Object.assign(_runDatasetItemWorkflow, { workflowId: "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//_runDatasetItemWorkflow" });
202
203
 
203
204
  //#endregion
204
205
  export { runDatasetItemWorkflow };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types1 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_types1.BlankEnv, hono_types1.BlankSchema, "/">;
5
+ declare const workflowRoutes: Hono<hono_types9.BlankEnv, hono_types9.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { workflowRoutes };
@@ -11,8 +11,9 @@ import { createVercelWorld } from "@workflow/world-vercel";
11
11
  * Vercel's NFT can't trace dynamic imports in bundled code.
12
12
  *
13
13
  * Set WORKFLOW_TARGET_WORLD to: 'local' | 'vercel' | '@workflow/world-postgres'
14
+ * Defaults to 'local' for development if not set.
14
15
  */
15
- const targetWorld = env.WORKFLOW_TARGET_WORLD;
16
+ const targetWorld = env.WORKFLOW_TARGET_WORLD || "local";
16
17
  let world;
17
18
  if (targetWorld === "vercel") {
18
19
  const token = process.env.WORKFLOW_VERCEL_AUTH_TOKEN;
@@ -30,7 +31,7 @@ if (targetWorld === "vercel") {
30
31
  jobPrefix: env.WORKFLOW_POSTGRES_JOB_PREFIX,
31
32
  queueConcurrency: Number(env.WORKFLOW_POSTGRES_WORKER_CONCURRENCY) || 10
32
33
  });
33
- else if (targetWorld === "local") world = createLocalWorld();
34
+ else world = createLocalWorld();
34
35
 
35
36
  //#endregion
36
37
  export { world };
@@ -0,0 +1,14 @@
1
+ import { z } from "@hono/zod-openapi";
2
+
3
+ //#region src/domains/github/config.d.ts
4
+ declare const GitHubAppConfigSchema: z.ZodObject<{
5
+ appId: z.ZodString;
6
+ privateKey: z.ZodString;
7
+ }, z.core.$strip>;
8
+ type GitHubAppConfig = z.infer<typeof GitHubAppConfigSchema>;
9
+ declare function getGitHubAppConfig(): GitHubAppConfig;
10
+ declare function isGitHubAppConfigured(): boolean;
11
+ declare function validateGitHubAppConfigOnStartup(): void;
12
+ declare function clearConfigCache(): void;
13
+ //#endregion
14
+ export { GitHubAppConfig, clearConfigCache, getGitHubAppConfig, isGitHubAppConfigured, validateGitHubAppConfigOnStartup };
@@ -0,0 +1,47 @@
1
+ import { getLogger } from "../../logger.js";
2
+ import { z } from "@hono/zod-openapi";
3
+
4
+ //#region src/domains/github/config.ts
5
+ const logger = getLogger("github-config");
6
+ const GitHubAppConfigSchema = z.object({
7
+ appId: z.string().min(1, "GITHUB_APP_ID is required"),
8
+ privateKey: z.string().min(1, "GITHUB_APP_PRIVATE_KEY is required")
9
+ });
10
+ let cachedConfig = null;
11
+ function getGitHubAppConfig() {
12
+ if (cachedConfig) return cachedConfig;
13
+ const appId = process.env.GITHUB_APP_ID;
14
+ const privateKey = process.env.GITHUB_APP_PRIVATE_KEY?.replace(/\\n/g, "\n");
15
+ const result = GitHubAppConfigSchema.safeParse({
16
+ appId,
17
+ privateKey
18
+ });
19
+ if (!result.success) {
20
+ const errorMessage = `GitHub App credentials are not configured. ${result.error.issues.map((issue) => issue.message).join(". ")}. Please set GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY environment variables.`;
21
+ logger.error({}, errorMessage);
22
+ throw new Error(errorMessage);
23
+ }
24
+ cachedConfig = result.data;
25
+ logger.info({}, "GitHub App credentials loaded successfully");
26
+ return cachedConfig;
27
+ }
28
+ function isGitHubAppConfigured() {
29
+ return Boolean(process.env.GITHUB_APP_ID && process.env.GITHUB_APP_PRIVATE_KEY);
30
+ }
31
+ function validateGitHubAppConfigOnStartup() {
32
+ if (!isGitHubAppConfigured()) {
33
+ logger.warn({}, "GitHub App credentials not configured. Token exchange endpoint will return 500 errors. Set GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY to enable the feature.");
34
+ return;
35
+ }
36
+ try {
37
+ getGitHubAppConfig();
38
+ } catch (error) {
39
+ logger.error({ error }, "GitHub App credentials are invalid. Token exchange endpoint will return 500 errors.");
40
+ }
41
+ }
42
+ function clearConfigCache() {
43
+ cachedConfig = null;
44
+ }
45
+
46
+ //#endregion
47
+ export { clearConfigCache, getGitHubAppConfig, isGitHubAppConfigured, validateGitHubAppConfigOnStartup };
@@ -0,0 +1,12 @@
1
+ import { GitHubAppConfig, getGitHubAppConfig, isGitHubAppConfigured } from "./config.js";
2
+ import { GenerateInstallationAccessTokenResult, GenerateTokenError, GenerateTokenResult, InstallationAccessToken, InstallationInfo, LookupInstallationError, LookupInstallationForRepoResult, LookupInstallationResult, generateInstallationAccessToken, lookupInstallationForRepo } from "./installation.js";
3
+ import { GetJwkResult, JwksError, JwksResult, clearJwksCache, getJwkForToken, getJwksCacheStatus } from "./jwks.js";
4
+ import { GitHubOidcClaims, ValidateOidcTokenResult, ValidateTokenError, ValidateTokenResult, validateOidcToken } from "./oidcToken.js";
5
+ import { Hono } from "hono";
6
+ import * as hono_types5 from "hono/types";
7
+
8
+ //#region src/domains/github/index.d.ts
9
+ declare function createGithubRoutes(): Hono<hono_types5.BlankEnv, hono_types5.BlankSchema, "/">;
10
+ declare const githubRoutes: Hono<hono_types5.BlankEnv, hono_types5.BlankSchema, "/">;
11
+ //#endregion
12
+ export { type GenerateInstallationAccessTokenResult, type GenerateTokenError, type GenerateTokenResult, type GetJwkResult, type GitHubAppConfig, type GitHubOidcClaims, type InstallationAccessToken, type InstallationInfo, type JwksError, type JwksResult, type LookupInstallationError, type LookupInstallationForRepoResult, type LookupInstallationResult, type ValidateOidcTokenResult, type ValidateTokenError, type ValidateTokenResult, clearJwksCache, createGithubRoutes, generateInstallationAccessToken, getGitHubAppConfig, getJwkForToken, getJwksCacheStatus, githubRoutes, isGitHubAppConfigured, lookupInstallationForRepo, validateOidcToken };
@@ -0,0 +1,18 @@
1
+ import { getGitHubAppConfig, isGitHubAppConfigured, validateGitHubAppConfigOnStartup } from "./config.js";
2
+ import { generateInstallationAccessToken, lookupInstallationForRepo } from "./installation.js";
3
+ import { clearJwksCache, getJwkForToken, getJwksCacheStatus } from "./jwks.js";
4
+ import { validateOidcToken } from "./oidcToken.js";
5
+ import tokenExchange_default from "./routes/tokenExchange.js";
6
+ import { Hono } from "hono";
7
+
8
+ //#region src/domains/github/index.ts
9
+ function createGithubRoutes() {
10
+ validateGitHubAppConfigOnStartup();
11
+ const app = new Hono();
12
+ app.route("/token-exchange", tokenExchange_default);
13
+ return app;
14
+ }
15
+ const githubRoutes = createGithubRoutes();
16
+
17
+ //#endregion
18
+ export { clearJwksCache, createGithubRoutes, generateInstallationAccessToken, getGitHubAppConfig, getJwkForToken, getJwksCacheStatus, githubRoutes, isGitHubAppConfigured, lookupInstallationForRepo, validateOidcToken };
@@ -0,0 +1,34 @@
1
+ //#region src/domains/github/installation.d.ts
2
+ interface InstallationInfo {
3
+ installationId: number;
4
+ accountLogin: string;
5
+ accountType: 'User' | 'Organization';
6
+ }
7
+ interface LookupInstallationResult {
8
+ success: true;
9
+ installation: InstallationInfo;
10
+ }
11
+ interface LookupInstallationError {
12
+ success: false;
13
+ errorType: 'not_installed' | 'api_error' | 'jwt_error';
14
+ message: string;
15
+ }
16
+ type LookupInstallationForRepoResult = LookupInstallationResult | LookupInstallationError;
17
+ interface InstallationAccessToken {
18
+ token: string;
19
+ expiresAt: string;
20
+ }
21
+ interface GenerateTokenResult {
22
+ success: true;
23
+ accessToken: InstallationAccessToken;
24
+ }
25
+ interface GenerateTokenError {
26
+ success: false;
27
+ errorType: 'api_error' | 'jwt_error';
28
+ message: string;
29
+ }
30
+ type GenerateInstallationAccessTokenResult = GenerateTokenResult | GenerateTokenError;
31
+ declare function lookupInstallationForRepo(repositoryOwner: string, repositoryName: string): Promise<LookupInstallationForRepoResult>;
32
+ declare function generateInstallationAccessToken(installationId: number): Promise<GenerateInstallationAccessTokenResult>;
33
+ //#endregion
34
+ export { GenerateInstallationAccessTokenResult, GenerateTokenError, GenerateTokenResult, InstallationAccessToken, InstallationInfo, LookupInstallationError, LookupInstallationForRepoResult, LookupInstallationResult, generateInstallationAccessToken, lookupInstallationForRepo };
@@ -0,0 +1,172 @@
1
+ import { getLogger } from "../../logger.js";
2
+ import { getGitHubAppConfig } from "./config.js";
3
+ import { createPrivateKey } from "node:crypto";
4
+ import { SignJWT } from "jose";
5
+
6
+ //#region src/domains/github/installation.ts
7
+ const logger = getLogger("github-installation");
8
+ const GITHUB_API_BASE = "https://api.github.com";
9
+ async function createAppJwt() {
10
+ const config = getGitHubAppConfig();
11
+ const privateKey = createPrivateKey({
12
+ key: config.privateKey,
13
+ format: "pem"
14
+ });
15
+ const now = Math.floor(Date.now() / 1e3);
16
+ return await new SignJWT({}).setProtectedHeader({ alg: "RS256" }).setIssuedAt(now - 60).setExpirationTime(now + 600).setIssuer(config.appId).sign(privateKey);
17
+ }
18
+ async function lookupInstallationForRepo(repositoryOwner, repositoryName) {
19
+ let appJwt;
20
+ try {
21
+ appJwt = await createAppJwt();
22
+ } catch (error) {
23
+ const message = error instanceof Error ? error.message : "Unknown error";
24
+ logger.error({ error: message }, "Failed to create GitHub App JWT");
25
+ return {
26
+ success: false,
27
+ errorType: "jwt_error",
28
+ message: `Failed to create GitHub App authentication: ${message}`
29
+ };
30
+ }
31
+ const url = `${GITHUB_API_BASE}/repos/${repositoryOwner}/${repositoryName}/installation`;
32
+ try {
33
+ const response = await fetch(url, {
34
+ method: "GET",
35
+ headers: {
36
+ Authorization: `Bearer ${appJwt}`,
37
+ Accept: "application/vnd.github+json",
38
+ "X-GitHub-Api-Version": "2022-11-28",
39
+ "User-Agent": "inkeep-agents-api"
40
+ }
41
+ });
42
+ if (response.status === 404) return {
43
+ success: false,
44
+ errorType: "not_installed",
45
+ message: `GitHub App is not installed on repository ${repositoryOwner}/${repositoryName}. Please install the Inkeep Agents GitHub App on the repository to enable token exchange.`
46
+ };
47
+ if (!response.ok) {
48
+ const errorText = await response.text();
49
+ logger.error({
50
+ status: response.status,
51
+ error: errorText,
52
+ repositoryOwner,
53
+ repositoryName
54
+ }, "GitHub API error looking up installation");
55
+ return {
56
+ success: false,
57
+ errorType: "api_error",
58
+ message: `GitHub API error (${response.status}): Failed to look up installation for repository`
59
+ };
60
+ }
61
+ const data = await response.json();
62
+ const installationId = data.id;
63
+ const accountLogin = data.account?.login;
64
+ const accountType = data.account?.type;
65
+ if (typeof installationId !== "number" || typeof accountLogin !== "string") {
66
+ logger.error({ data }, "Unexpected response format from GitHub API");
67
+ return {
68
+ success: false,
69
+ errorType: "api_error",
70
+ message: "Unexpected response format from GitHub API"
71
+ };
72
+ }
73
+ logger.info({
74
+ installationId,
75
+ accountLogin,
76
+ accountType,
77
+ repositoryOwner,
78
+ repositoryName
79
+ }, "Found GitHub App installation for repository");
80
+ return {
81
+ success: true,
82
+ installation: {
83
+ installationId,
84
+ accountLogin,
85
+ accountType: accountType === "Organization" ? "Organization" : "User"
86
+ }
87
+ };
88
+ } catch (error) {
89
+ const message = error instanceof Error ? error.message : "Unknown error";
90
+ logger.error({
91
+ error: message,
92
+ repositoryOwner,
93
+ repositoryName
94
+ }, "Error calling GitHub API to look up installation");
95
+ return {
96
+ success: false,
97
+ errorType: "api_error",
98
+ message: `Failed to connect to GitHub API: ${message}`
99
+ };
100
+ }
101
+ }
102
+ async function generateInstallationAccessToken(installationId) {
103
+ let appJwt;
104
+ try {
105
+ appJwt = await createAppJwt();
106
+ } catch (error) {
107
+ const message = error instanceof Error ? error.message : "Unknown error";
108
+ logger.error({ error: message }, "Failed to create GitHub App JWT for token generation");
109
+ return {
110
+ success: false,
111
+ errorType: "jwt_error",
112
+ message: `Failed to create GitHub App authentication: ${message}`
113
+ };
114
+ }
115
+ const url = `${GITHUB_API_BASE}/app/installations/${installationId}/access_tokens`;
116
+ try {
117
+ const response = await fetch(url, {
118
+ method: "POST",
119
+ headers: {
120
+ Authorization: `Bearer ${appJwt}`,
121
+ Accept: "application/vnd.github+json",
122
+ "X-GitHub-Api-Version": "2022-11-28",
123
+ "User-Agent": "inkeep-agents-api"
124
+ }
125
+ });
126
+ if (!response.ok) {
127
+ const errorText = await response.text();
128
+ logger.error({
129
+ status: response.status,
130
+ error: errorText,
131
+ installationId
132
+ }, "GitHub API error generating installation access token");
133
+ return {
134
+ success: false,
135
+ errorType: "api_error",
136
+ message: `GitHub API error (${response.status}): Failed to generate installation access token`
137
+ };
138
+ }
139
+ const data = await response.json();
140
+ const token = data.token;
141
+ const expiresAt = data.expires_at;
142
+ if (typeof token !== "string" || typeof expiresAt !== "string") {
143
+ logger.error({ data }, "Unexpected response format from GitHub API for token generation");
144
+ return {
145
+ success: false,
146
+ errorType: "api_error",
147
+ message: "Unexpected response format from GitHub API"
148
+ };
149
+ }
150
+ return {
151
+ success: true,
152
+ accessToken: {
153
+ token,
154
+ expiresAt
155
+ }
156
+ };
157
+ } catch (error) {
158
+ const message = error instanceof Error ? error.message : "Unknown error";
159
+ logger.error({
160
+ error: message,
161
+ installationId
162
+ }, "Error calling GitHub API to generate installation access token");
163
+ return {
164
+ success: false,
165
+ errorType: "api_error",
166
+ message: `Failed to connect to GitHub API: ${message}`
167
+ };
168
+ }
169
+ }
170
+
171
+ //#endregion
172
+ export { generateInstallationAccessToken, lookupInstallationForRepo };
@@ -0,0 +1,20 @@
1
+ import { CryptoKey, JWSHeaderParameters } from "jose";
2
+
3
+ //#region src/domains/github/jwks.d.ts
4
+ interface JwksResult {
5
+ success: true;
6
+ key: CryptoKey;
7
+ }
8
+ interface JwksError {
9
+ success: false;
10
+ error: string;
11
+ }
12
+ type GetJwkResult = JwksResult | JwksError;
13
+ declare function getJwkForToken(header: JWSHeaderParameters): Promise<GetJwkResult>;
14
+ declare function clearJwksCache(): void;
15
+ declare function getJwksCacheStatus(): {
16
+ cached: boolean;
17
+ expiresIn?: number;
18
+ };
19
+ //#endregion
20
+ export { GetJwkResult, JwksError, JwksResult, clearJwksCache, getJwkForToken, getJwksCacheStatus };