Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions template/v4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ RUN apt-get update && apt-get upgrade -y && \
unzip /tmp/kirocli.zip -d /tmp && \
Q_INSTALL_GLOBAL=1 KIRO_CLI_SKIP_SETUP=1 /tmp/kirocli/install.sh && \
rm -rf /tmp/kirocli.zip /tmp/kirocli && \
: && \
# Clone SageMaker AI skills from GitHub
git clone --depth 1 https://github.com/awslabs/agent-plugins.git /tmp/agent-plugins && \
Copy link
Copy Markdown
Contributor

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?

mkdir -p /etc/sagemaker/skills && \
cp -r /tmp/agent-plugins/plugins/sagemaker-ai/skills/* /etc/sagemaker/skills/ && \
rm -rf /tmp/agent-plugins && \
# CodeEditor - create server, user data dirs
mkdir -p /opt/amazon/sagemaker/sagemaker-code-editor-server-data /opt/amazon/sagemaker/sagemaker-ui-code-editor-server-data /opt/amazon/sagemaker/sagemaker-code-editor-user-data \
&& chown $MAMBA_USER:$MAMBA_USER /opt/amazon/sagemaker/sagemaker-code-editor-server-data /opt/amazon/sagemaker/sagemaker-ui-code-editor-server-data /opt/amazon/sagemaker/sagemaker-code-editor-user-data && \
Expand Down
8 changes: 8 additions & 0 deletions template/v4/dirs/etc/sagemaker/sagemaker-default-agent.json
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"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all tools, this is what tools are available

"allowedTools": [],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add read-only Jupyter MCP tools

"mcpServers": {},
"resources": []
}
66 changes: 66 additions & 0 deletions template/v4/dirs/etc/sagemaker/skills/sync_skills.sh
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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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."
22 changes: 22 additions & 0 deletions template/v4/dirs/usr/local/bin/start-jupyter-server
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do errors get printed?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe we also have a sync_agent.sh

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
Expand Down