-
Notifications
You must be signed in to change notification settings - Fork 110
[Sherpa] Add pre-packaged skills with persistence and subagent config for SMAI spaces #1143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fda6bed
ac0625c
17b0a07
b55c719
5f6b4cb
db890cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "sagemaker_default", | ||
| "description": "SageMaker AI assistant with pre-installed skills for model customization, evaluation, deployment, and HyperPod operations.", | ||
| "tools": ["@builtin"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all tools, this is what tools are available |
||
| "allowedTools": [], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add read-only Jupyter MCP tools |
||
| "mcpServers": {}, | ||
| "resources": [] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/bin/bash | ||
| # Syncs pre-packaged SageMaker skills from image to user's EBS. | ||
| set -eu | ||
|
|
||
| IMAGE_SKILLS_DIR="/etc/sagemaker/skills" | ||
| EBS_SKILLS_DIR="$HOME/.agent/skills" | ||
| LOCK_FILE="$EBS_SKILLS_DIR/.sagemaker-lock" | ||
| KIRO_SKILLS_DIR="$HOME/.kiro/skills" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can we parameterize this so it would be easy to add claude folder in future? can also do in follow up if/when we add claude |
||
|
|
||
| compute_checksum() { | ||
| (cd "$1" && find . -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | awk '{print $1}') | ||
| } | ||
|
|
||
| get_locked_checksum() { | ||
| [ -f "$LOCK_FILE" ] && jq -r --arg s "$1" '.skills[$s].checksum // empty' "$LOCK_FILE" 2>/dev/null | ||
| } | ||
|
|
||
| set_locked_checksum() { | ||
| [ -f "$LOCK_FILE" ] || echo '{"skills":{}}' > "$LOCK_FILE" | ||
| jq --arg s "$1" --arg c "$2" '.skills[$s].checksum = $c' "$LOCK_FILE" > "$LOCK_FILE.tmp" | ||
| mv "$LOCK_FILE.tmp" "$LOCK_FILE" | ||
| } | ||
|
|
||
| mkdir -p "$EBS_SKILLS_DIR" "$KIRO_SKILLS_DIR" | ||
|
|
||
| if [ ! -d "$IMAGE_SKILLS_DIR" ]; then | ||
| echo "No bundled skills found at $IMAGE_SKILLS_DIR, skipping." | ||
| exit 0 | ||
| fi | ||
|
|
||
| for skill_path in "$IMAGE_SKILLS_DIR"/*/; do | ||
| [ -d "$skill_path" ] || continue | ||
| skill_name=$(basename "$skill_path") | ||
| ebs_skill="$EBS_SKILLS_DIR/$skill_name" | ||
| image_checksum=$(compute_checksum "$skill_path") | ||
|
|
||
| if [ ! -d "$ebs_skill" ]; then | ||
| cp -r "$skill_path" "$ebs_skill" | ||
| set_locked_checksum "$skill_name" "$image_checksum" | ||
| echo "Installed skill '$skill_name'" | ||
| else | ||
| recorded_checksum=$(get_locked_checksum "$skill_name") | ||
| current_checksum=$(compute_checksum "$ebs_skill") | ||
|
|
||
| if [ "$current_checksum" = "$recorded_checksum" ]; then | ||
| if [ "$image_checksum" != "$recorded_checksum" ]; then | ||
| rm -rf "$ebs_skill" | ||
| cp -r "$skill_path" "$ebs_skill" | ||
| set_locked_checksum "$skill_name" "$image_checksum" | ||
| echo "Updated skill '$skill_name'" | ||
| else | ||
| echo "Skill '$skill_name' already current, skipping" | ||
| fi | ||
| else | ||
| echo "Skipping skill '$skill_name' — user modified" | ||
| fi | ||
| fi | ||
|
|
||
| kiro_link="$KIRO_SKILLS_DIR/$skill_name" | ||
| if [ ! -e "$kiro_link" ]; then | ||
| ln -s "$ebs_skill" "$kiro_link" | ||
| echo "Created symlink $kiro_link -> $ebs_skill" | ||
| fi | ||
| done | ||
|
|
||
| echo "Skills sync complete." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,28 @@ else | |
| micromamba remove -y sagemaker-studio-dataengineering-sessions sagemaker-studio-dataengineering-extensions | ||
| # Disable SMUS-specific extensions | ||
| jupyter labextension disable sagemaker-data-explorer:plugin | ||
| # Disable old Q chat extension | ||
| jupyter labextension disable @amzn/amazon_sagemaker_jupyter_ai_q_developer | ||
| fi | ||
|
|
||
| # Setup skills and subagent for SMAI spaces | ||
| if [ -n "$SAGEMAKER_APP_TYPE_LOWERCASE" ]; then | ||
| # Sync pre-packaged skills to EBS | ||
| bash /etc/sagemaker/skills/sync_skills.sh || echo "Warning: skills sync failed, continuing..." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do errors get printed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this log only available to customer? Thinking whether we should create metrics on this. |
||
|
|
||
| # Install subagent config (always overwrite) | ||
| mkdir -p "$HOME/.kiro/agents" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe we also have a |
||
| cp /etc/sagemaker/sagemaker-default-agent.json "$HOME/.kiro/agents/sagemaker-default-agent.json" | ||
|
|
||
| # Set default agent only if user hasn't configured one | ||
| KIRO_CLI_SETTINGS="$HOME/.kiro/settings/cli.json" | ||
| mkdir -p "$HOME/.kiro/settings" | ||
| if [ ! -f "$KIRO_CLI_SETTINGS" ]; then | ||
| echo '{"chat.defaultAgent":"sagemaker_default"}' > "$KIRO_CLI_SETTINGS" | ||
| elif ! jq -e '."chat.defaultAgent"' "$KIRO_CLI_SETTINGS" >/dev/null 2>&1; then | ||
| jq '. + {"chat.defaultAgent":"sagemaker_default"}' "$KIRO_CLI_SETTINGS" > "$KIRO_CLI_SETTINGS.tmp" | ||
| mv "$KIRO_CLI_SETTINGS.tmp" "$KIRO_CLI_SETTINGS" | ||
| fi | ||
| fi | ||
|
|
||
| # Enable S3AG plugin if TIP is enabled | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for now. can we see how we can write this in a way that easily scales if we have more github repos? like a config or list of the skills, and then the code reads from this and clones them?