fix: packer build — OOM kill and history builtin (#2274)

* fix: claude snapshot build — remove npm fallback from install command

The native install (curl | bash) succeeds but exits non-zero due to a
PATH warning. The || fallback then tries `npm install` which doesn't
exist on the "minimal" tier → exit 127.

Fix: replace npm fallback with binary existence check (same pattern
as hermes agent). If install exits non-zero but ~/.local/bin/claude
exists, the build succeeds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: snapshot cleanup and lookup — use name prefix instead of tags

DO Packer builder `tags` only apply to the temporary build droplet,
not the resulting snapshot image. Both the workflow cleanup step and
the CLI's findSpawnSnapshot() were querying by `tag_name` which
returned nothing — old snapshots piled up and the CLI couldn't find
existing snapshots.

Fix: filter by snapshot name prefix (`spawn-{agent}-`) instead of
tags, in both the workflow and the CLI. Remove misleading `tags`
from the Packer template. Add test cases for name-prefix filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: packer build failures — OOM kill + history builtin

Two issues introduced by PR #2271 (marketplace compliance):

1. Droplet downsized to s-1vcpu-1gb (1GB RAM) — Claude's native
   installer and zeroclaw's Rust build get OOM-killed. Restore
   s-2vcpu-2gb.

2. Cleanup provisioner uses `history -c` which is a bash builtin.
   Packer runs scripts with /bin/sh (dash on Ubuntu) which doesn't
   have it → exit 127 on ALL agents. Remove it — the .bash_history
   file deletion already handles persistent history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ahmed Abushagur 2026-03-06 22:15:39 -08:00 committed by GitHub
parent d77a067aa4
commit 5103a763b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,9 +35,9 @@ source "digitalocean" "spawn" {
api_token = var.do_api_token
image = "ubuntu-24-04-x64"
region = "sfo3"
# DO Marketplace recommends the smallest droplet ($6/mo s-1vcpu-1gb) for
# build compatibility snapshots built on s-1vcpu-1gb work on all sizes.
size = "s-1vcpu-1gb"
# 2 GB RAM needed Claude's native installer and zeroclaw's Rust build
# get OOM-killed on s-1vcpu-1gb. Snapshots built here work on all sizes.
size = "s-2vcpu-2gb"
ssh_username = "root"
snapshot_name = local.image_name
@ -116,8 +116,7 @@ build {
"rm -f /root/.ssh/authorized_keys",
"find /home -name authorized_keys -delete",
# Clear bash history
"history -c",
# Clear bash history (history -c is bash-only; Packer runs /bin/sh)
"rm -f /root/.bash_history",
"find /home -name .bash_history -delete",