openclaw-agent-wake-protocol 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ # onboard-agent.sh — Register, initialize, and schedule Genesis interview for a new LIFE agent
3
+ # Run this once per new agent after the gateway is running.
4
+ #
5
+ # Usage: ./scripts/onboard-agent.sh <agent-name> [workspace-dir]
6
+ # agent-name Short name used in OpenClaw (e.g. "finance", "platform")
7
+ # workspace-dir Path to the agent's shared workspace (default: auto-detected)
8
+ #
9
+ # The script will:
10
+ # 1. Detect the agent_id from IDENTITY.md if present
11
+ # 2. Register the agent in the LIFE gateway DB
12
+ # 3. Initialize the LIFE core (DATA dirs, traits.db, genesis questions)
13
+ # 4. Apply Genesis answers if answers.md already exists, else print interview instructions
14
+
15
+ set -euo pipefail
16
+
17
+ AGENT_NAME="${1:-}"
18
+ if [[ -z "$AGENT_NAME" ]]; then
19
+ echo "Usage: $0 <agent-name> [workspace-dir]"
20
+ echo " Examples: $0 finance"
21
+ echo " $0 platform /path/to/workspace"
22
+ exit 1
23
+ fi
24
+
25
+ DEFAULT_SHARED_DIR="$HOME/.openclaw/workspaces/quin/quin-workflows/agents/shared/$AGENT_NAME"
26
+ SHARED_DIR="${2:-$DEFAULT_SHARED_DIR}"
27
+ IDENTITY_PATH="$SHARED_DIR/IDENTITY.md"
28
+ ANSWERS_PATH="$SHARED_DIR/CORE/genesis/answers.md"
29
+
30
+ # Derive agent_id: read from IDENTITY.md or fall back to name
31
+ AGENT_ID=""
32
+ if [[ -f "$IDENTITY_PATH" ]]; then
33
+ AGENT_ID=$(sed -n 's/.*\*\*Agent ID:\*\*[[:space:]]*//p' "$IDENTITY_PATH" | head -n1 | tr -d '\r' | xargs 2>/dev/null || true)
34
+ fi
35
+ AGENT_ID="${AGENT_ID:-$AGENT_NAME}"
36
+
37
+ echo "=== Onboarding LIFE Agent ==="
38
+ echo " OpenClaw name: $AGENT_NAME"
39
+ echo " LIFE agent_id: $AGENT_ID"
40
+ echo " Workspace: $SHARED_DIR"
41
+ echo ""
42
+
43
+ if [[ ! -d "$SHARED_DIR" ]]; then
44
+ echo "ERROR: Workspace directory not found: $SHARED_DIR"
45
+ echo "Ensure Antfarm or your workflow provisioning has created this directory first."
46
+ exit 1
47
+ fi
48
+
49
+ # Helper: call mcporter and show output
50
+ mcall() {
51
+ local server_tool="$1"; shift
52
+ echo " mcporter call $server_tool $*"
53
+ mcporter call "$server_tool" "$@" 2>&1 || echo " (command failed — check gateway logs)"
54
+ echo ""
55
+ }
56
+
57
+ echo "Step 1: Registering agent in LIFE gateway DB..."
58
+ mcall "life-gateway.register_agent" \
59
+ "agent_id=$AGENT_ID" \
60
+ "name=$AGENT_NAME" \
61
+ "workspace_dir=$SHARED_DIR"
62
+
63
+ echo "Step 2: Initializing LIFE core (DATA dirs, traits DB, genesis questions)..."
64
+ mcall "life-gateway.initialize_life_core" "agent_id=$AGENT_ID"
65
+
66
+ if [[ -f "$ANSWERS_PATH" ]]; then
67
+ echo "Step 3: Genesis answers found — applying..."
68
+ mcall "life-gateway.apply_genesis_answers" \
69
+ "agent_id=$AGENT_ID" \
70
+ "answers_path=$ANSWERS_PATH"
71
+ echo "Step 4: Running wake protocol..."
72
+ mcall "life-gateway.wake" "agent_id=$AGENT_ID"
73
+ echo "=== Agent $AGENT_ID is live ==="
74
+ else
75
+ echo "Step 3: Genesis interview required."
76
+ echo ""
77
+ echo " The agent must complete the Genesis interview before it can wake."
78
+ echo " Questions are at: $SHARED_DIR/CORE/genesis/questions.md"
79
+ echo ""
80
+ echo " To run the interview via the main agent:"
81
+ echo " openclaw agent --agent main --message \\"
82
+ echo " 'Complete the LIFE Genesis interview for $AGENT_ID. Read CORE/genesis/questions.md"
83
+ echo " in $SHARED_DIR and save answers to $ANSWERS_PATH based on the agent persona.'"
84
+ echo ""
85
+ echo " After answers.md is saved, run:"
86
+ echo " mcporter call life-gateway.apply_genesis_answers agent_id=$AGENT_ID answers_path=$ANSWERS_PATH"
87
+ echo " mcporter call life-gateway.wake agent_id=$AGENT_ID"
88
+ fi