From c705e020f3da6bfca8a0d6bb994e122957ed0275 Mon Sep 17 00:00:00 2001 From: Daniel Law Date: Wed, 20 May 2026 23:34:07 +0000 Subject: [PATCH] Stamp metadata.anthropic_cookbook on managed-agent deploys --- scripts/deploy-managed-agent.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/deploy-managed-agent.sh b/scripts/deploy-managed-agent.sh index b6966f1..55bb9d7 100755 --- a/scripts/deploy-managed-agent.sh +++ b/scripts/deploy-managed-agent.sh @@ -25,6 +25,12 @@ API="${ANTHROPIC_API_BASE:-https://api.anthropic.com}" [[ -f "$DIR/agent.yaml" ]] || { echo "no manifest at $DIR/agent.yaml" >&2; exit 1; } +# REPO_SLUG derives from the git remote so this script stays copy-identical +# across vertical repos; override via env if running outside a checkout. +REPO_SLUG="${REPO_SLUG:-$(basename -s .git "$(git config --get remote.origin.url)")}" +: "${REPO_SLUG:?cannot derive REPO_SLUG from git remote; set REPO_SLUG env var}" +COOKBOOK_TAG="${REPO_SLUG}/${ROLE}" + # Validate SKILL_TITLE_PREFIX against the same allowlist the YAML env-var # substitution uses. This string flows into `curl -F display_title=...`; # without validation, a hostile prefix could inject extra multipart fields @@ -165,6 +171,7 @@ create_agent() { sub_ids=$(jq --arg i "$sid" --argjson v "$sver" '. + [{type:"agent", id:$i, version:$v}]' <<<"$sub_ids") done < <(jq -r '.callable_agents[]?.manifest // empty' <<<"$json") json=$(jq --argjson c "$sub_ids" '.callable_agents=$c | del(.output_schema)' <<<"$json") + json=$(jq --arg ck "$COOKBOOK_TAG" '.metadata = ((.metadata // {}) + {anthropic_cookbook: $ck})' <<<"$json") [[ -n "${DEPLOY_DEBUG:-}" ]] && jq -c '{name, callable_agents}' <<<"$json" >&2 if [[ $DRY_RUN -eq 1 ]]; then @@ -196,4 +203,5 @@ OUT=$(create_agent "$DIR/agent.yaml") AGENT_ID=${OUT%% *} echo "deployed: $ROLE" echo "agent id: $AGENT_ID" +echo "cookbook: $COOKBOOK_TAG" echo "console: https://console.anthropic.com/agents/$AGENT_ID"