@inkeep/agents-core 0.43.0 → 0.45.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 (76) hide show
  1. package/dist/auth/auth.d.ts +4 -2
  2. package/dist/auth/auth.js +4 -3
  3. package/dist/auth/authz/client.d.ts +0 -1
  4. package/dist/auth/authz/client.js +0 -1
  5. package/dist/auth/authz/config.d.ts +1 -7
  6. package/dist/auth/authz/config.js +1 -9
  7. package/dist/auth/authz/index.d.ts +3 -3
  8. package/dist/auth/authz/index.js +3 -3
  9. package/dist/auth/authz/permissions.d.ts +16 -1
  10. package/dist/auth/authz/permissions.js +30 -9
  11. package/dist/auth/authz/sync.js +1 -11
  12. package/dist/auth/init.d.ts +1 -0
  13. package/dist/auth/init.js +115 -0
  14. package/dist/client-exports.d.ts +2 -6
  15. package/dist/client-exports.js +3 -7
  16. package/dist/constants/otel-attributes.d.ts +6 -0
  17. package/dist/constants/otel-attributes.js +9 -3
  18. package/dist/constants/signoz-queries.d.ts +1 -0
  19. package/dist/constants/signoz-queries.js +2 -1
  20. package/dist/data-access/index.d.ts +4 -3
  21. package/dist/data-access/index.js +6 -5
  22. package/dist/data-access/manage/agentFull.js +42 -1
  23. package/dist/data-access/manage/agents.d.ts +27 -10
  24. package/dist/data-access/manage/agents.js +33 -2
  25. package/dist/data-access/manage/artifactComponents.d.ts +4 -4
  26. package/dist/data-access/manage/artifactComponents.js +1 -1
  27. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  28. package/dist/data-access/manage/dataComponents.d.ts +4 -4
  29. package/dist/data-access/manage/dataComponents.js +1 -1
  30. package/dist/data-access/manage/functionTools.d.ts +4 -4
  31. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
  32. package/dist/data-access/manage/subAgentRelations.d.ts +18 -18
  33. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
  34. package/dist/data-access/manage/subAgents.d.ts +3 -3
  35. package/dist/data-access/manage/tools.d.ts +20 -15
  36. package/dist/data-access/manage/tools.js +20 -1
  37. package/dist/data-access/runtime/apiKeys.d.ts +4 -4
  38. package/dist/data-access/runtime/cascade-delete.d.ts +48 -1
  39. package/dist/data-access/runtime/cascade-delete.js +52 -2
  40. package/dist/data-access/runtime/conversations.d.ts +19 -19
  41. package/dist/data-access/runtime/github-work-app-installations.d.ts +261 -0
  42. package/dist/data-access/runtime/github-work-app-installations.js +457 -0
  43. package/dist/data-access/runtime/messages.d.ts +6 -6
  44. package/dist/data-access/runtime/organizations.js +2 -2
  45. package/dist/data-access/runtime/tasks.d.ts +4 -4
  46. package/dist/db/manage/manage-schema.d.ts +17 -0
  47. package/dist/db/manage/manage-schema.js +1 -0
  48. package/dist/db/runtime/runtime-schema.d.ts +1009 -165
  49. package/dist/db/runtime/runtime-schema.js +173 -5
  50. package/dist/dolt/ref-middleware.js +1 -1
  51. package/dist/env.d.ts +6 -4
  52. package/dist/env.js +11 -10
  53. package/dist/index.d.ts +10 -11
  54. package/dist/index.js +22 -23
  55. package/dist/types/entities.d.ts +9 -2
  56. package/dist/types/index.d.ts +3 -3
  57. package/dist/types/utility.d.ts +16 -2
  58. package/dist/utils/temp-jwt.d.ts +2 -1
  59. package/dist/utils/temp-jwt.js +3 -2
  60. package/dist/validation/agentFull.js +1 -1
  61. package/dist/validation/dolt-schemas.d.ts +1 -1
  62. package/dist/validation/drizzle-schema-helpers.d.ts +1 -20
  63. package/dist/validation/drizzle-schema-helpers.js +3 -30
  64. package/dist/validation/index.d.ts +2 -4
  65. package/dist/validation/index.js +4 -6
  66. package/dist/validation/schemas.d.ts +3021 -1228
  67. package/dist/validation/schemas.js +164 -79
  68. package/drizzle/manage/0006_fixed_umar.sql +1 -0
  69. package/drizzle/manage/meta/0006_snapshot.json +3148 -0
  70. package/drizzle/manage/meta/_journal.json +7 -0
  71. package/drizzle/runtime/0010_previous_black_knight.sql +84 -0
  72. package/drizzle/runtime/meta/0010_snapshot.json +3066 -0
  73. package/drizzle/runtime/meta/_journal.json +7 -0
  74. package/package.json +4 -2
  75. package/dist/validation/id-validation.d.ts +0 -24
  76. package/dist/validation/id-validation.js +0 -52
@@ -1,7 +1,7 @@
1
1
  import { __exportAll } from "../../_virtual/rolldown_runtime.js";
2
2
  import { account, deviceCode, invitation, member, organization, session, ssoProvider, user, verification } from "../../auth/auth-schema.js";
3
3
  import { relations } from "drizzle-orm";
4
- import { foreignKey, index, jsonb, pgTable, primaryKey, text, timestamp, unique, varchar } from "drizzle-orm/pg-core";
4
+ import { boolean, foreignKey, index, jsonb, pgTable, primaryKey, text, timestamp, unique, varchar } from "drizzle-orm/pg-core";
5
5
 
6
6
  //#region src/db/runtime/runtime-schema.ts
7
7
  var runtime_schema_exports = /* @__PURE__ */ __exportAll({
@@ -31,11 +31,24 @@ var runtime_schema_exports = /* @__PURE__ */ __exportAll({
31
31
  tasksRelations: () => tasksRelations,
32
32
  triggerInvocations: () => triggerInvocations,
33
33
  user: () => user,
34
- verification: () => verification
34
+ verification: () => verification,
35
+ workAppGitHubInstallations: () => workAppGitHubInstallations,
36
+ workAppGitHubInstallationsRelations: () => workAppGitHubInstallationsRelations,
37
+ workAppGitHubMcpToolAccessMode: () => workAppGitHubMcpToolAccessMode,
38
+ workAppGitHubMcpToolRepositoryAccess: () => workAppGitHubMcpToolRepositoryAccess,
39
+ workAppGitHubMcpToolRepositoryAccessRelations: () => workAppGitHubMcpToolRepositoryAccessRelations,
40
+ workAppGitHubProjectAccessMode: () => workAppGitHubProjectAccessMode,
41
+ workAppGitHubProjectRepositoryAccess: () => workAppGitHubProjectRepositoryAccess,
42
+ workAppGitHubProjectRepositoryAccessRelations: () => workAppGitHubProjectRepositoryAccessRelations,
43
+ workAppGitHubRepositories: () => workAppGitHubRepositories,
44
+ workAppGitHubRepositoriesRelations: () => workAppGitHubRepositoriesRelations
35
45
  });
36
- const projectScoped = {
46
+ const tenantScoped = {
37
47
  tenantId: varchar("tenant_id", { length: 256 }).notNull(),
38
- id: varchar("id", { length: 256 }).notNull(),
48
+ id: varchar("id", { length: 256 }).notNull()
49
+ };
50
+ const projectScoped = {
51
+ ...tenantScoped,
39
52
  projectId: varchar("project_id", { length: 256 }).notNull()
40
53
  };
41
54
  const agentScoped = {
@@ -478,6 +491,161 @@ const ledgerArtifactsRelations = relations(ledgerArtifacts, ({ one }) => ({ task
478
491
  fields: [ledgerArtifacts.taskId],
479
492
  references: [tasks.id]
480
493
  }) }));
494
+ /**
495
+ * Tracks GitHub App installations linked to tenants.
496
+ * One tenant can have multiple installations (e.g., multiple orgs).
497
+ * The installation_id is the GitHub-assigned ID, unique across all GitHub.
498
+ */
499
+ const workAppGitHubInstallations = pgTable("work_app_github_installations", {
500
+ ...tenantScoped,
501
+ installationId: text("installation_id").notNull().unique(),
502
+ accountLogin: varchar("account_login", { length: 256 }).notNull(),
503
+ accountId: text("account_id").notNull(),
504
+ accountType: varchar("account_type", { length: 20 }).$type().notNull(),
505
+ status: varchar("status", { length: 20 }).$type().notNull().default("active"),
506
+ ...timestamps
507
+ }, (table) => [
508
+ index("work_app_github_installations_tenant_idx").on(table.tenantId),
509
+ index("work_app_github_installations_installation_id_idx").on(table.installationId),
510
+ foreignKey({
511
+ columns: [table.tenantId],
512
+ foreignColumns: [organization.id],
513
+ name: "work_app_github_installations_organization_fk"
514
+ }).onDelete("cascade")
515
+ ]);
516
+ /**
517
+ * Repositories accessible through a GitHub App installation.
518
+ * These are synced from GitHub when the app is installed or updated.
519
+ * The repository_id is the GitHub-assigned ID, unique across all GitHub.
520
+ */
521
+ const workAppGitHubRepositories = pgTable("work_app_github_repositories", {
522
+ id: varchar("id", { length: 256 }).primaryKey(),
523
+ installationDbId: varchar("installation_db_id", { length: 256 }).notNull(),
524
+ repositoryId: text("repository_id").notNull(),
525
+ repositoryName: varchar("repository_name", { length: 256 }).notNull(),
526
+ repositoryFullName: varchar("repository_full_name", { length: 512 }).notNull(),
527
+ private: boolean("private").notNull().default(false),
528
+ ...timestamps
529
+ }, (table) => [
530
+ index("work_app_github_repositories_installation_idx").on(table.installationDbId),
531
+ index("work_app_github_repositories_full_name_idx").on(table.repositoryFullName),
532
+ unique("work_app_github_repositories_repo_installation_unique").on(table.installationDbId, table.repositoryId),
533
+ foreignKey({
534
+ columns: [table.installationDbId],
535
+ foreignColumns: [workAppGitHubInstallations.id],
536
+ name: "work_app_github_repositories_installation_fk"
537
+ }).onDelete("cascade")
538
+ ]);
539
+ /**
540
+ * Links projects to specific GitHub repositories for fine-grained access control.
541
+ * When a project has entries here, only the listed repositories are accessible.
542
+ * When no entries exist for a project, all tenant repositories are accessible (mode='all').
543
+ * The tenant_id and project_id reference the projects table in the manage schema
544
+ * (cross-schema, no FK constraint for project). tenant_id is included because
545
+ * project IDs are only unique within a tenant.
546
+ */
547
+ const workAppGitHubProjectRepositoryAccess = pgTable("work_app_github_project_repository_access", {
548
+ ...projectScoped,
549
+ repositoryDbId: varchar("repository_db_id", { length: 256 }).notNull(),
550
+ ...timestamps
551
+ }, (table) => [
552
+ index("work_app_github_project_repository_access_tenant_idx").on(table.tenantId),
553
+ index("work_app_github_project_repository_access_project_idx").on(table.projectId),
554
+ unique("work_app_github_project_repository_access_unique").on(table.tenantId, table.projectId, table.repositoryDbId),
555
+ foreignKey({
556
+ columns: [table.tenantId],
557
+ foreignColumns: [organization.id],
558
+ name: "work_app_github_project_repository_access_tenant_fk"
559
+ }).onDelete("cascade"),
560
+ foreignKey({
561
+ columns: [table.repositoryDbId],
562
+ foreignColumns: [workAppGitHubRepositories.id],
563
+ name: "work_app_github_project_repository_access_repo_fk"
564
+ }).onDelete("cascade")
565
+ ]);
566
+ /**
567
+ * Links MCP tools to specific GitHub repositories for repository-scoped access.
568
+ * When an MCP tool has entries here, only the listed repositories are accessible to that tool.
569
+ * The tool_id, tenant_id, and project_id reference the tools table in the manage schema
570
+ * (cross-schema, no FK constraint). These are denormalized here so all GitHub access
571
+ * info can be queried from PostgreSQL alone.
572
+ */
573
+ const workAppGitHubMcpToolRepositoryAccess = pgTable("work_app_github_mcp_tool_repository_access", {
574
+ ...projectScoped,
575
+ toolId: varchar("tool_id", { length: 256 }).notNull(),
576
+ repositoryDbId: varchar("repository_db_id", { length: 256 }).notNull(),
577
+ ...timestamps
578
+ }, (table) => [
579
+ index("work_app_github_mcp_tool_repository_access_tool_idx").on(table.toolId),
580
+ index("work_app_github_mcp_tool_repository_access_tenant_idx").on(table.tenantId),
581
+ index("work_app_github_mcp_tool_repository_access_project_idx").on(table.projectId),
582
+ unique("work_app_github_mcp_tool_repository_access_unique").on(table.toolId, table.repositoryDbId),
583
+ foreignKey({
584
+ columns: [table.tenantId],
585
+ foreignColumns: [organization.id],
586
+ name: "work_app_github_mcp_tool_repository_access_tenant_fk"
587
+ }).onDelete("cascade"),
588
+ foreignKey({
589
+ columns: [table.repositoryDbId],
590
+ foreignColumns: [workAppGitHubRepositories.id],
591
+ name: "work_app_github_mcp_tool_repository_access_repo_fk"
592
+ }).onDelete("cascade")
593
+ ]);
594
+ /**
595
+ * Stores the explicit access mode for project-level GitHub repository access.
596
+ * - 'all': Project has access to all repositories from tenant GitHub installations
597
+ * - 'selected': Project only has access to repositories listed in work_app_github_project_repository_access
598
+ * If no row exists for a project, defaults to 'selected' (fail-safe: no access unless explicitly granted).
599
+ */
600
+ const workAppGitHubProjectAccessMode = pgTable("work_app_github_project_access_mode", {
601
+ tenantId: varchar("tenant_id", { length: 256 }).notNull(),
602
+ projectId: varchar("project_id", { length: 256 }).notNull(),
603
+ mode: varchar("mode", { length: 20 }).$type().notNull(),
604
+ ...timestamps
605
+ }, (table) => [primaryKey({ columns: [table.tenantId, table.projectId] }), foreignKey({
606
+ columns: [table.tenantId],
607
+ foreignColumns: [organization.id],
608
+ name: "work_app_github_project_access_mode_tenant_fk"
609
+ }).onDelete("cascade")]);
610
+ /**
611
+ * Stores the explicit access mode for MCP tool-level GitHub repository access.
612
+ * - 'all': Tool has access to all repositories the project has access to
613
+ * - 'selected': Tool only has access to repositories listed in work_app_github_mcp_tool_repository_access
614
+ * If no row exists for a tool, defaults to 'selected' (fail-safe: no access unless explicitly granted).
615
+ */
616
+ const workAppGitHubMcpToolAccessMode = pgTable("work_app_github_mcp_tool_access_mode", {
617
+ toolId: varchar("tool_id", { length: 256 }).notNull(),
618
+ tenantId: varchar("tenant_id", { length: 256 }).notNull(),
619
+ projectId: varchar("project_id", { length: 256 }).notNull(),
620
+ mode: varchar("mode", { length: 20 }).$type().notNull(),
621
+ ...timestamps
622
+ }, (table) => [
623
+ primaryKey({ columns: [table.toolId] }),
624
+ index("work_app_github_mcp_tool_access_mode_tenant_idx").on(table.tenantId),
625
+ index("work_app_github_mcp_tool_access_mode_project_idx").on(table.projectId),
626
+ foreignKey({
627
+ columns: [table.tenantId],
628
+ foreignColumns: [organization.id],
629
+ name: "work_app_github_mcp_tool_access_mode_tenant_fk"
630
+ }).onDelete("cascade")
631
+ ]);
632
+ const workAppGitHubInstallationsRelations = relations(workAppGitHubInstallations, ({ many }) => ({ repositories: many(workAppGitHubRepositories) }));
633
+ const workAppGitHubRepositoriesRelations = relations(workAppGitHubRepositories, ({ one, many }) => ({
634
+ installation: one(workAppGitHubInstallations, {
635
+ fields: [workAppGitHubRepositories.installationDbId],
636
+ references: [workAppGitHubInstallations.id]
637
+ }),
638
+ projectAccess: many(workAppGitHubProjectRepositoryAccess),
639
+ mcpToolAccess: many(workAppGitHubMcpToolRepositoryAccess)
640
+ }));
641
+ const workAppGitHubProjectRepositoryAccessRelations = relations(workAppGitHubProjectRepositoryAccess, ({ one }) => ({ repository: one(workAppGitHubRepositories, {
642
+ fields: [workAppGitHubProjectRepositoryAccess.repositoryDbId],
643
+ references: [workAppGitHubRepositories.id]
644
+ }) }));
645
+ const workAppGitHubMcpToolRepositoryAccessRelations = relations(workAppGitHubMcpToolRepositoryAccess, ({ one }) => ({ repository: one(workAppGitHubRepositories, {
646
+ fields: [workAppGitHubMcpToolRepositoryAccess.repositoryDbId],
647
+ references: [workAppGitHubRepositories.id]
648
+ }) }));
481
649
 
482
650
  //#endregion
483
- export { account, apiKeys, contextCache, conversations, conversationsRelations, datasetRun, datasetRunConversationRelations, deviceCode, evaluationResult, evaluationRun, invitation, ledgerArtifacts, ledgerArtifactsRelations, member, messages, messagesRelations, organization, projectMetadata, runtime_schema_exports, session, ssoProvider, taskRelations, taskRelationsRelations, tasks, tasksRelations, triggerInvocations, user, verification };
651
+ export { account, apiKeys, contextCache, conversations, conversationsRelations, datasetRun, datasetRunConversationRelations, deviceCode, evaluationResult, evaluationRun, invitation, ledgerArtifacts, ledgerArtifactsRelations, member, messages, messagesRelations, organization, projectMetadata, runtime_schema_exports, session, ssoProvider, taskRelations, taskRelationsRelations, tasks, tasksRelations, triggerInvocations, user, verification, workAppGitHubInstallations, workAppGitHubInstallationsRelations, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubMcpToolRepositoryAccessRelations, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess, workAppGitHubProjectRepositoryAccessRelations, workAppGitHubRepositories, workAppGitHubRepositoriesRelations };
@@ -1,7 +1,7 @@
1
1
  import { getLogger } from "../utils/logger.js";
2
- import { createApiError } from "../utils/error.js";
3
2
  import { isRefWritable, resolveRef } from "./ref-helpers.js";
4
3
  import { ensureBranchExists } from "./branch.js";
4
+ import { createApiError } from "../utils/error.js";
5
5
 
6
6
  //#region src/dolt/ref-middleware.ts
7
7
  const logger = getLogger("ref-middleware");
package/dist/env.d.ts CHANGED
@@ -13,11 +13,12 @@ declare const envSchema: z.ZodObject<{
13
13
  INKEEP_AGENTS_RUN_DATABASE_URL: z.ZodOptional<z.ZodString>;
14
14
  POSTGRES_POOL_SIZE: z.ZodOptional<z.ZodString>;
15
15
  INKEEP_AGENTS_JWT_SIGNING_SECRET: z.ZodOptional<z.ZodString>;
16
- INKEEP_AGENTS_MANAGE_UI_URL: z.ZodOptional<z.ZodString>;
17
- INKEEP_AGENTS_API_URL: z.ZodOptional<z.ZodString>;
18
16
  BETTER_AUTH_SECRET: z.ZodOptional<z.ZodString>;
19
17
  TRUSTED_ORIGIN: z.ZodOptional<z.ZodString>;
20
18
  OAUTH_PROXY_PRODUCTION_URL: z.ZodOptional<z.ZodString>;
19
+ INKEEP_AGENTS_MANAGE_UI_URL: z.ZodOptional<z.ZodString>;
20
+ INKEEP_AGENTS_API_URL: z.ZodOptional<z.ZodString>;
21
+ GITHUB_MCP_API_KEY: z.ZodOptional<z.ZodString>;
21
22
  }, z.core.$strip>;
22
23
  declare const env: {
23
24
  ENVIRONMENT?: "development" | "production" | "pentest" | "test" | undefined;
@@ -25,11 +26,12 @@ declare const env: {
25
26
  INKEEP_AGENTS_RUN_DATABASE_URL?: string | undefined;
26
27
  POSTGRES_POOL_SIZE?: string | undefined;
27
28
  INKEEP_AGENTS_JWT_SIGNING_SECRET?: string | undefined;
28
- INKEEP_AGENTS_MANAGE_UI_URL?: string | undefined;
29
- INKEEP_AGENTS_API_URL?: string | undefined;
30
29
  BETTER_AUTH_SECRET?: string | undefined;
31
30
  TRUSTED_ORIGIN?: string | undefined;
32
31
  OAUTH_PROXY_PRODUCTION_URL?: string | undefined;
32
+ INKEEP_AGENTS_MANAGE_UI_URL?: string | undefined;
33
+ INKEEP_AGENTS_API_URL?: string | undefined;
34
+ GITHUB_MCP_API_KEY?: string | undefined;
33
35
  };
34
36
  type Env = z.infer<typeof envSchema>;
35
37
  //#endregion
package/dist/env.js CHANGED
@@ -37,16 +37,17 @@ const envSchema = z.object({
37
37
  "production",
38
38
  "pentest",
39
39
  "test"
40
- ]).optional(),
41
- INKEEP_AGENTS_MANAGE_DATABASE_URL: z.string().optional(),
42
- INKEEP_AGENTS_RUN_DATABASE_URL: z.string().optional(),
43
- POSTGRES_POOL_SIZE: z.string().optional(),
44
- INKEEP_AGENTS_JWT_SIGNING_SECRET: z.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional(),
45
- INKEEP_AGENTS_MANAGE_UI_URL: z.string().optional(),
46
- INKEEP_AGENTS_API_URL: z.string().optional(),
47
- BETTER_AUTH_SECRET: z.string().optional(),
48
- TRUSTED_ORIGIN: z.string().optional(),
49
- OAUTH_PROXY_PRODUCTION_URL: z.string().optional()
40
+ ]).optional().describe("Application environment mode"),
41
+ INKEEP_AGENTS_MANAGE_DATABASE_URL: z.string().optional().describe("PostgreSQL connection URL for the management database (Doltgres with Git version control)"),
42
+ INKEEP_AGENTS_RUN_DATABASE_URL: z.string().optional().describe("PostgreSQL connection URL for the runtime database (Doltgres with Git version control)"),
43
+ POSTGRES_POOL_SIZE: z.string().optional().describe("Maximum number of connections in the PostgreSQL connection pool"),
44
+ INKEEP_AGENTS_JWT_SIGNING_SECRET: z.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional().describe("Secret key for signing JWT tokens (minimum 32 characters)"),
45
+ BETTER_AUTH_SECRET: z.string().optional().describe("Secret key for Better Auth session encryption (change in production)"),
46
+ TRUSTED_ORIGIN: z.string().optional().describe("Trusted origin URL for CORS in local/preview environments"),
47
+ OAUTH_PROXY_PRODUCTION_URL: z.string().optional().describe("OAuth proxy URL for production environment (used in local/preview environments)"),
48
+ INKEEP_AGENTS_MANAGE_UI_URL: z.string().optional().describe("URL where the management UI is hosted"),
49
+ INKEEP_AGENTS_API_URL: z.string().optional().describe("URL where the agents management API is running"),
50
+ GITHUB_MCP_API_KEY: z.string().optional().describe("API key for the GitHub MCP")
50
51
  });
51
52
  const parseEnv = () => {
52
53
  try {