remote-codex 0.1.6 → 0.1.8

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 (34) hide show
  1. package/apps/supervisor-api/dist/index.js +7515 -6185
  2. package/apps/supervisor-web/dist/assets/{highlighted-body-OFNGDK62-DvEvXPo5.js → highlighted-body-OFNGDK62-owvlMiML.js} +1 -1
  3. package/apps/supervisor-web/dist/assets/index-CbIt0KnL.css +32 -0
  4. package/apps/supervisor-web/dist/assets/index-CrcX157r.js +377 -0
  5. package/apps/supervisor-web/dist/assets/{xterm-CWQ1ih_R.js → xterm-BQ_J5An_.js} +1 -1
  6. package/apps/supervisor-web/dist/index.html +2 -2
  7. package/package.json +5 -1
  8. package/packages/agent-runtime/src/index.ts +2 -0
  9. package/packages/agent-runtime/src/registry.ts +44 -0
  10. package/packages/agent-runtime/src/types.ts +534 -0
  11. package/packages/codex/src/appServerManager.test.ts +328 -0
  12. package/packages/codex/src/appServerManager.ts +656 -0
  13. package/packages/codex/src/historyItems.ts +1256 -0
  14. package/packages/codex/src/hookHistory.ts +224 -0
  15. package/packages/codex/src/index.ts +6 -0
  16. package/packages/codex/src/jsonrpc.test.ts +58 -0
  17. package/packages/codex/src/jsonrpc.ts +198 -0
  18. package/packages/codex/src/requestMapper.test.ts +127 -0
  19. package/packages/codex/src/requestMapper.ts +511 -0
  20. package/packages/codex/src/runtimeAdapter.ts +743 -0
  21. package/packages/codex/src/types.ts +403 -0
  22. package/packages/db/migrations/0015_agent_provider_fields.sql +14 -0
  23. package/packages/db/migrations/0016_remove_codex_thread_goal_id.sql +46 -0
  24. package/packages/db/migrations/0017_remove_codex_thread_columns.sql +85 -0
  25. package/packages/db/src/client.ts +53 -0
  26. package/packages/db/src/index.ts +5 -0
  27. package/packages/db/src/migrate.test.ts +36 -0
  28. package/packages/db/src/migrate.ts +84 -0
  29. package/packages/db/src/repositories.ts +898 -0
  30. package/packages/db/src/schema.ts +177 -0
  31. package/packages/db/src/seed.ts +51 -0
  32. package/packages/shared/src/index.ts +880 -0
  33. package/apps/supervisor-web/dist/assets/index-CQu6sRq7.css +0 -32
  34. package/apps/supervisor-web/dist/assets/index-MELw9ga_.js +0 -377
@@ -0,0 +1,84 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { loadRuntimeConfig } from '../../config/src/index';
4
+ import { createDatabase } from './client';
5
+
6
+ interface MigrationRecord {
7
+ id: number;
8
+ name: string;
9
+ applied_at: string;
10
+ }
11
+
12
+ function findWorkspaceRoot(start = process.cwd()): string | null {
13
+ let current = path.resolve(start);
14
+
15
+ while (current !== path.dirname(current)) {
16
+ if (fs.existsSync(path.join(current, 'pnpm-workspace.yaml'))) {
17
+ return current;
18
+ }
19
+ current = path.dirname(current);
20
+ }
21
+
22
+ return null;
23
+ }
24
+
25
+ function resolvePackageRoot(start = process.cwd()): string {
26
+ const workspaceRoot = findWorkspaceRoot(start);
27
+ if (workspaceRoot && fs.existsSync(path.join(workspaceRoot, 'packages', 'db', 'migrations'))) {
28
+ return workspaceRoot;
29
+ }
30
+
31
+ if (process.env.REMOTE_CODEX_PACKAGE_ROOT) {
32
+ return path.resolve(process.env.REMOTE_CODEX_PACKAGE_ROOT);
33
+ }
34
+
35
+ throw new Error('Unable to locate package root from current working directory.');
36
+ }
37
+
38
+ export function getMigrationsDir(start = process.cwd()): string {
39
+ return path.join(resolvePackageRoot(start), 'packages', 'db', 'migrations');
40
+ }
41
+
42
+ export function runMigrations(databaseUrl: string) {
43
+ const { sqlite } = createDatabase(databaseUrl);
44
+
45
+ sqlite.exec(`
46
+ CREATE TABLE IF NOT EXISTS __migrations (
47
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
48
+ name TEXT NOT NULL UNIQUE,
49
+ applied_at TEXT NOT NULL
50
+ );
51
+ `);
52
+
53
+ const applied = sqlite
54
+ .prepare('SELECT name, applied_at, id FROM __migrations ORDER BY id ASC')
55
+ .all() as MigrationRecord[];
56
+ const appliedNames = new Set(applied.map((item) => item.name));
57
+
58
+ const migrations = fs
59
+ .readdirSync(getMigrationsDir())
60
+ .filter((file) => file.endsWith('.sql'))
61
+ .sort();
62
+
63
+ for (const migration of migrations) {
64
+ if (appliedNames.has(migration)) {
65
+ continue;
66
+ }
67
+
68
+ const sql = fs.readFileSync(path.join(getMigrationsDir(), migration), 'utf8');
69
+ sqlite.exec(sql);
70
+ sqlite
71
+ .prepare('INSERT INTO __migrations (name, applied_at) VALUES (?, ?)')
72
+ .run(migration, new Date().toISOString());
73
+ }
74
+
75
+ sqlite.close();
76
+ }
77
+
78
+ if (import.meta.url === `file://${process.argv[1]}`) {
79
+ if (fs.existsSync('.env')) {
80
+ process.loadEnvFile?.('.env');
81
+ }
82
+ const config = loadRuntimeConfig();
83
+ runMigrations(config.databaseUrl);
84
+ }