INNER CODE UNIT · Shell
TIMESTAMP
humanplane/homunculus · plugins/homunculus/scripts/observe.sh:17
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
# Build observation JSON based on event type
case "$EVENT_TYPE" in
prompt)
# UserPromptSubmit: capture user intent
PROMPT=$(echo "$INPUT" | jq -r '.prompt // empty' 2>/dev/null || echo "")
if [ -n "$PROMPT" ]; then
# Truncate long prompts to save space
PROMPT_SHORT=$(echo "$PROMPT" | head -c 500)
jq -nc --arg ts "$TIMESTAMP" --arg type "prompt" --arg prompt "$PROMPT_SHORT" \
'{timestamp: $ts, type: $type, prompt: $prompt}' >> "$OBS_FILE"
fi
;;
tool)
# PostToolUse: capture tool + result
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null || echo "")
TOOL_INPUT=$(echo "$INPUT" | jq -c '.tool_input // {}' 2>/dev/null || echo "{}")