Sign inSign up

sbx/codex-sessions:1.0.0

Multi-platform
Manifest digest

sha256:d6c74e00f913fe1d34c26d0c350298b95b2e9297582db3dbed2c2cc5bd249388

Last pushed

about 1 hour by dhibot

Type

Sandbox Kit

Manifest digest

sha256:d6c74e00f913fe1d34c26d0c350298b95b2e9297582db3dbed2c2cc5bd249388

yaml
schemaVersion: "3"
displayName: Codex host sessions
author: Docker, Inc. https://docker.com
description: Retain Codex session state on the host across sandbox removal
sourceUrl: https://github.com/docker-hardened-images/definitions
version: 1.0.0
licenses:
    - Apache-2.0
kind: mixin
requires:
    - codex
capabilities:
    - type: com.docker.sandbox/host-mount@1
      config:
        mode: "0700"
        path: /home/agent/codex-history
    - type: com.docker.sandbox/lifecycle@1
      config:
        install:
            - command: |
                set -eu
                state="/home/agent/.codex"
                history="/home/agent/codex-history"
                mkdir -p "$state"
                for name in sessions archived_sessions; do
                  link="$state/$name"
                  target="$history/$name"
                  mkdir -p "$target"
                  if [ -L "$link" ]; then
                    if [ "$(readlink "$link")" != "$target" ]; then
                      printf 'Refusing to replace unexpected symlink: %s\n' "$link" >&2
                      exit 1
                    fi
                    continue
                  fi
                  # rmdir preserves existing sessions and refuses mounted volumes.
                  if [ -e "$link" ]; then
                    if ! rmdir "$link"; then
                      printf 'Cannot replace %s; move existing state to the host directory first.\n' "$link" >&2
                      exit 1
                    fi
                  fi
                  ln -s "$target" "$link"
                done
              description: Link Codex session state to the host-shared directory
              user: agent
args:
    version:
        required: true
        description: Revision of the session-linking hook
        pattern: ^[0-9]+\.[0-9]+\.[0-9]+$
        buildArg: VERSION