From 69920554f9e9a5f021904d6f94113d025731354b Mon Sep 17 00:00:00 2001 From: Oz Sayag Date: Wed, 4 Feb 2026 16:35:20 +0200 Subject: [PATCH 1/2] throubleshooter --- .claude-plugin/plugin.json | 2 +- skills/troubleshoot-production/SKILL.md | 157 ++++++++++++++++++ .../references/agent-conversations-api.md | 117 +++++++++++++ .../references/audit-logs-api.md | 99 +++++++++++ .../references/function-logs-api.md | 81 +++++++++ .../scripts/fetch-agent-conversations.sh | 109 ++++++++++++ .../scripts/fetch-audit-logs.sh | 150 +++++++++++++++++ .../scripts/fetch-function-logs.sh | 89 ++++++++++ 8 files changed, 803 insertions(+), 1 deletion(-) create mode 100644 skills/troubleshoot-production/SKILL.md create mode 100644 skills/troubleshoot-production/references/agent-conversations-api.md create mode 100644 skills/troubleshoot-production/references/audit-logs-api.md create mode 100644 skills/troubleshoot-production/references/function-logs-api.md create mode 100755 skills/troubleshoot-production/scripts/fetch-agent-conversations.sh create mode 100755 skills/troubleshoot-production/scripts/fetch-audit-logs.sh create mode 100755 skills/troubleshoot-production/scripts/fetch-function-logs.sh diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 8650277..e0275cc 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -2,5 +2,5 @@ "name": "base44", "version": "0.0.1", "description": "Base44 SDK skills for Claude Code - CLI operations and JavaScript/TypeScript SDK development", - "skills": ["./skills/base44-cli/", "./skills/base44-sdk/"] + "skills": ["./skills/base44-cli/", "./skills/base44-sdk/", "./skills/toubleshoot-production/"] } diff --git a/skills/troubleshoot-production/SKILL.md b/skills/troubleshoot-production/SKILL.md new file mode 100644 index 0000000..04cbea2 --- /dev/null +++ b/skills/troubleshoot-production/SKILL.md @@ -0,0 +1,157 @@ +--- +name: troubleshoot-production +description: Troubleshoot production issues using audit logs, backend function logs, and agent conversations. Use when investigating app errors, debugging function calls, tracking user activity, debugging agent tool failures, or diagnosing production problems in Base44 apps. +--- + +# Troubleshoot Production Issues + +## Security Rules + +**NEVER read, cat, or access any auth/token files directly. NEVER use curl with Authorization headers.** + +Always use the provided scripts - they handle authentication internally. If authentication fails, instruct the user to run `base44 login` (or `npx base44 login` if base44 is not installed globally). + +## Prerequisites + +Verify authentication before running scripts: + +```bash +base44 whoami || npx base44 whoami +``` + +If not authenticated or token expired, instruct user to run `base44 login` (or `npx base44 login` if base44 is not installed globally). + +## Scripts + +Scripts are located in the `scripts/` subdirectory of this skill. Use the absolute path based on where this SKILL.md file is located: + +``` +/scripts/fetch-audit-logs.sh +/scripts/fetch-function-logs.sh +/scripts/fetch-agent-conversations.sh +``` + +Scripts read the token internally - no token handling needed. + +### fetch-audit-logs.sh + +```bash +/scripts/fetch-audit-logs.sh [options] +``` + +**Options**: +| Option | Description | +|--------|-------------| +| `--status ` | Filter by outcome | +| `--event-types ''` | Filter by event types | +| `--user-email ` | Filter by user | +| `--start-date ` | From date | +| `--end-date ` | Until date | +| `--limit <1-1000>` | Results per page (default: 50) | +| `--order ` | Sort order (default: DESC) | + +**Examples**: +```bash +/scripts/fetch-audit-logs.sh abc123 --status failure +/scripts/fetch-audit-logs.sh abc123 --event-types '["api.function.call"]' +/scripts/fetch-audit-logs.sh abc123 --status failure --limit 10 --user-email user@example.com +``` + +### fetch-function-logs.sh + +```bash +/scripts/fetch-function-logs.sh [options] +``` + +**Options**: +| Option | Description | +|--------|-------------| +| `--since ` | Show logs from this time | +| `--until ` | Show logs until this time | + +**Examples**: +```bash +/scripts/fetch-function-logs.sh abc123 myFunction +/scripts/fetch-function-logs.sh abc123 myFunction --since 2024-01-01T00:00:00Z +/scripts/fetch-function-logs.sh abc123 myFunction --since 2024-01-01T00:00:00Z --until 2024-01-02T00:00:00Z +``` + +### fetch-agent-conversations.sh + +```bash +/scripts/fetch-agent-conversations.sh [options] +``` + +**Options**: +| Option | Description | +|--------|-------------| +| `--agent-name ` | Filter by agent name | +| `--limit ` | Max results (default: 50) | +| `--errors-only` | Only show conversations with tool errors | +| `--conversation-id ` | Fetch specific conversation | + +**Examples**: +```bash +/scripts/fetch-agent-conversations.sh abc123 +/scripts/fetch-agent-conversations.sh abc123 --agent-name task_agent +/scripts/fetch-agent-conversations.sh abc123 --errors-only +/scripts/fetch-agent-conversations.sh abc123 --conversation-id conv_123 +``` + +## Troubleshooting Flow + +### 1. Get App ID + +Read the app ID from `base44/.app.jsonc`: + +```bash +jq -r '.id' base44/.app.jsonc +``` + +Fallback: ask the user. + +### 2. Fetch Audit Logs + +```bash +APP_ID=$(jq -r '.id' base44/.app.jsonc) +/scripts/fetch-audit-logs.sh $APP_ID --filters '{"status": "failure"}' | jq '.events[] | {timestamp, event_type, error_code, metadata}' +``` + +### 3. Investigate Function Failures + +If audit logs show `api.function.call` failures, get runtime logs: + +```bash +# Get function name from audit log metadata.function_name +/scripts/fetch-function-logs.sh $APP_ID +``` + +### 4. Investigate Agent Failures + +If audit logs show `app.agent.conversation` events or users report agent issues: + +```bash +# Find conversations with tool errors +/scripts/fetch-agent-conversations.sh $APP_ID --errors-only + +# Get specific conversation details +/scripts/fetch-agent-conversations.sh $APP_ID --conversation-id + +# Extract error details +/scripts/fetch-agent-conversations.sh $APP_ID --errors-only | \ + jq '.[].messages[].tool_calls[]? | select(.status == "error") | {name, results}' +``` + +## Key Differences + +| Source | Contains | Use For | +|--------|----------|---------| +| Audit Logs | Event metadata (who, what, when, success/fail) | Finding what failed | +| Function Logs | Console output, stack traces | Debugging why backend functions failed | +| Agent Conversations | Full chat + tool calls with results | Debugging agent tool failures, RLS issues | + +## References + +- [Audit Logs API](references/audit-logs-api.md) - Event metadata, request/response schema +- [Function Logs API](references/function-logs-api.md) - Runtime logs, console output +- [Agent Conversations API](references/agent-conversations-api.md) - Chat history, tool call results diff --git a/skills/troubleshoot-production/references/agent-conversations-api.md b/skills/troubleshoot-production/references/agent-conversations-api.md new file mode 100644 index 0000000..f674eff --- /dev/null +++ b/skills/troubleshoot-production/references/agent-conversations-api.md @@ -0,0 +1,117 @@ +# Agent Conversations API + +Fetch AI agent conversation history including all messages and tool call results. + +## Authentication Flow + +Agent conversations use **app user tokens**, not platform tokens. The script handles this automatically: + +1. Platform token → `GET /api/apps/{app_id}/auth/token` → App user token +2. App user token → `GET /api/apps/{app_id}/agents/conversations` + +## Endpoints + +### List Conversations + +``` +GET /api/apps/{app_id}/agents/conversations +``` + +**Query Parameters**: +| Parameter | Type | Description | +|-----------|------|-------------| +| `agent_name` | string | Filter by agent name | +| `limit` | number | Max results (default: 50) | +| `skip` | number | Pagination offset | + +### Get Single Conversation + +``` +GET /api/apps/{app_id}/agents/conversations/{conversation_id} +``` + +## Response Schema + +### AgentConversation + +```json +{ + "id": "conversation_id_123", + "app_id": "app_id_456", + "created_by_id": "user_id_789", + "agent_name": "task_agent", + "metadata": {}, + "messages": [Message, ...] +} +``` + +### Message + +```json +{ + "id": "msg_uuid", + "role": "user" | "assistant" | "system", + "content": "message text or null for tool calls", + "tool_calls": [ToolCall, ...] | null, + "reasoning": { ... } | null, + "metadata": { + "created_date": "2024-01-15T10:30:00Z", + "created_by_email": "user@example.com" + } +} +``` + +### ToolCall + +```json +{ + "id": "call_uuid", + "name": "read_task", + "arguments_string": "{\"query\":{\"title\":\"test\"}}", + "status": "success" | "error" | "running" | "stopped" | "waiting_for_user_input", + "results": "result string or error message" +} +``` + +## Tool Call Status Values + +| Status | Description | +|--------|-------------| +| `success` | Tool executed successfully | +| `error` | Tool failed (check `results` for error message) | +| `running` | Tool currently executing | +| `stopped` | Execution was stopped | +| `waiting_for_user_input` | Awaiting user approval | + +## Common Tool Error Patterns + +### RLS Denial (Entity Not Found) +```json +{ + "name": "delete_task", + "status": "error", + "results": "Error deleting Task: status=404 message=Entity Task with ID abc123 not found" +} +``` +This typically indicates RLS blocked the operation - the entity exists but the user doesn't have permission. + +### Validation Error +```json +{ + "name": "create_task", + "status": "error", + "results": "Error creating Task: status=422 message=Validation error: title is required" +} +``` + +## Filtering for Errors + +Use jq to find conversations with failed tool calls: + +```bash +# Get conversations with errors +jq '[.[] | select(.messages[]?.tool_calls[]?.status == "error")]' + +# Extract just error details +jq '.messages[].tool_calls[]? | select(.status == "error") | {name, status, results}' +``` diff --git a/skills/troubleshoot-production/references/audit-logs-api.md b/skills/troubleshoot-production/references/audit-logs-api.md new file mode 100644 index 0000000..1ee3d54 --- /dev/null +++ b/skills/troubleshoot-production/references/audit-logs-api.md @@ -0,0 +1,99 @@ +# Audit Logs API Reference + +## Endpoint + +``` +POST /api/workspace/audit-logs/list?workspaceId={workspace_id} +Authorization: Bearer {token} +Content-Type: application/json +``` + +## Request + +| Field | Type | Description | +|-------|------|-------------| +| `app_id` | string | Filter by app | +| `event_types` | string[] | Filter by event types | +| `user_email` | string | Filter by user | +| `status` | `success` \| `failure` | Filter by outcome | +| `start_date` | ISO datetime | From date | +| `end_date` | ISO datetime | To date | +| `limit` | 1-1000 | Results per page (default 50) | +| `order` | `ASC` \| `DESC` | Sort order (default DESC) | +| `cursor_timestamp` | ISO datetime | Pagination cursor | +| `cursor_user_email` | string | Pagination cursor | + +## Response + +```json +{ + "events": [{ + "timestamp": "ISO datetime", + "user_email": "string", + "workspace_id": "string", + "app_id": "string", + "ip": "string", + "user_agent": "string", + "event_type": "string", + "status": "success | failure", + "error_code": "string", + "metadata": {} + }], + "pagination": { + "total": 0, + "limit": 50, + "has_more": false, + "next_cursor": null + } +} +``` + +## Event Types & Metadata + +### Runtime Events + +| Event Type | Metadata | +|------------|----------| +| `api.function.call` | `function_name`, `status_code` | +| `app.entity.created` | `entity_name`, `entity_id` | +| `app.entity.updated` | `entity_name`, `entity_id` | +| `app.entity.deleted` | `entity_name`, `entity_id` | +| `app.entity.bulk_created` | `entity_name`, `method`, `count` | +| `app.entity.bulk_deleted` | `entity_name`, `method`, `count` | +| `app.entity.query` | `entity_name`, `filter_fields` | +| `app.user.registered` | `target_email`, `role` | +| `app.user.updated` | `target_user_id`, `target_email` | +| `app.user.deleted` | `target_user_id`, `target_email` | +| `app.user.role_changed` | `target_email`, `old_role`, `new_role` | +| `app.user.invited` | `invitee_email`, `role` | +| `app.user.page_visit` | `page_name`, `origin_url` | +| `app.auth.login` | `auth_method`, `sso_provider` | +| `app.access.requested` | `requester_email` | +| `app.access.approved` | `target_email` | +| `app.access.denied` | `target_email` | +| `app.integration.executed` | `integration_name`, `action`, `duration_ms` | +| `app.automation.executed` | `automation_id`, `automation_name`, `automation_type` | +| `app.agent.conversation` | `agent_name`, `conversation_id`, `model` | + +### Setup Events + +| Event Type | Metadata | +|------------|----------| +| `app.created` | `app_name` | +| `app.deleted` | `app_name` | +| `app.published` | `checkpoint_id` | +| `app.schema.created` | `entity_name`, `has_rls` | +| `app.schema.updated` | `entity_name`, `rls_changed`, `has_rls` | +| `app.schema.deleted` | `entity_name` | +| `integration.stripe.*` | `sandbox_id` | +| `integration.oauth.*` | `integration_type` | +| `domain.*` | `domain`, `domain_id` | + +## Function Logs Endpoint + +``` +GET /api/apps/{app_id}/functions-mgmt/{function_name}/logs?since={ISO datetime} +Authorization: Bearer {token} +``` + +Returns Deno Deploy runtime logs (console output, errors, stack traces). diff --git a/skills/troubleshoot-production/references/function-logs-api.md b/skills/troubleshoot-production/references/function-logs-api.md new file mode 100644 index 0000000..40be5df --- /dev/null +++ b/skills/troubleshoot-production/references/function-logs-api.md @@ -0,0 +1,81 @@ +# Function Logs API Reference + +Runtime logs from Deno Deploy containing console output, errors, and stack traces. + +## Endpoint + +``` +GET /api/apps/{app_id}/functions-mgmt/{function_name}/logs +Authorization: Bearer {token} +``` + +## Query Parameters + +| Parameter | Type | Description | +|-----------|------|-------------| +| `since` | ISO datetime | Show logs from this time (default: `2021-08-01T00:00:00Z`) | +| `until` | ISO datetime | Show logs until this time | + +## Response + +Array of log entries from Deno Deploy: + +```json +[ + { + "time": "2024-01-15T10:30:00.000Z", + "level": "log", + "message": "Processing request for user 123" + }, + { + "time": "2024-01-15T10:30:00.050Z", + "level": "error", + "message": "TypeError: Cannot read property 'id' of undefined\n at handler (file:///src/index.ts:25:15)" + } +] +``` + +## Log Entry Fields + +| Field | Type | Description | +|-------|------|-------------| +| `time` | ISO datetime | When the log was emitted | +| `level` | string | Log level: `log`, `info`, `warn`, `error`, `debug` | +| `message` | string | The log message (includes stack traces for errors) | + +## Log Levels + +| Level | Source | +|-------|--------| +| `log` | `console.log()` | +| `info` | `console.info()` | +| `warn` | `console.warn()` | +| `error` | `console.error()` or uncaught exceptions | +| `debug` | `console.debug()` | + +## Limits + +- **Max message size**: 2KB (larger messages are trimmed) +- **Rate limit**: Up to 1000 log entries per second per deployment +- **Retention**: Based on Deno Deploy subscription plan + +## Script Usage + +```bash +# All logs +./scripts/fetch-function-logs.sh + +# Logs from specific time +./scripts/fetch-function-logs.sh --since 2024-01-01T00:00:00Z + +# Logs in time range +./scripts/fetch-function-logs.sh --since 2024-01-01T00:00:00Z --until 2024-01-02T00:00:00Z +``` + +## Filtering Errors + +To show only errors: + +```bash +./scripts/fetch-function-logs.sh | jq '[.[] | select(.level == "error")]' +``` diff --git a/skills/troubleshoot-production/scripts/fetch-agent-conversations.sh b/skills/troubleshoot-production/scripts/fetch-agent-conversations.sh new file mode 100755 index 0000000..45c34eb --- /dev/null +++ b/skills/troubleshoot-production/scripts/fetch-agent-conversations.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# +# Fetch agent conversations for a Base44 app +# Usage: fetch-agent-conversations.sh [options] +# +# Options: +# --agent-name Filter by agent name +# --limit Max results (default: 50) +# --errors-only Only show conversations with tool errors +# --conversation-id Fetch specific conversation +# + +set -e + +# Parse arguments +APP_ID="" +AGENT_NAME="" +LIMIT="50" +ERRORS_ONLY=false +CONVERSATION_ID="" + +while [[ $# -gt 0 ]]; do + case $1 in + --agent-name) + AGENT_NAME="$2" + shift 2 + ;; + --limit) + LIMIT="$2" + shift 2 + ;; + --errors-only) + ERRORS_ONLY=true + shift + ;; + --conversation-id) + CONVERSATION_ID="$2" + shift 2 + ;; + -*) + echo "Unknown option: $1" >&2 + exit 1 + ;; + *) + if [ -z "$APP_ID" ]; then + APP_ID="$1" + fi + shift + ;; + esac +done + +if [ -z "$APP_ID" ]; then + echo "Usage: fetch-agent-conversations.sh [options]" >&2 + echo "" >&2 + echo "Options:" >&2 + echo " --agent-name Filter by agent name" >&2 + echo " --limit Max results (default: 50)" >&2 + echo " --errors-only Only show conversations with tool errors" >&2 + echo " --conversation-id Fetch specific conversation" >&2 + exit 1 +fi + +# Read token from auth file +AUTH_FILE="$HOME/.base44/auth/auth.json" +if [ ! -f "$AUTH_FILE" ]; then + echo "Error: Not authenticated. Run 'base44 login' first." >&2 + exit 1 +fi + +PLATFORM_TOKEN=$(jq -r '.accessToken' "$AUTH_FILE") +if [ -z "$PLATFORM_TOKEN" ] || [ "$PLATFORM_TOKEN" = "null" ]; then + echo "Error: Invalid auth token. Run 'base44 login' to refresh." >&2 + exit 1 +fi + +BASE_URL="https://app.base44.com" + +# Step 1: Get app user token from platform token +APP_USER_TOKEN=$(curl -s "${BASE_URL}/api/apps/${APP_ID}/auth/token" \ + -H "Authorization: Bearer ${PLATFORM_TOKEN}" | jq -r '.token') + +if [ -z "$APP_USER_TOKEN" ] || [ "$APP_USER_TOKEN" = "null" ]; then + echo "Error: Failed to get app user token. Check app ID and permissions." >&2 + exit 1 +fi + +# Step 2: Fetch conversations +if [ -n "$CONVERSATION_ID" ]; then + # Fetch specific conversation + RESPONSE=$(curl -s "${BASE_URL}/api/apps/${APP_ID}/agents/conversations/${CONVERSATION_ID}" \ + -H "Authorization: Bearer ${APP_USER_TOKEN}") +else + # Build query params + QUERY_PARAMS="?limit=${LIMIT}" + if [ -n "$AGENT_NAME" ]; then + QUERY_PARAMS="${QUERY_PARAMS}&agent_name=${AGENT_NAME}" + fi + + RESPONSE=$(curl -s "${BASE_URL}/api/apps/${APP_ID}/agents/conversations${QUERY_PARAMS}" \ + -H "Authorization: Bearer ${APP_USER_TOKEN}") +fi + +# Step 3: Filter for errors if requested +if [ "$ERRORS_ONLY" = true ]; then + echo "$RESPONSE" | jq '[.[] | select(.messages[]?.tool_calls[]?.status == "error")]' +else + echo "$RESPONSE" | jq '.' +fi diff --git a/skills/troubleshoot-production/scripts/fetch-audit-logs.sh b/skills/troubleshoot-production/scripts/fetch-audit-logs.sh new file mode 100755 index 0000000..5c16f23 --- /dev/null +++ b/skills/troubleshoot-production/scripts/fetch-audit-logs.sh @@ -0,0 +1,150 @@ +#!/bin/bash +# +# Fetch audit logs for a Base44 app +# +# Usage: +# ./fetch-audit-logs.sh [options] +# +# Options: +# --status Filter by outcome +# --event-types Filter by event types, e.g. '["api.function.call"]' +# --user-email Filter by user email +# --start-date Filter events from this date +# --end-date Filter events until this date +# --limit <1-1000> Results per page (default: 50) +# --order Sort order (default: DESC) +# --cursor-timestamp Pagination cursor timestamp +# --cursor-user-email Pagination cursor user email +# +# Examples: +# ./fetch-audit-logs.sh abc123 +# ./fetch-audit-logs.sh abc123 --status failure +# ./fetch-audit-logs.sh abc123 --event-types '["api.function.call"]' +# ./fetch-audit-logs.sh abc123 --status failure --event-types '["api.function.call"]' --limit 10 +# ./fetch-audit-logs.sh abc123 --user-email user@example.com --start-date 2024-01-01T00:00:00Z +# + +set -e + +APP_ID="$1" + +if [[ -z "$APP_ID" ]]; then + echo "Error: app_id is required" >&2 + echo "Usage: $0 [options]" >&2 + exit 1 +fi + +shift + +# Initialize filter variables +STATUS="" +EVENT_TYPES="" +USER_EMAIL="" +START_DATE="" +END_DATE="" +LIMIT="" +ORDER="" +CURSOR_TIMESTAMP="" +CURSOR_USER_EMAIL="" + +# Parse options +while [[ $# -gt 0 ]]; do + case $1 in + --status) + STATUS="$2" + shift 2 + ;; + --event-types) + EVENT_TYPES="$2" + shift 2 + ;; + --user-email) + USER_EMAIL="$2" + shift 2 + ;; + --start-date) + START_DATE="$2" + shift 2 + ;; + --end-date) + END_DATE="$2" + shift 2 + ;; + --limit) + LIMIT="$2" + shift 2 + ;; + --order) + ORDER="$2" + shift 2 + ;; + --cursor-timestamp) + CURSOR_TIMESTAMP="$2" + shift 2 + ;; + --cursor-user-email) + CURSOR_USER_EMAIL="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" >&2 + exit 1 + ;; + esac +done + +# Read token from Base44 CLI auth file +AUTH_FILE="$HOME/.base44/auth/auth.json" +if [[ ! -f "$AUTH_FILE" ]]; then + echo "Error: Not authenticated. Run 'base44 login' first." >&2 + exit 1 +fi + +TOKEN=$(jq -r '.accessToken' "$AUTH_FILE") +if [[ -z "$TOKEN" || "$TOKEN" == "null" ]]; then + echo "Error: Invalid auth token. Run 'base44 login' to re-authenticate." >&2 + exit 1 +fi + +BASE_URL="https://app.base44.com" + +# Get workspace ID from app +WORKSPACE_ID=$(curl -s "$BASE_URL/api/apps/$APP_ID" \ + -H "Authorization: Bearer $TOKEN" | jq -r '.organization_id') + +if [[ -z "$WORKSPACE_ID" || "$WORKSPACE_ID" == "null" ]]; then + echo "Error: Could not get workspace ID for app $APP_ID" >&2 + exit 1 +fi + +# Build request body +REQUEST_BODY=$(jq -n \ + --arg app_id "$APP_ID" \ + --arg status "$STATUS" \ + --argjson event_types "${EVENT_TYPES:-null}" \ + --arg user_email "$USER_EMAIL" \ + --arg start_date "$START_DATE" \ + --arg end_date "$END_DATE" \ + --arg limit "$LIMIT" \ + --arg order "$ORDER" \ + --arg cursor_timestamp "$CURSOR_TIMESTAMP" \ + --arg cursor_user_email "$CURSOR_USER_EMAIL" \ + '{ + app_id: $app_id, + order: (if $order != "" then $order else "DESC" end), + limit: (if $limit != "" then ($limit | tonumber) else 50 end) + } + + (if $status != "" then {status: $status} else {} end) + + (if $event_types != null then {event_types: $event_types} else {} end) + + (if $user_email != "" then {user_email: $user_email} else {} end) + + (if $start_date != "" then {start_date: $start_date} else {} end) + + (if $end_date != "" then {end_date: $end_date} else {} end) + + (if $cursor_timestamp != "" then {cursor_timestamp: $cursor_timestamp} else {} end) + + (if $cursor_user_email != "" then {cursor_user_email: $cursor_user_email} else {} end)' +) + +# Fetch audit logs +curl -s -X POST "$BASE_URL/api/workspace/audit-logs/list?workspaceId=$WORKSPACE_ID" \ + -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + -d "$REQUEST_BODY" diff --git a/skills/troubleshoot-production/scripts/fetch-function-logs.sh b/skills/troubleshoot-production/scripts/fetch-function-logs.sh new file mode 100755 index 0000000..7b0f944 --- /dev/null +++ b/skills/troubleshoot-production/scripts/fetch-function-logs.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# +# Fetch runtime logs for a Base44 backend function (from Deno Deploy) +# +# Usage: +# ./fetch-function-logs.sh [options] +# +# Options: +# --since Show logs from this time (default: 2021-08-01T00:00:00Z) +# --until Show logs until this time +# +# Examples: +# ./fetch-function-logs.sh abc123 myFunction +# ./fetch-function-logs.sh abc123 myFunction --since 2024-01-01T00:00:00Z +# ./fetch-function-logs.sh abc123 myFunction --since 2024-01-01T00:00:00Z --until 2024-01-02T00:00:00Z +# + +set -e + +APP_ID="$1" +FUNCTION_NAME="$2" + +if [[ -z "$APP_ID" || -z "$FUNCTION_NAME" ]]; then + echo "Error: app_id and function_name are required" >&2 + echo "Usage: $0 [options]" >&2 + exit 1 +fi + +shift 2 + +# Initialize filter variables +SINCE="" +UNTIL="" + +# Parse options +while [[ $# -gt 0 ]]; do + case $1 in + --since) + SINCE="$2" + shift 2 + ;; + --until) + UNTIL="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" >&2 + exit 1 + ;; + esac +done + +# Read token from Base44 CLI auth file +AUTH_FILE="$HOME/.base44/auth/auth.json" +if [[ ! -f "$AUTH_FILE" ]]; then + echo "Error: Not authenticated. Run 'base44 login' first." >&2 + exit 1 +fi + +TOKEN=$(jq -r '.accessToken' "$AUTH_FILE") +if [[ -z "$TOKEN" || "$TOKEN" == "null" ]]; then + echo "Error: Invalid auth token. Run 'base44 login' to re-authenticate." >&2 + exit 1 +fi + +BASE_URL="https://app.base44.com" + +# Build URL with query parameters +URL="$BASE_URL/api/apps/$APP_ID/functions-mgmt/$FUNCTION_NAME/logs" +QUERY_PARAMS="" + +if [[ -n "$SINCE" ]]; then + QUERY_PARAMS="since=$SINCE" +fi + +if [[ -n "$UNTIL" ]]; then + if [[ -n "$QUERY_PARAMS" ]]; then + QUERY_PARAMS="$QUERY_PARAMS&until=$UNTIL" + else + QUERY_PARAMS="until=$UNTIL" + fi +fi + +if [[ -n "$QUERY_PARAMS" ]]; then + URL="$URL?$QUERY_PARAMS" +fi + +# Fetch function logs +curl -s "$URL" -H "Authorization: Bearer $TOKEN" From d5606ca1a9e4f57224b44f159da27c81a105405d Mon Sep 17 00:00:00 2001 From: Oz Sayag Date: Wed, 4 Feb 2026 16:36:26 +0200 Subject: [PATCH 2/2] rename skill --- .claude-plugin/plugin.json | 2 +- .../{troubleshoot-production => base44-troubleshooter}/SKILL.md | 2 +- .../references/agent-conversations-api.md | 0 .../references/audit-logs-api.md | 0 .../references/function-logs-api.md | 0 .../scripts/fetch-agent-conversations.sh | 0 .../scripts/fetch-audit-logs.sh | 0 .../scripts/fetch-function-logs.sh | 0 8 files changed, 2 insertions(+), 2 deletions(-) rename skills/{troubleshoot-production => base44-troubleshooter}/SKILL.md (99%) rename skills/{troubleshoot-production => base44-troubleshooter}/references/agent-conversations-api.md (100%) rename skills/{troubleshoot-production => base44-troubleshooter}/references/audit-logs-api.md (100%) rename skills/{troubleshoot-production => base44-troubleshooter}/references/function-logs-api.md (100%) rename skills/{troubleshoot-production => base44-troubleshooter}/scripts/fetch-agent-conversations.sh (100%) rename skills/{troubleshoot-production => base44-troubleshooter}/scripts/fetch-audit-logs.sh (100%) rename skills/{troubleshoot-production => base44-troubleshooter}/scripts/fetch-function-logs.sh (100%) diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index e0275cc..3600f0a 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -2,5 +2,5 @@ "name": "base44", "version": "0.0.1", "description": "Base44 SDK skills for Claude Code - CLI operations and JavaScript/TypeScript SDK development", - "skills": ["./skills/base44-cli/", "./skills/base44-sdk/", "./skills/toubleshoot-production/"] + "skills": ["./skills/base44-cli/", "./skills/base44-sdk/", "./skills/base44-troubleshooter/"] } diff --git a/skills/troubleshoot-production/SKILL.md b/skills/base44-troubleshooter/SKILL.md similarity index 99% rename from skills/troubleshoot-production/SKILL.md rename to skills/base44-troubleshooter/SKILL.md index 04cbea2..1d4ac1b 100644 --- a/skills/troubleshoot-production/SKILL.md +++ b/skills/base44-troubleshooter/SKILL.md @@ -1,5 +1,5 @@ --- -name: troubleshoot-production +name: base44-troubleshooter description: Troubleshoot production issues using audit logs, backend function logs, and agent conversations. Use when investigating app errors, debugging function calls, tracking user activity, debugging agent tool failures, or diagnosing production problems in Base44 apps. --- diff --git a/skills/troubleshoot-production/references/agent-conversations-api.md b/skills/base44-troubleshooter/references/agent-conversations-api.md similarity index 100% rename from skills/troubleshoot-production/references/agent-conversations-api.md rename to skills/base44-troubleshooter/references/agent-conversations-api.md diff --git a/skills/troubleshoot-production/references/audit-logs-api.md b/skills/base44-troubleshooter/references/audit-logs-api.md similarity index 100% rename from skills/troubleshoot-production/references/audit-logs-api.md rename to skills/base44-troubleshooter/references/audit-logs-api.md diff --git a/skills/troubleshoot-production/references/function-logs-api.md b/skills/base44-troubleshooter/references/function-logs-api.md similarity index 100% rename from skills/troubleshoot-production/references/function-logs-api.md rename to skills/base44-troubleshooter/references/function-logs-api.md diff --git a/skills/troubleshoot-production/scripts/fetch-agent-conversations.sh b/skills/base44-troubleshooter/scripts/fetch-agent-conversations.sh similarity index 100% rename from skills/troubleshoot-production/scripts/fetch-agent-conversations.sh rename to skills/base44-troubleshooter/scripts/fetch-agent-conversations.sh diff --git a/skills/troubleshoot-production/scripts/fetch-audit-logs.sh b/skills/base44-troubleshooter/scripts/fetch-audit-logs.sh similarity index 100% rename from skills/troubleshoot-production/scripts/fetch-audit-logs.sh rename to skills/base44-troubleshooter/scripts/fetch-audit-logs.sh diff --git a/skills/troubleshoot-production/scripts/fetch-function-logs.sh b/skills/base44-troubleshooter/scripts/fetch-function-logs.sh similarity index 100% rename from skills/troubleshoot-production/scripts/fetch-function-logs.sh rename to skills/base44-troubleshooter/scripts/fetch-function-logs.sh