Skill: christinetyip/shared-memory (version 1.0.2)

--- name: shared-memory description: Share memories and state with other users. Use when user wants to share knowledge, create users/groups, grant permissions, set up family or team sharing, subscribe to memory changes, or manage access control on their memory knowledge base. This shared memory skill uses Ensue - a shared memory network for agents. metadata: clawdbot: emoji: "🤝" requires: env: - ENSUE_API_KEY primaryEnv: ENSUE_API_KEY homepage: https://ensue-network.ai --- # Shared Memory Share memories from your knowledge base with other users. Manage users, groups, and fine-grained permissions on namespaces. ## Quick Start ```bash # Create user and group {baseDir}/scripts/shared-memory.sh create-user mark {baseDir}/scripts/shared-memory.sh create-group family {baseDir}/scripts/shared-memory.sh add-member family mark # Grant access {baseDir}/scripts/shared-memory.sh grant group family read christine/shared/ {baseDir}/scripts/shared-memory.sh grant group family update christine/shared/ ``` ## Namespace Organization ``` <username>/ ├── private/ # Only this user ├── shared/ # Shared with others └── public/ # Read-only to others ``` Grant access to `mark/shared/` → all shared content Grant access to `mark/shared/recipes/` → just recipes ## Commands ### Users | Command | Description | |---------|-------------| | `create-user <username>` | Create user | | `delete-user <username>` | Delete user | ### Groups | Command | Description | |---------|-------------| | `create-group <name>` | Create group | | `delete-group <name>` | Delete group | | `add-member <group> <user>` | Add user to group | | `remove-member <group> <user>` | Remove user | ### Permissions | Command | Description | |---------|-------------| | `grant org <action> <pattern>` | Grant to org | | `grant user <name> <action> <pattern>` | Grant to user | | `grant group <name> <action> <pattern>` | Grant to group | | `revoke <grant_id>` | Revoke permission | | `list` | List all grants | | `list-permissions` | List effective permissions | **Actions**: `read`, `create`, `update`, `delete` ### Subscriptions | Command | Description | |---------|-------------| | `subscribe <key>` | Get notified on changes | | `unsubscribe <key>` | Stop notifications | | `list-subscriptions` | List subscriptions | ## Example: Family Sharing ```bash # Create user for partner {baseDir}/scripts/shared-memory.sh create-user mark # Create family group {baseDir}/scripts/shared-memory.sh create-group family {baseDir}/scripts/shared-memory.sh add-member family mark # Grant mutual access to shared/ namespaces {baseDir}/scripts/shared-memory.sh grant group family read christine/shared/ {baseDir}/scripts/shared-memory.sh grant group family create christine/shared/ {baseDir}/scripts/shared-memory.sh grant group family update christine/shared/ {baseDir}/scripts/shared-memory.sh grant group family read mark/shared/ {baseDir}/scripts/shared-memory.sh grant group family update mark/shared/ ``` ## Troubleshooting If commands fail, first check if an Ensue API key is configured: ```bash echo $ENSUE_API_KEY grep -A2 'ensue-learning-memory' ~/.clawdbot/clawdbot.json ``` If no API key found, tell user to get a free key at https://www.ensue-network.ai/login and configure in `~/.clawdbot/clawdbot.json`: ```json { "skills": { "entries": { "ensue-learning-memory": { "apiKey": "their-api-key-here" } } } } ``` If key exists but commands fail, the key may be invalid - have user generate a new one.

path: scripts/shared-memory.sh
content: #!/bin/bash
# Shared Memory - Manage users, groups, and permissions
# Uses Ensue - a shared memory network for agents
#
# Usage: ./scripts/shared-memory.sh <action> [args...]
#
# Actions:
#   create-user <username>
#   delete-user <username>
#   create-group <group_name>
#   delete-group <group_name>
#   add-member <group_name> <username>
#   remove-member <group_name> <username>
#   grant <target_type> <target_name> <action> <key_pattern>
#   revoke <grant_id>
#   list [target_type] [action]
#   subscribe <key_name>
#   unsubscribe <key_name>
#   list-subscriptions

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

# Find Ensue API key from various sources
find_api_key() {
  if [ -n "${ENSUE_API_KEY:-}" ]; then
    echo "$ENSUE_API_KEY"
    return
  fi

  # Check learning-memory plugin
  local key_file="$HOME/.claude/plugins/cache/ensue-learning-memory/ensue-learning-memory/0.2.0/.ensue-key"
  if [ -f "$key_file" ]; then
    cat "$key_file"
    return
  fi

  # Check ensue-memory plugin
  key_file="$HOME/.claude/plugins/cache/ensue-memory-network/ensue-memory/0.1.0/.ensue-key"
  if [ -f "$key_file" ]; then
    cat "$key_file"
    return
  fi

  # Check clawdbot config
  if [ -f "$HOME/.clawdbot/clawdbot.json" ]; then
    local key=$(grep -A2 '"ensue-learning-memory"' "$HOME/.clawdbot/clawdbot.json" | grep '"apiKey"' | cut -d'"' -f4)
    if [ -n "$key" ]; then
      echo "$key"
      return
    fi
  fi

  echo ""
}

ENSUE_API_KEY=$(find_api_key)

if [ -z "$ENSUE_API_KEY" ]; then
  echo '{"error":"ENSUE_API_KEY not found. Get a free API key at https://www.ensue-network.ai/login then configure it in clawdbot.json under skills.entries.ensue-learning-memory.apiKey or set as ENSUE_API_KEY environment variable."}'
  exit 1
fi

call_api() {
  local method="$1"
  local args="$2"

  curl -s -X POST https://api.ensue-network.ai/ \
    -H "Authorization: Bearer $ENSUE_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"jsonrpc\":\"2.0\",\"method\":\"tools/call\",\"params\":{\"name\":\"$method\",\"arguments\":$args},\"id\":1}" \
    | sed 's/^data: //'
}

ACTION="${1:-}"

case "$ACTION" in
  create-user)
    USERNAME="${2:?Username required}"
    call_api "share" "{\"command\":{\"command\":\"create_user\",\"username\":\"$USERNAME\"}}"
    ;;

  delete-user)
    USERNAME="${2:?Username required}"
    call_api "share" "{\"command\":{\"command\":\"delete_user\",\"username\":\"$USERNAME\"}}"
    ;;

  create-group)
    GROUP="${2:?Group name required}"
    call_api "share" "{\"command\":{\"command\":\"create_group\",\"group_name\":\"$GROUP\"}}"
    ;;

  delete-group)
    GROUP="${2:?Group name required}"
    call_api "share" "{\"command\":{\"command\":\"delete_group\",\"group_name\":\"$GROUP\"}}"
    ;;

  add-member)
    GROUP="${2:?Group name required}"
    USERNAME="${3:?Username required}"
    call_api "share" "{\"command\":{\"command\":\"add_member\",\"group_name\":\"$GROUP\",\"username\":\"$USERNAME\"}}"
    ;;

  remove-member)
    GROUP="${2:?Group name required}"
    USERNAME="${3:?Username required}"
    call_api "share" "{\"command\":{\"command\":\"remove_member\",\"group_name\":\"$GROUP\",\"username\":\"$USERNAME\"}}"
    ;;

  grant)
    TARGET_TYPE="${2:?Target type required (org|user|group)}"
    TARGET_NAME="${3:-}"
    GRANT_ACTION="${4:?Action required (read|create|update|delete)}"
    KEY_PATTERN="${5:?Key pattern required}"

    if [ "$TARGET_TYPE" = "org" ]; then
      call_api "share" "{\"command\":{\"command\":\"grant\",\"target\":{\"type\":\"org\"},\"action\":\"$GRANT_ACTION\",\"key_pattern\":\"$KEY_PATTERN\"}}"
    elif [ "$TARGET_TYPE" = "user" ]; then
      call_api "share" "{\"command\":{\"command\":\"grant\",\"target\":{\"type\":\"user\",\"username\":\"$TARGET_NAME\"},\"action\":\"$GRANT_ACTION\",\"key_pattern\":\"$KEY_PATTERN\"}}"
    elif [ "$TARGET_TYPE" = "group" ]; then
      call_api "share" "{\"command\":{\"command\":\"grant\",\"target\":{\"type\":\"group\",\"group_name\":\"$TARGET_NAME\"},\"action\":\"$GRANT_ACTION\",\"key_pattern\":\"$KEY_PATTERN\"}}"
    else
      echo '{"error":"Invalid target type. Use: org, user, or group"}'
      exit 1
    fi
    ;;

  revoke)
    GRANT_ID="${2:?Grant ID required}"
    call_api "share" "{\"command\":{\"command\":\"revoke\",\"grant_id\":\"$GRANT_ID\"}}"
    ;;

  list)
    TARGET_TYPE="${2:-}"
    LIST_ACTION="${3:-}"
    if [ -n "$TARGET_TYPE" ] && [ -n "$LIST_ACTION" ]; then
      call_api "share" "{\"command\":{\"command\":\"list\",\"target_type\":\"$TARGET_TYPE\",\"action\":\"$LIST_ACTION\"}}"
    elif [ -n "$TARGET_TYPE" ]; then
      call_api "share" "{\"command\":{\"command\":\"list\",\"target_type\":\"$TARGET_TYPE\"}}"
    else
      call_api "share" "{\"command\":{\"command\":\"list\"}}"
    fi
    ;;

  subscribe)
    KEY_NAME="${2:?Key name required}"
    call_api "subscribe_to_memory" "{\"key_name\":\"$KEY_NAME\"}"
    ;;

  unsubscribe)
    KEY_NAME="${2:?Key name required}"
    call_api "unsubscribe_from_memory" "{\"key_name\":\"$KEY_NAME\"}"
    ;;

  list-subscriptions)
    call_api "list_subscriptions" "{}"
    ;;

  list-permissions)
    call_api "list_permissions" "{}"
    ;;

  *)
    cat << 'EOF'
Shared Memory - Manage users, groups, and permissions
Uses Ensue - a shared memory network for agents

Usage: ./scripts/shared-memory.sh <action> [args...]

User Management:
  create-user <username>           Create a new user
  delete-user <username>           Delete a user

Group Management:
  create-group <group_name>        Create a new group
  delete-group <group_name>        Delete a group
  add-member <group> <username>    Add user to group
  remove-member <group> <username> Remove user from group

Permissions:
  grant org <action> <pattern>              Grant to entire org
  grant user <username> <action> <pattern>  Grant to specific user
  grant group <group> <action> <pattern>    Grant to group
  revoke <grant_id>                         Revoke a permission
  list [target_type] [action]               List permissions
  list-permissions                          List current user's permissions

Subscriptions:
  subscribe <key_name>             Subscribe to changes on a key
  unsubscribe <key_name>           Unsubscribe from a key
  list-subscriptions               List active subscriptions

Actions: read, create, update, delete
Patterns: Namespace prefix (e.g., "christine/shared/" matches all keys under that path)

Namespace Organization:
  <username>/
  ├── private/     -> Only this user
  ├── shared/      -> Shared with others
  └── public/      -> Read-only knowledge

Examples:
  ./scripts/shared-memory.sh create-user mark
  ./scripts/shared-memory.sh create-group family
  ./scripts/shared-memory.sh add-member family mark
  ./scripts/shared-memory.sh grant group family read christine/shared/
  ./scripts/shared-memory.sh subscribe christine/shared/shopping-list
EOF
    ;;
esac


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)