@inkeep/agents-core 0.42.0 → 0.44.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 (125) hide show
  1. package/dist/auth/auth.d.ts +28 -26
  2. package/dist/auth/auth.js +21 -16
  3. package/dist/auth/authz/client.d.ts +8 -3
  4. package/dist/auth/authz/client.js +23 -17
  5. package/dist/auth/authz/config.d.ts +50 -29
  6. package/dist/auth/authz/config.js +42 -33
  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 +0 -4
  10. package/dist/auth/authz/permissions.js +9 -13
  11. package/dist/auth/authz/sync.d.ts +23 -2
  12. package/dist/auth/authz/sync.js +127 -53
  13. package/dist/auth/init.d.ts +1 -0
  14. package/dist/auth/init.js +115 -0
  15. package/dist/auth/permissions.d.ts +9 -9
  16. package/dist/client-exports.d.ts +3 -6
  17. package/dist/client-exports.js +4 -7
  18. package/dist/constants/execution-limits-shared/defaults.d.ts +1 -1
  19. package/dist/constants/execution-limits-shared/defaults.js +1 -1
  20. package/dist/constants/execution-limits-shared/index.d.ts +1 -1
  21. package/dist/constants/otel-attributes.d.ts +5 -0
  22. package/dist/constants/otel-attributes.js +8 -3
  23. package/dist/constants/signoz-queries.d.ts +1 -0
  24. package/dist/constants/signoz-queries.js +2 -1
  25. package/dist/context/TemplateEngine.d.ts +0 -6
  26. package/dist/context/TemplateEngine.js +4 -18
  27. package/dist/credential-stores/keychain-store.d.ts +20 -8
  28. package/dist/credential-stores/keychain-store.js +107 -43
  29. package/dist/data-access/index.d.ts +5 -4
  30. package/dist/data-access/index.js +5 -4
  31. package/dist/data-access/manage/agentFull.js +70 -25
  32. package/dist/data-access/manage/agents.d.ts +41 -41
  33. package/dist/data-access/manage/agents.js +29 -21
  34. package/dist/data-access/manage/artifactComponents.d.ts +12 -12
  35. package/dist/data-access/manage/artifactComponents.js +1 -1
  36. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  37. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  38. package/dist/data-access/manage/dataComponents.js +1 -1
  39. package/dist/data-access/manage/functionTools.d.ts +44 -21
  40. package/dist/data-access/manage/functionTools.js +34 -22
  41. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
  42. package/dist/data-access/manage/subAgentRelations.d.ts +26 -26
  43. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  44. package/dist/data-access/manage/subAgents.d.ts +15 -15
  45. package/dist/data-access/manage/tools.d.ts +39 -28
  46. package/dist/data-access/manage/tools.js +73 -31
  47. package/dist/data-access/manage/triggers.d.ts +27 -1
  48. package/dist/data-access/runtime/apiKeys.d.ts +20 -20
  49. package/dist/data-access/runtime/cascade-delete.d.ts +48 -1
  50. package/dist/data-access/runtime/cascade-delete.js +52 -2
  51. package/dist/data-access/runtime/conversations.d.ts +24 -24
  52. package/dist/data-access/runtime/github-work-app-installations.d.ts +261 -0
  53. package/dist/data-access/runtime/github-work-app-installations.js +457 -0
  54. package/dist/data-access/runtime/messages.d.ts +18 -18
  55. package/dist/data-access/runtime/organizations.d.ts +2 -2
  56. package/dist/data-access/runtime/organizations.js +4 -4
  57. package/dist/data-access/runtime/tasks.d.ts +6 -6
  58. package/dist/db/manage/manage-schema.d.ts +533 -402
  59. package/dist/db/manage/manage-schema.js +38 -27
  60. package/dist/db/runtime/runtime-schema.d.ts +1021 -177
  61. package/dist/db/runtime/runtime-schema.js +173 -5
  62. package/dist/db/utils.d.ts +6 -0
  63. package/dist/db/utils.js +42 -0
  64. package/dist/dolt/branch.js +1 -1
  65. package/dist/dolt/branches-api.js +1 -1
  66. package/dist/dolt/index.d.ts +2 -2
  67. package/dist/dolt/index.js +4 -4
  68. package/dist/dolt/migrate-all-branches.js +6 -1
  69. package/dist/dolt/migrate-dolt.js +4 -1
  70. package/dist/dolt/ref-helpers.js +1 -1
  71. package/dist/dolt/ref-middleware.js +1 -1
  72. package/dist/dolt/ref-scope.js +1 -1
  73. package/dist/dolt/schema-sync.d.ts +2 -1
  74. package/dist/dolt/schema-sync.js +10 -1
  75. package/dist/env.d.ts +6 -4
  76. package/dist/env.js +11 -10
  77. package/dist/index.d.ts +15 -16
  78. package/dist/index.js +23 -24
  79. package/dist/types/@napi-rs__keyring/index.d.ts +14 -0
  80. package/dist/types/entities.d.ts +9 -2
  81. package/dist/types/index.d.ts +3 -3
  82. package/dist/types/utility.d.ts +17 -3
  83. package/dist/types/utility.js +2 -1
  84. package/dist/utils/JsonTransformer.d.ts +1 -3
  85. package/dist/utils/JsonTransformer.js +14 -23
  86. package/dist/utils/index.d.ts +3 -3
  87. package/dist/utils/index.js +3 -3
  88. package/dist/utils/jmespath-utils.d.ts +152 -0
  89. package/dist/utils/jmespath-utils.js +213 -0
  90. package/dist/utils/mcp-client.d.ts +1 -1
  91. package/dist/utils/mcp-client.js +1 -1
  92. package/dist/utils/signature-validation.d.ts +2 -0
  93. package/dist/utils/signature-validation.js +3 -0
  94. package/dist/utils/third-party-mcp-servers/composio-client.d.ts +13 -1
  95. package/dist/utils/third-party-mcp-servers/composio-client.js +24 -6
  96. package/dist/utils/third-party-mcp-servers/index.d.ts +2 -2
  97. package/dist/utils/third-party-mcp-servers/index.js +2 -2
  98. package/dist/utils/trigger-auth.d.ts +31 -8
  99. package/dist/utils/trigger-auth.js +121 -13
  100. package/dist/validation/agentFull.js +1 -1
  101. package/dist/validation/drizzle-schema-helpers.d.ts +4 -23
  102. package/dist/validation/drizzle-schema-helpers.js +3 -30
  103. package/dist/validation/index.d.ts +3 -5
  104. package/dist/validation/index.js +5 -7
  105. package/dist/validation/render-validation.js +19 -0
  106. package/dist/validation/schemas.d.ts +3675 -1665
  107. package/dist/validation/schemas.js +409 -94
  108. package/dist/validation/stream-event-schemas.d.ts +96 -1
  109. package/dist/validation/stream-event-schemas.js +67 -2
  110. package/drizzle/manage/0003_tiny_captain_universe.sql +8 -0
  111. package/drizzle/manage/0004_curious_phil_sheldon.sql +2 -0
  112. package/drizzle/manage/0005_silent_shatterstar.sql +53 -0
  113. package/drizzle/manage/0006_fixed_umar.sql +1 -0
  114. package/drizzle/manage/meta/0003_snapshot.json +3134 -0
  115. package/drizzle/manage/meta/0004_snapshot.json +3141 -0
  116. package/drizzle/manage/meta/0005_snapshot.json +3141 -0
  117. package/drizzle/manage/meta/0006_snapshot.json +3148 -0
  118. package/drizzle/manage/meta/_journal.json +28 -0
  119. package/drizzle/runtime/0010_previous_black_knight.sql +84 -0
  120. package/drizzle/runtime/meta/0010_snapshot.json +3066 -0
  121. package/drizzle/runtime/meta/_journal.json +7 -0
  122. package/package.json +12 -5
  123. package/spicedb/schema.zed +114 -0
  124. package/dist/validation/id-validation.d.ts +0 -24
  125. 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 };
@@ -0,0 +1,6 @@
1
+ //#region src/db/utils.d.ts
2
+ declare const isLocalhostUrl: (url: string | undefined) => boolean;
3
+ declare const askConfirmation: (question: string) => Promise<boolean>;
4
+ declare const confirmMigration: (connectionString: string | undefined) => Promise<boolean>;
5
+ //#endregion
6
+ export { askConfirmation, confirmMigration, isLocalhostUrl };
@@ -0,0 +1,42 @@
1
+ import * as readline from "node:readline";
2
+
3
+ //#region src/db/utils.ts
4
+ const isLocalhostUrl = (url) => {
5
+ if (!url) return false;
6
+ try {
7
+ const parsed = new URL(url);
8
+ return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1";
9
+ } catch {
10
+ return url.includes("localhost") || url.includes("127.0.0.1");
11
+ }
12
+ };
13
+ const askConfirmation = (question) => {
14
+ const rl = readline.createInterface({
15
+ input: process.stdin,
16
+ output: process.stdout
17
+ });
18
+ return new Promise((resolve) => {
19
+ rl.question(question, (answer) => {
20
+ rl.close();
21
+ resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
22
+ });
23
+ });
24
+ };
25
+ const confirmMigration = async (connectionString) => {
26
+ if (!connectionString) {
27
+ console.error("❌ Error: Database URL is not set.");
28
+ process.exit(1);
29
+ }
30
+ if (!isLocalhostUrl(connectionString)) {
31
+ console.warn("⚠️ Warning: Database URL is not pointing to localhost. This operation may modify a production database.");
32
+ if (!await askConfirmation("Do you want to proceed? (y/n): ")) {
33
+ console.log("Migration cancelled.");
34
+ process.exit(0);
35
+ }
36
+ console.log("");
37
+ }
38
+ return true;
39
+ };
40
+
41
+ //#endregion
42
+ export { askConfirmation, confirmMigration, isLocalhostUrl };
@@ -1,5 +1,5 @@
1
- import { doltHashOf } from "./commit.js";
2
1
  import { resolveRef } from "./ref-helpers.js";
2
+ import { doltHashOf } from "./commit.js";
3
3
  import { sql } from "drizzle-orm";
4
4
  import { logger } from "@composio/core";
5
5
 
@@ -1,5 +1,5 @@
1
- import { SCHEMA_SOURCE_BRANCH, ensureSchemaSync, getSchemaDiff, syncSchemaFromMain } from "./schema-sync.js";
2
1
  import { doltBranch, doltCheckout, doltDeleteBranch, doltGetBranchNamespace, doltListBranches } from "./branch.js";
2
+ import { SCHEMA_SOURCE_BRANCH, ensureSchemaSync, getSchemaDiff, syncSchemaFromMain } from "./schema-sync.js";
3
3
  import { sql } from "drizzle-orm";
4
4
 
5
5
  //#region src/dolt/branches-api.ts
@@ -6,5 +6,5 @@ import { doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltResolveC
6
6
  import { RefType, checkoutRef, getCurrentBranchOrCommit, getProjectMainResolvedRef, getProjectScopedRef, getTenantScopedRef, isRefWritable, isValidCommitHash, resolveRef } from "./ref-helpers.js";
7
7
  import { RefContext, RefMiddlewareOptions, createRefMiddleware, createWriteProtectionMiddleware, refMiddlewareFactory, writeProtectionMiddlewareFactory } from "./ref-middleware.js";
8
8
  import { NestedRefScopeError, WithRefOptions, getCurrentRefScope, getRefScopedDb, isInRefScope, withRef } from "./ref-scope.js";
9
- import { EnsureSchemaSyncOptions, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, syncSchemaFromMain } from "./schema-sync.js";
10
- export { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, EnsureSchemaSyncOptions, GetBranchParams, MAIN_BRANCH_SUFFIX, NestedRefScopeError, RefContext, RefMiddlewareOptions, RefType, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, WithRefOptions, areBranchesSchemaCompatible, branchScopes, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, isInRefScope, isProtectedBranchName, isRefWritable, isValidCommitHash, listBranches, listBranchesForAgent, refMiddlewareFactory, resolveRef, syncSchemaFromMain, withRef, writeProtectionMiddlewareFactory };
9
+ import { EnsureSchemaSyncOptions, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, isLocalhostUrl, syncSchemaFromMain } from "./schema-sync.js";
10
+ export { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, EnsureSchemaSyncOptions, GetBranchParams, MAIN_BRANCH_SUFFIX, NestedRefScopeError, RefContext, RefMiddlewareOptions, RefType, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, WithRefOptions, areBranchesSchemaCompatible, branchScopes, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, isInRefScope, isLocalhostUrl, isProtectedBranchName, isRefWritable, isValidCommitHash, listBranches, listBranchesForAgent, refMiddlewareFactory, resolveRef, syncSchemaFromMain, withRef, writeProtectionMiddlewareFactory };
@@ -1,11 +1,11 @@
1
- import { doltAdd, doltAddAndCommit, doltCommit, doltDeleteTag, doltHashOf, doltListTags, doltLog, doltReset, doltStatus, doltTag } from "./commit.js";
2
- import { doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltResolveConflicts, doltSchemaConflicts, doltTableConflicts } from "./merge.js";
3
- import { SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, syncSchemaFromMain } from "./schema-sync.js";
4
1
  import { MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTenantMainBranch, isProtectedBranchName, listBranches, listBranchesForAgent } from "./branches-api.js";
5
2
  import { checkoutRef, getCurrentBranchOrCommit, getProjectMainResolvedRef, getProjectScopedRef, getTenantScopedRef, isRefWritable, isValidCommitHash, resolveRef } from "./ref-helpers.js";
6
3
  import { doltActiveBranch, doltBranch, doltBranchExists, doltCheckout, doltDeleteBranch, doltGetBranchNamespace, doltListBranches, doltRenameBranch, ensureBranchExists } from "./branch.js";
4
+ import { doltAdd, doltAddAndCommit, doltCommit, doltDeleteTag, doltHashOf, doltListTags, doltLog, doltReset, doltStatus, doltTag } from "./commit.js";
5
+ import { doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltResolveConflicts, doltSchemaConflicts, doltTableConflicts } from "./merge.js";
6
+ import { SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, isLocalhostUrl, syncSchemaFromMain } from "./schema-sync.js";
7
7
  import { doltDiff, doltDiffSummary } from "./diff.js";
8
8
  import { createRefMiddleware, createWriteProtectionMiddleware, refMiddlewareFactory, writeProtectionMiddlewareFactory } from "./ref-middleware.js";
9
9
  import { NestedRefScopeError, getCurrentRefScope, getRefScopedDb, isInRefScope, withRef } from "./ref-scope.js";
10
10
 
11
- export { MAIN_BRANCH_SUFFIX, NestedRefScopeError, SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, isInRefScope, isProtectedBranchName, isRefWritable, isValidCommitHash, listBranches, listBranchesForAgent, refMiddlewareFactory, resolveRef, syncSchemaFromMain, withRef, writeProtectionMiddlewareFactory };
11
+ export { MAIN_BRANCH_SUFFIX, NestedRefScopeError, SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, isInRefScope, isLocalhostUrl, isProtectedBranchName, isRefWritable, isValidCommitHash, listBranches, listBranchesForAgent, refMiddlewareFactory, resolveRef, syncSchemaFromMain, withRef, writeProtectionMiddlewareFactory };
@@ -1,6 +1,8 @@
1
+ import { loadEnvironmentFiles } from "../env.js";
1
2
  import { createAgentsManageDatabaseClient } from "../db/manage/manage-client.js";
2
- import { syncSchemaFromMain } from "./schema-sync.js";
3
3
  import { doltCheckout, doltListBranches } from "./branch.js";
4
+ import { syncSchemaFromMain } from "./schema-sync.js";
5
+ import { confirmMigration } from "../db/utils.js";
4
6
 
5
7
  //#region src/dolt/migrate-all-branches.ts
6
8
  const ansi = {
@@ -22,6 +24,9 @@ const format = {
22
24
  };
23
25
  const ms = (start, end) => `${Math.max(0, end - start)}ms`;
24
26
  const main = async () => {
27
+ loadEnvironmentFiles();
28
+ const connectionString = process.env.INKEEP_AGENTS_MANAGE_DATABASE_URL;
29
+ await confirmMigration(connectionString);
25
30
  const startedAt = Date.now();
26
31
  const db = createAgentsManageDatabaseClient({});
27
32
  const branches = await doltListBranches(db)();
@@ -1,18 +1,21 @@
1
1
  import { loadEnvironmentFiles } from "../env.js";
2
2
  import { createAgentsManageDatabaseClient } from "../db/manage/manage-client.js";
3
3
  import { doltAddAndCommit, doltStatus } from "./commit.js";
4
+ import { confirmMigration } from "../db/utils.js";
4
5
  import { execSync } from "node:child_process";
5
6
 
6
7
  //#region src/dolt/migrate-dolt.ts
7
8
  const commitMigrations = async () => {
8
9
  loadEnvironmentFiles();
10
+ const connectionString = process.env.INKEEP_AGENTS_MANAGE_DATABASE_URL;
11
+ await confirmMigration(connectionString);
9
12
  try {
10
13
  execSync("drizzle-kit migrate --config=drizzle.manage.config.ts", { stdio: "inherit" });
11
14
  } catch (error) {
12
15
  console.error("❌ Error running migrations:", error);
13
16
  process.exit(1);
14
17
  }
15
- const db = createAgentsManageDatabaseClient({ connectionString: process.env.INKEEP_AGENTS_MANAGE_DATABASE_URL });
18
+ const db = createAgentsManageDatabaseClient({ connectionString });
16
19
  if ((await doltStatus(db)()).length > 0) await doltAddAndCommit(db)({ message: "Applied database migrations" });
17
20
  else console.log("ℹ️ No changes to commit - database is up to date\n");
18
21
  };
@@ -1,6 +1,6 @@
1
- import { doltHashOf, doltListTags } from "./commit.js";
2
1
  import { checkoutBranch } from "./branches-api.js";
3
2
  import { doltListBranches } from "./branch.js";
3
+ import { doltHashOf, doltListTags } from "./commit.js";
4
4
  import { sql } from "drizzle-orm";
5
5
 
6
6
  //#region src/dolt/ref-helpers.ts
@@ -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");
@@ -1,8 +1,8 @@
1
1
  import { manage_schema_exports } from "../db/manage/manage-schema.js";
2
2
  import { getLogger } from "../utils/logger.js";
3
3
  import { generateId } from "../utils/conversations.js";
4
- import { doltAddAndCommit, doltReset, doltStatus } from "./commit.js";
5
4
  import { checkoutBranch } from "./branches-api.js";
5
+ import { doltAddAndCommit, doltReset, doltStatus } from "./commit.js";
6
6
  import { drizzle } from "drizzle-orm/node-postgres";
7
7
  import { AsyncLocalStorage } from "node:async_hooks";
8
8
 
@@ -130,5 +130,6 @@ declare const areBranchesSchemaCompatible: (db: AgentsManageDatabaseClient) => (
130
130
  branchADifferences: SchemaDiff[];
131
131
  branchBDifferences: SchemaDiff[];
132
132
  }>;
133
+ declare const isLocalhostUrl: (url: string | undefined) => boolean;
133
134
  //#endregion
134
- export { EnsureSchemaSyncOptions, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, syncSchemaFromMain };
135
+ export { EnsureSchemaSyncOptions, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, isLocalhostUrl, syncSchemaFromMain };
@@ -241,6 +241,15 @@ const areBranchesSchemaCompatible = (db) => async (branchA, branchB) => {
241
241
  branchBDifferences: diffB
242
242
  };
243
243
  };
244
+ const isLocalhostUrl = (url) => {
245
+ if (!url) return false;
246
+ try {
247
+ const parsed = new URL(url);
248
+ return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1";
249
+ } catch {
250
+ return url.includes("localhost") || url.includes("127.0.0.1");
251
+ }
252
+ };
244
253
 
245
254
  //#endregion
246
- export { SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, syncSchemaFromMain };
255
+ export { SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, isLocalhostUrl, syncSchemaFromMain };
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 {