{
  "schemaVersion": "1.0",
  "item": {
    "slug": "session-cost",
    "name": "Session Cost",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/khaney64/session-cost",
    "canonicalUrl": "https://clawhub.ai/khaney64/session-cost",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/session-cost",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=session-cost",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "scripts/session-cost.js"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T17:22:31.273Z",
      "expiresAt": "2026-05-14T17:22:31.273Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
        "contentDisposition": "attachment; filename=\"afrexai-annual-report-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/session-cost"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/session-cost",
    "agentPageUrl": "https://openagent3.xyz/skills/session-cost/agent",
    "manifestUrl": "https://openagent3.xyz/skills/session-cost/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/session-cost/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Session Cost",
        "body": "Analyze OpenClaw session logs for token usage, costs, and performance metrics grouped by agent and model.\n\nBy default, scans all agents in ~/.openclaw/agents/. Each agent's sessions are read from ~/.openclaw/agents/<name>/sessions/."
      },
      {
        "title": "Quick Start",
        "body": "# Summary across all agents\nnode scripts/session-cost.js\n\n# Show all session details\nnode scripts/session-cost.js --details\n\n# Show details for a specific session (searches across all agents)\nnode scripts/session-cost.js --details abc123"
      },
      {
        "title": "Options",
        "body": "--path <dir> — Directory to scan for .jsonl files (overrides agent auto-discovery)\n--agent <name> — Filter by agent name (e.g., main, codegen)\n--offset <time> — Only include sessions from the last N units (30m, 2h, 7d)\n--provider <name> — Filter by model provider (anthropic, openai, ollama, etc.)\n--details [session-id] — Show per-session details. Optionally pass a session ID to show just that session (searches across all agents for <id>.jsonl)\n--table — Show details in compact table format (use with --details)\n--format <type> — Output format: text (default), json, or discord\n--json — Shorthand for --format json (backwards compat)\n--help, -h — Show help message"
      },
      {
        "title": "Examples",
        "body": "# Last 24 hours summary\nnode scripts/session-cost.js --offset 24h\n\n# Only the main agent\nnode scripts/session-cost.js --agent main\n\n# Last 7 days, JSON output\nnode scripts/session-cost.js --offset 7d --json\n\n# Discord-friendly format (for bots/chat)\nnode scripts/session-cost.js --format discord\n\n# Discord format with filters\nnode scripts/session-cost.js --format discord --offset 24h --provider anthropic\n\n# Filter by provider\nnode scripts/session-cost.js --provider anthropic\n\n# All sessions in compact table format\nnode scripts/session-cost.js --details --table\n\n# Custom path with details (overrides agent discovery, scans exact directory)\nnode scripts/session-cost.js --path /other/dir --details\n\n# Single session detail (found automatically across agents)\nnode scripts/session-cost.js --details 9df7a399-8254-411b-a875-e7337df73d29\n\n# Anthropic sessions from last 24h in table format\nnode scripts/session-cost.js --provider anthropic --offset 24h --details --table"
      },
      {
        "title": "Text Summary (Default)",
        "body": "Results are grouped by agent, then by model within each agent. A grand total section shows per-agent subtotals and a combined total.\n\nFound 52 .jsonl files across 2 agents, 52 matched\n\n====================================================================================================\nSUMMARY BY AGENT\n====================================================================================================\n\nAgent: main\n\n  anthropic/claude-sonnet-4-5-20250929\n  --------------------------------------------------------------------------------\n    Sessions: 30\n    Tokens:   1,234,567 (input: 900,000, output: 334,567)\n    Cache:    read: 500,000 tokens, write: 200,000 tokens\n    Cost:     $12.3456\n      Input:       $5.4000\n      Output:      $5.0185\n      Cache read:  $1.5000  (included in total, discounted rate)\n      Cache write: $0.4271  (included in total)\n\n  anthropic/claude-opus-4-6\n  --------------------------------------------------------------------------------\n    Sessions: 5\n    Tokens:   250,000 (input: 180,000, output: 70,000)\n    ...\n\nAgent: codegen\n\n  anthropic/claude-sonnet-4-5-20250929\n  --------------------------------------------------------------------------------\n    Sessions: 17\n    ...\n\n====================================================================================================\nGRAND TOTAL\n====================================================================================================\n  main                 — 35 sessions, $15.8200\n  codegen              — 17 sessions, $8.5600\n\nAll agents (2)\n--------------------------------------------------------------------------------\n  Sessions: 52\n  Tokens:   ...\n  Cost:     $24.3800\n  ...\n\nWhen only a single agent is present, the grand total shows \"All models (N)\" instead."
      },
      {
        "title": "Text Details (--details)",
        "body": "Shows per-session breakdown (session ID, agent, model, duration, timestamps, tokens, cache, cost) followed by the agent/model summary."
      },
      {
        "title": "Table Format (--details --table)",
        "body": "Compact table view. When multiple agents are present, an Agent column is included.\n\nSESSION DETAILS\n============================================================================================================================================\nAgent          Model                              Duration    Tokens        Cache               Cost        Session\n────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\nmain           anthropic/claude-sonnet-4.5        45 min      128.5K        15.2K / 8.1K        $0.3245     abc123def456\ncodegen        anthropic/claude-sonnet-4.5        12 min      45.3K         2.1K / 1.5K         $0.8921     xyz789abc012\n\nWith a single agent, the Agent column is omitted and the table matches the previous format."
      },
      {
        "title": "JSON (--format json)",
        "body": "Results are nested by agent. Each agent contains its model summaries and an agent-level totals object. A top-level grandTotal aggregates across all agents.\n\n{\n  \"agents\": {\n    \"main\": {\n      \"models\": {\n        \"anthropic/claude-sonnet-4-5-20250929\": {\n          \"sessions\": 30,\n          \"tokens\": { \"input\": 900000, \"output\": 334567, \"total\": 1234567 },\n          \"cache\": { \"read\": 500000, \"write\": 200000 },\n          \"cost\": { \"total\": 12.3456, \"input\": 5.4, \"output\": 5.0185, \"cacheRead\": 1.5, \"cacheWrite\": 0.4271 }\n        }\n      },\n      \"totals\": {\n        \"sessions\": 35,\n        \"tokens\": { \"input\": 1080000, \"output\": 404567, \"total\": 1484567 },\n        \"cache\": { \"read\": 600000, \"write\": 250000 },\n        \"cost\": { \"total\": 15.82, ... }\n      }\n    },\n    \"codegen\": {\n      \"models\": { ... },\n      \"totals\": { ... }\n    }\n  },\n  \"grandTotal\": {\n    \"sessions\": 52,\n    \"tokens\": { \"input\": 1500000, \"output\": 600000, \"total\": 2100000 },\n    \"cache\": { \"read\": 800000, \"write\": 350000 },\n    \"cost\": { \"total\": 24.38, ... }\n  }\n}"
      },
      {
        "title": "Discord (--format discord)",
        "body": "Optimized for chat platforms (Discord, Slack, etc.) - concise, markdown-friendly, no tables:\n\n💰 **Usage Summary**\n(last 24h)\n\n**Total Cost:** $24.38\n**Total Tokens:** 2.1M\n**Sessions:** 52\n\n**By Agent:**\n• main: $15.82 (35 sessions)\n• codegen: $8.56 (17 sessions)\n\n**By Provider:**\n• anthropic: $22.50 (1.9M tokens)\n• openai: $1.88 (200K tokens)\n\n**Top Models:**\n• anthropic/claude-sonnet-4.5: $18.20 (1.5M tokens)\n• anthropic/claude-opus-4: $4.30 (400K tokens)\n• openai/gpt-4o: $1.88 (200K tokens)\n\nThe \"By Agent\" section is shown only when multiple agents are present."
      },
      {
        "title": "Output Fields",
        "body": "Agent — Agent name (derived from directory under ~/.openclaw/agents/)\nSessions — Number of session files analyzed\nTokens — Total, input, and output token counts\nCache — Cache read and write token counts\nCost — Total cost broken down by input, output, cache read, and cache write\nDuration — Session duration in minutes (details mode)\nTimestamps — First and last activity timestamps (details mode)"
      },
      {
        "title": "Notes",
        "body": "When --path is provided, it overrides agent auto-discovery and scans exactly that directory. The agent name is inferred from the path (e.g., .../agents/main/sessions → \"main\").\n--agent and --provider filters can be combined (e.g., --agent main --provider anthropic).\nSingle session lookup (--details <id>) searches across all discovered agents to find the session file."
      }
    ],
    "body": "Session Cost\n\nAnalyze OpenClaw session logs for token usage, costs, and performance metrics grouped by agent and model.\n\nBy default, scans all agents in ~/.openclaw/agents/. Each agent's sessions are read from ~/.openclaw/agents/<name>/sessions/.\n\nQuick Start\n# Summary across all agents\nnode scripts/session-cost.js\n\n# Show all session details\nnode scripts/session-cost.js --details\n\n# Show details for a specific session (searches across all agents)\nnode scripts/session-cost.js --details abc123\n\nOptions\n--path <dir> — Directory to scan for .jsonl files (overrides agent auto-discovery)\n--agent <name> — Filter by agent name (e.g., main, codegen)\n--offset <time> — Only include sessions from the last N units (30m, 2h, 7d)\n--provider <name> — Filter by model provider (anthropic, openai, ollama, etc.)\n--details [session-id] — Show per-session details. Optionally pass a session ID to show just that session (searches across all agents for <id>.jsonl)\n--table — Show details in compact table format (use with --details)\n--format <type> — Output format: text (default), json, or discord\n--json — Shorthand for --format json (backwards compat)\n--help, -h — Show help message\nExamples\n# Last 24 hours summary\nnode scripts/session-cost.js --offset 24h\n\n# Only the main agent\nnode scripts/session-cost.js --agent main\n\n# Last 7 days, JSON output\nnode scripts/session-cost.js --offset 7d --json\n\n# Discord-friendly format (for bots/chat)\nnode scripts/session-cost.js --format discord\n\n# Discord format with filters\nnode scripts/session-cost.js --format discord --offset 24h --provider anthropic\n\n# Filter by provider\nnode scripts/session-cost.js --provider anthropic\n\n# All sessions in compact table format\nnode scripts/session-cost.js --details --table\n\n# Custom path with details (overrides agent discovery, scans exact directory)\nnode scripts/session-cost.js --path /other/dir --details\n\n# Single session detail (found automatically across agents)\nnode scripts/session-cost.js --details 9df7a399-8254-411b-a875-e7337df73d29\n\n# Anthropic sessions from last 24h in table format\nnode scripts/session-cost.js --provider anthropic --offset 24h --details --table\n\nOutput Format\nText Summary (Default)\n\nResults are grouped by agent, then by model within each agent. A grand total section shows per-agent subtotals and a combined total.\n\nFound 52 .jsonl files across 2 agents, 52 matched\n\n====================================================================================================\nSUMMARY BY AGENT\n====================================================================================================\n\nAgent: main\n\n  anthropic/claude-sonnet-4-5-20250929\n  --------------------------------------------------------------------------------\n    Sessions: 30\n    Tokens:   1,234,567 (input: 900,000, output: 334,567)\n    Cache:    read: 500,000 tokens, write: 200,000 tokens\n    Cost:     $12.3456\n      Input:       $5.4000\n      Output:      $5.0185\n      Cache read:  $1.5000  (included in total, discounted rate)\n      Cache write: $0.4271  (included in total)\n\n  anthropic/claude-opus-4-6\n  --------------------------------------------------------------------------------\n    Sessions: 5\n    Tokens:   250,000 (input: 180,000, output: 70,000)\n    ...\n\nAgent: codegen\n\n  anthropic/claude-sonnet-4-5-20250929\n  --------------------------------------------------------------------------------\n    Sessions: 17\n    ...\n\n====================================================================================================\nGRAND TOTAL\n====================================================================================================\n  main                 — 35 sessions, $15.8200\n  codegen              — 17 sessions, $8.5600\n\nAll agents (2)\n--------------------------------------------------------------------------------\n  Sessions: 52\n  Tokens:   ...\n  Cost:     $24.3800\n  ...\n\n\nWhen only a single agent is present, the grand total shows \"All models (N)\" instead.\n\nText Details (--details)\n\nShows per-session breakdown (session ID, agent, model, duration, timestamps, tokens, cache, cost) followed by the agent/model summary.\n\nTable Format (--details --table)\n\nCompact table view. When multiple agents are present, an Agent column is included.\n\nSESSION DETAILS\n============================================================================================================================================\nAgent          Model                              Duration    Tokens        Cache               Cost        Session\n────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\nmain           anthropic/claude-sonnet-4.5        45 min      128.5K        15.2K / 8.1K        $0.3245     abc123def456\ncodegen        anthropic/claude-sonnet-4.5        12 min      45.3K         2.1K / 1.5K         $0.8921     xyz789abc012\n\n\nWith a single agent, the Agent column is omitted and the table matches the previous format.\n\nJSON (--format json)\n\nResults are nested by agent. Each agent contains its model summaries and an agent-level totals object. A top-level grandTotal aggregates across all agents.\n\n{\n  \"agents\": {\n    \"main\": {\n      \"models\": {\n        \"anthropic/claude-sonnet-4-5-20250929\": {\n          \"sessions\": 30,\n          \"tokens\": { \"input\": 900000, \"output\": 334567, \"total\": 1234567 },\n          \"cache\": { \"read\": 500000, \"write\": 200000 },\n          \"cost\": { \"total\": 12.3456, \"input\": 5.4, \"output\": 5.0185, \"cacheRead\": 1.5, \"cacheWrite\": 0.4271 }\n        }\n      },\n      \"totals\": {\n        \"sessions\": 35,\n        \"tokens\": { \"input\": 1080000, \"output\": 404567, \"total\": 1484567 },\n        \"cache\": { \"read\": 600000, \"write\": 250000 },\n        \"cost\": { \"total\": 15.82, ... }\n      }\n    },\n    \"codegen\": {\n      \"models\": { ... },\n      \"totals\": { ... }\n    }\n  },\n  \"grandTotal\": {\n    \"sessions\": 52,\n    \"tokens\": { \"input\": 1500000, \"output\": 600000, \"total\": 2100000 },\n    \"cache\": { \"read\": 800000, \"write\": 350000 },\n    \"cost\": { \"total\": 24.38, ... }\n  }\n}\n\nDiscord (--format discord)\n\nOptimized for chat platforms (Discord, Slack, etc.) - concise, markdown-friendly, no tables:\n\n💰 **Usage Summary**\n(last 24h)\n\n**Total Cost:** $24.38\n**Total Tokens:** 2.1M\n**Sessions:** 52\n\n**By Agent:**\n• main: $15.82 (35 sessions)\n• codegen: $8.56 (17 sessions)\n\n**By Provider:**\n• anthropic: $22.50 (1.9M tokens)\n• openai: $1.88 (200K tokens)\n\n**Top Models:**\n• anthropic/claude-sonnet-4.5: $18.20 (1.5M tokens)\n• anthropic/claude-opus-4: $4.30 (400K tokens)\n• openai/gpt-4o: $1.88 (200K tokens)\n\n\nThe \"By Agent\" section is shown only when multiple agents are present.\n\nOutput Fields\nAgent — Agent name (derived from directory under ~/.openclaw/agents/)\nSessions — Number of session files analyzed\nTokens — Total, input, and output token counts\nCache — Cache read and write token counts\nCost — Total cost broken down by input, output, cache read, and cache write\nDuration — Session duration in minutes (details mode)\nTimestamps — First and last activity timestamps (details mode)\nNotes\nWhen --path is provided, it overrides agent auto-discovery and scans exactly that directory. The agent name is inferred from the path (e.g., .../agents/main/sessions → \"main\").\n--agent and --provider filters can be combined (e.g., --agent main --provider anthropic).\nSingle session lookup (--details <id>) searches across all discovered agents to find the session file."
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/khaney64/session-cost",
    "publisherUrl": "https://clawhub.ai/khaney64/session-cost",
    "owner": "khaney64",
    "version": "1.0.3",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/session-cost",
    "downloadUrl": "https://openagent3.xyz/downloads/session-cost",
    "agentUrl": "https://openagent3.xyz/skills/session-cost/agent",
    "manifestUrl": "https://openagent3.xyz/skills/session-cost/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/session-cost/agent.md"
  }
}