HUB
Sign inSign up

sbx/hermes-agent-sessions:latest

Multi-platform
Manifest digest

sha256:62a0df1e74368672c6815750279330ed4168817d3de73acb839d82344e1c537a

Last pushed

5 days by dhibot

Type

Sandbox Kit

Manifest digest

sha256:62a0df1e74368672c6815750279330ed4168817d3de73acb839d82344e1c537a

yaml
schemaVersion: "3"
displayName: Hermes Agent host sessions
author: Docker, Inc. https://docker.com
description: Retain Hermes Agent session state on the host across sandbox removal
sourceUrl: https://github.com/docker-hardened-images/definitions
version: 1.0.1
licenses:
    - Apache-2.0
kind: mixin
requires:
    - hermes-agent
capabilities:
    - type: com.docker.sandbox/host-mount@1
      config:
        mode: "0700"
        path: /home/agent/hermes-history
    - type: com.docker.sandbox/lifecycle@1
      config:
        install:
            - command: |
                set -eu
                case "${SANDBOX_NAME:-}" in
                  ""|.|..|*/*) echo 'SANDBOX_NAME must be one path segment' >&2; exit 1 ;;
                esac
                state=/home/agent/.hermes
                history="/home/agent/hermes-history/$SANDBOX_NAME"
                mkdir -p "$state" "$history"
                for name in sessions memories skills; do
                  link="$state/$name"
                  target="$history/$name"
                  mkdir -p "$target"
                  if [ -L "$link" ]; then
                    [ "$(readlink "$link")" = "$target" ] || { echo "Refusing unexpected symlink: $link" >&2; exit 1; }
                    continue
                  fi
                  if [ -e "$link" ]; then
                    rmdir "$link" || { echo "Cannot replace existing state: $link" >&2; exit 1; }
                  fi
                  ln -s "$target" "$link"
                done
                [ -e "$history/state.db" ] || /opt/hermes-agent/app/.venv/bin/python -c 'import sqlite3, sys; db = sqlite3.connect(sys.argv[1]); db.execute("VACUUM"); db.close()' "$history/state.db"
                for name in state.db state.db-wal state.db-shm; do
                  link="$state/$name"
                  target="$history/$name"
                  if [ -L "$link" ]; then
                    [ "$(readlink "$link")" = "$target" ] || { echo "Refusing unexpected symlink: $link" >&2; exit 1; }
                    continue
                  fi
                  [ ! -e "$link" ] || { echo "Cannot replace existing state: $link" >&2; exit 1; }
                  ln -s "$target" "$link"
                done
              description: Link session database, transcripts, memories and skills into this sandbox's host directory
              env:
                - SANDBOX_NAME
              user: agent
args:
    version:
        required: true
        pattern: ^[0-9]+\.[0-9]+\.[0-9]+$
        buildArg: VERSION