dsh 0.2.0-rc.2: in-container update (experimental channel), path-agnostic compose, upstream patches adapted to 0.1.x/0.2.x

This commit is contained in:
hermes committed 2026-10-01 19:21:19 +00:00
commit e6dcef9bf5
302 files changed
+75178

No files matched your search

@@ -0,0 +1,32 @@
import { readFile } from 'node:fs/promises'
import { durableReplace } from '../../../../platform/lib/atomic.mjs'
export const TERMINAL_UPDATE_STATES = new Set(['idle', 'success', 'failed'])
export class UpdateStateStore {
constructor(path, now = () => new Date()) {
this.path = path
this.now = now
}
async read() {
try {
return JSON.parse(await readFile(this.path, 'utf8'))
} catch (error) {
if (error?.code === 'ENOENT') return { status: 'idle', taskId: null, progress: 0, error: null }
throw error
}
}
async write(status, fields = {}) {
const previous = await this.read()
const next = {
...previous,
...fields,
status,
updatedAt: this.now().toISOString(),
}
await durableReplace(this.path, `${JSON.stringify(next)}\n`)
return Object.freeze(next)
}
}