@toist/aja 0.6.1 → 0.8.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.
- package/CHANGELOG.md +57 -1
- package/README.md +62 -0
- package/package.json +11 -5
- package/src/cache-db.ts +1 -9
- package/src/cli.ts +153 -0
- package/src/client.ts +76 -0
- package/src/data-db.ts +1 -13
- package/src/index.ts +35 -2
- package/src/instance-metadata.ts +48 -0
- package/src/kinds/index.ts +23 -61
- package/src/lock.ts +27 -53
- package/src/migrate.ts +3 -3
- package/src/pipeline-store.ts +31 -0
- package/src/resources-fs.ts +43 -0
- package/src/resources.ts +27 -190
- package/src/run-events.ts +42 -0
- package/src/runtime-db.ts +11 -30
- package/src/server.ts +506 -496
- package/src/sqlite-runtime.ts +135 -0
- package/src/startRunner.ts +56 -70
- package/src/stores/sqlite.ts +243 -0
- package/src/stores/types.ts +18 -0
- package/src/config.ts +0 -129
- package/src/db-handles.ts +0 -70
- package/src/hitl.ts +0 -257
- package/src/instance.ts +0 -64
- package/src/kinds/control.ts +0 -26
- package/src/kinds/data.ts +0 -30
- package/src/kinds/db.ts +0 -92
- package/src/kinds/hitl.ts +0 -56
- package/src/kinds/http.ts +0 -134
- package/src/kinds/runs.ts +0 -130
- package/src/kinds/transform.ts +0 -123
- package/src/kinds/types.ts +0 -16
- package/src/pipeline.ts +0 -605
- package/src/runs.ts +0 -53
package/src/runtime-db.ts
CHANGED
|
@@ -1,44 +1,25 @@
|
|
|
1
1
|
// 2121
|
|
2
|
-
// Platform-internal runtime ledger. Holds:
|
|
3
|
-
// - runs — every pipeline execution (status, payload, result, steps, timing)
|
|
4
|
-
// - logs — log lines emitted from kinds during a run, scoped to run_id
|
|
5
|
-
// - tasks — HITL pending tasks (added in migration 002)
|
|
6
|
-
// - node_outputs — checkpoint-between-nodes memoization (added in migration 002)
|
|
7
|
-
//
|
|
8
|
-
// Schema is owned by the platform and evolved via numbered SQL migrations
|
|
9
|
-
// in ../migrations/. See migrate.ts for the runner.
|
|
10
|
-
//
|
|
11
|
-
// Kinds never receive a handle to this DB — they only see ctx.db (data
|
|
12
|
-
// store) and ctx.cache (capability), so they cannot accidentally touch
|
|
13
|
-
// runtime tables.
|
|
14
|
-
//
|
|
15
|
-
// Migration policy: by default the runner applies pending migrations at
|
|
16
|
-
// startup. RUNTIME_AUTO_MIGRATE=false flips to fail-loud — startup aborts if
|
|
17
|
-
// anything is pending.
|
|
18
|
-
//
|
|
19
|
-
// Lifecycle: openRuntimeDb() is a pure factory. The runner lock is acquired
|
|
20
|
-
// separately by db-handles.initDbs() before this is called, so two callers
|
|
21
|
-
// cannot race on migrations.
|
|
22
|
-
|
|
23
2
|
import { Database } from "bun:sqlite"
|
|
24
3
|
import { mkdirSync } from "node:fs"
|
|
25
4
|
import { dirname } from "node:path"
|
|
26
5
|
import { runMigrations, pendingMigrations } from "./migrate.ts"
|
|
27
|
-
import { runtimeDbPath } from "./config.ts"
|
|
28
6
|
|
|
29
|
-
export function openRuntimeDb(): Database {
|
|
30
|
-
const path = runtimeDbPath()
|
|
7
|
+
export function openRuntimeDb(path: string, opts: { skipMigrations?: boolean } = {}): Database {
|
|
31
8
|
mkdirSync(dirname(path), { recursive: true })
|
|
32
9
|
|
|
33
|
-
if (
|
|
10
|
+
if (opts.skipMigrations) {
|
|
11
|
+
const pending = pendingMigrations(path)
|
|
12
|
+
if (pending.length > 0) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`[runtime-db] ${pending.length} pending migration(s) with skipMigrations=true: ${pending.join(", ")}`,
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
} else if (process.env.RUNTIME_AUTO_MIGRATE === "false") {
|
|
34
18
|
const pending = pendingMigrations(path)
|
|
35
19
|
if (pending.length > 0) {
|
|
36
|
-
|
|
37
|
-
`[runtime-db] ${pending.length} pending migration(s); RUNTIME_AUTO_MIGRATE=false
|
|
20
|
+
throw new Error(
|
|
21
|
+
`[runtime-db] ${pending.length} pending migration(s); RUNTIME_AUTO_MIGRATE=false. Pending: ${pending.join(", ")}`,
|
|
38
22
|
)
|
|
39
|
-
console.error(`[runtime-db] pending: ${pending.join(", ")}`)
|
|
40
|
-
console.error(`[runtime-db] run migrations explicitly, or unset RUNTIME_AUTO_MIGRATE.`)
|
|
41
|
-
process.exit(1)
|
|
42
23
|
}
|
|
43
24
|
} else {
|
|
44
25
|
runMigrations(path)
|