@inkeep/agents-core 0.0.0-dev-20260305071004 → 0.0.0-dev-20260305162109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/db/utils.js CHANGED
@@ -27,6 +27,10 @@ const confirmMigration = async (connectionString) => {
27
27
  console.error("❌ Error: Database URL is not set.");
28
28
  process.exit(1);
29
29
  }
30
+ if (process.env.CI === "true") {
31
+ console.log("CI environment detected — skipping interactive confirmation.");
32
+ return true;
33
+ }
30
34
  if (!isLocalhostUrl(connectionString)) {
31
35
  console.warn("⚠️ Warning: Database URL is not pointing to localhost. This operation may modify a production database.");
32
36
  if (!await askConfirmation("Do you want to proceed? (y/n): ")) {
@@ -49,7 +49,7 @@ const main = async () => {
49
49
  await doltCheckout(db)({ branch: branch.name });
50
50
  console.log(format.ok("[OK]"));
51
51
  process.stdout.write(`${format.dim("Action ")} sync schema… `);
52
- const result = await syncSchemaFromMain(db)();
52
+ const result = await syncSchemaFromMain(db)({ autoCommitPending: true });
53
53
  if (result.synced) {
54
54
  syncedCount += 1;
55
55
  console.log(format.ok("[SYNCED]"));
@@ -59,6 +59,7 @@ const main = async () => {
59
59
  console.log(format.err("[FAILED]"));
60
60
  console.log(`${format.dim("Result ")} ${format.err("Error")} ${format.dim(`(${ms(branchStartedAt, Date.now())})`)}`);
61
61
  console.log(`${format.dim("Details")} ${result.error}`);
62
+ break;
62
63
  } else {
63
64
  upToDateCount += 1;
64
65
  console.log(format.warn("[NOOP]"));
@@ -70,12 +71,14 @@ const main = async () => {
70
71
  const message = error instanceof Error ? error.message : String(error);
71
72
  console.log(`${format.dim("Result ")} ${format.err("Error")} ${format.dim(`(${ms(branchStartedAt, Date.now())})`)}`);
72
73
  console.log(`${format.dim("Details")} ${message}`);
74
+ break;
73
75
  }
74
76
  console.log("");
75
77
  }
76
78
  console.log(format.bold("─".repeat(80)));
77
79
  console.log(`${format.bold("Summary")} ${format.ok(`${syncedCount} synced`)}, ${format.warn(`${upToDateCount} up to date`)}, ${errorCount > 0 ? format.err(`${errorCount} failed`) : format.ok("0 failed")}`);
78
80
  console.log(format.dim(`Total: ${ms(startedAt, Date.now())}`));
81
+ if (errorCount > 0) process.exit(1);
79
82
  };
80
83
  main();
81
84
 
@@ -1,7 +1,8 @@
1
1
  import { loadEnvironmentFiles } from "../env.js";
2
2
  import { createAgentsManageDatabaseClient } from "../db/manage/manage-client.js";
3
- import { doltAddAndCommit, doltStatus } from "./commit.js";
3
+ import { doltAddAndCommit, doltReset, doltStatus } from "./commit.js";
4
4
  import { confirmMigration } from "../db/utils.js";
5
+ import { appendFileSync } from "node:fs";
5
6
  import { execSync } from "node:child_process";
6
7
 
7
8
  //#region src/dolt/migrate-dolt.ts
@@ -16,8 +17,24 @@ const commitMigrations = async () => {
16
17
  process.exit(1);
17
18
  }
18
19
  const db = createAgentsManageDatabaseClient({ connectionString });
19
- if ((await doltStatus(db)()).length > 0) await doltAddAndCommit(db)({ message: "Applied database migrations" });
20
- else console.log("ℹ️ No changes to commit - database is up to date\n");
20
+ let migrationsApplied = false;
21
+ try {
22
+ migrationsApplied = (await doltStatus(db)()).length > 0;
23
+ if (migrationsApplied) await doltAddAndCommit(db)({ message: "Applied database migrations" });
24
+ else console.log("ℹ️ No changes to commit - database is up to date\n");
25
+ } catch (error) {
26
+ console.error("❌ Error committing migrations, reverting:", error);
27
+ try {
28
+ await doltReset(db)({ hard: true });
29
+ console.log("✓ Successfully reverted uncommitted changes.");
30
+ } catch (resetError) {
31
+ console.error("⚠️ Warning: Reset failed (connection may be dead):", resetError);
32
+ console.error("Manual cleanup may be required: run DOLT_RESET('--hard') on the database.");
33
+ }
34
+ process.exit(1);
35
+ }
36
+ const ghOutput = process.env.GITHUB_OUTPUT;
37
+ if (ghOutput) appendFileSync(ghOutput, `migrations_applied=${migrationsApplied}\n`);
21
38
  };
22
39
  commitMigrations();
23
40