Skip to content

Instantly share code, notes, and snippets.

View phultquist's full-sized avatar
🍊

Patrick Hultquist phultquist

🍊
View GitHub Profile
@phultquist
phultquist / README.md
Last active June 21, 2026 16:59
Codex UserPromptSubmit + Stop hooks for exact database-backed session uploads

Upload complete Codex sessions with two hooks

This is the smallest reliable pattern for making Codex sessions reviewable in your own database:

  1. UserPromptSubmit immediately appends every new rollout byte, including the submitted prompt.
  2. Stop appends the assistant response and any tool activity from the completed turn.
  3. The receiver stores immutable byte fragments plus a committed cursor.
  4. A session is reconstructed by ID by concatenating verified fragments in ordinal order.

No polling job or queue is required. Uploads are small, append-only, idempotent, and scoped to one session.

/*
This svelte store is a reference to make super quick live and interactive pieces of code.
See its announcement at https://www.youtube.com/watch?v=A8jkJTWacow&t=18579s
*/
type Options<T> = {
validator: (data: T) => void;
};
export function live<T>(path: string, initialValue: T, options?: Options<T>) {