← All Event Families

foundation.protocols.ai.claude.*

Complete Claude Code session recording: prompts, responses, thinking, tool calls, MCP interactions, approvals, file changes, git operations, cost tracking, multi-agent coordination.

42
Events
40
Timeline
2
State

Contents

Design Notes

All 42 events use the foundation.protocols.ai.claude namespace prefix — nested under ai to make clear that Claude is one specific AI vendor within the broader foundation.protocols.ai.* governance framework. Other AI vendors follow the same pattern (e.g., foundation.protocols.ai.mistral.*).

1. Session Lifecycle

6 events tracking the full lifecycle of a Claude Code session — from start to end, interruption, export, and replay.

Timeline Event

foundation.protocols.ai.claude.session.start

Sent when a Claude Code session is initiated. This event is the thread root for all subsequent events in the session.

FieldTypeDescription
session_idstringUnique session identifier
modelstringModel identifier (e.g., claude-sonnet-4-20250514)
initiated_bystringMatrix user ID who started the session
working_directorystringFilesystem path of the project root
environmentobjectPlatform, shell, runtime versions
system_prompt_hashstringSHA-256 hash of the system prompt
tools_enabledstring[]List of enabled built-in tools
mcp_servers_connectedstring[]MCP servers available at session start
extended_thinking_enabledbooleanWhether extended thinking is on
max_tokensintegerMax output tokens per turn
timestampintegerUnix millisecond timestamp
{
  "type": "foundation.protocols.ai.claude.session.start",
  "content": {
    "session_id": "sess_01ABC...",
    "model": "claude-sonnet-4-20250514",
    "initiated_by": "@user:matrix.openearth.network",
    "working_directory": "/project/root",
    "environment": {
      "platform": "linux",
      "shell": "bash",
      "node_version": "20.11.0",
      "python_version": "3.12.0"
    },
    "system_prompt_hash": "sha256:abc123...",
    "tools_enabled": ["bash", "read_file", "write_file", "web_search"],
    "mcp_servers_connected": ["github", "postgres"],
    "extended_thinking_enabled": false,
    "max_tokens": 8096,
    "timestamp": 1711800000000
  }
}
Timeline Event

foundation.protocols.ai.claude.session.end

Sent when a session terminates normally. Includes total cost (string-encoded), token counts, and duration.

FieldTypeDescription
session_idstringSession identifier
reasonstringTermination reason (e.g., completed)
duration_msintegerTotal session duration in milliseconds
total_input_tokensintegerCumulative input tokens
total_output_tokensintegerCumulative output tokens
totalCoststringTotal cost as decimal string (e.g., "0.042000")
currencystringISO 4217 currency code
turnsintegerNumber of prompt-response turns
{
  "type": "foundation.protocols.ai.claude.session.end",
  "content": {
    "session_id": "sess_01ABC...",
    "reason": "completed",
    "duration_ms": 45200,
    "total_input_tokens": 12400,
    "total_output_tokens": 3200,
    "totalCost": "0.042000",
    "currency": "USD",
    "turns": 12,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.session.interrupted

Sent when a session is force-killed, crashes, or is abandoned.

FieldTypeDescription
session_idstringSession identifier
reasonstringInterruption reason
Values: user_killed, crash, timeout, network_failure, process_exit
signalstringUnix signal (e.g., SIGINT)
last_event_idstringEvent ID of the last known event before interruption
duration_msintegerSession duration before interruption
total_input_tokensintegerCumulative input tokens
total_output_tokensintegerCumulative output tokens
{
  "type": "foundation.protocols.ai.claude.session.interrupted",
  "content": {
    "session_id": "sess_01ABC...",
    "reason": "user_killed",
    "signal": "SIGINT",
    "last_event_id": "$last_known_event_id",
    "duration_ms": 12000,
    "total_input_tokens": 4200,
    "total_output_tokens": 800,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.session.exported

Sent when a session transcript is exported to an external system or file.

FieldTypeDescription
session_idstringSession identifier
exported_bystringMatrix user ID who exported
formatstringExport format (e.g., json)
destinationstringWhere exported (e.g., file)
mxc_uristringMXC URI of the exported file
timestampintegerUnix millisecond timestamp
{
  "type": "foundation.protocols.ai.claude.session.exported",
  "content": {
    "session_id": "sess_01ABC...",
    "exported_by": "@user:matrix.openearth.network",
    "format": "json",
    "destination": "file",
    "mxc_uri": "mxc://matrix.openearth.network/exportfile123",
    "timestamp": 1711900000000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.session.replayed

Sent when a prior session is replayed for review or debugging.

FieldTypeDescription
original_session_idstringSession being replayed
replayed_bystringMatrix user ID who initiated replay
replay_session_idstringNew session ID for the replay
timestampintegerUnix millisecond timestamp
{
  "type": "foundation.protocols.ai.claude.session.replayed",
  "content": {
    "original_session_id": "sess_01ABC...",
    "replayed_by": "@user:matrix.openearth.network",
    "replay_session_id": "sess_02DEF...",
    "timestamp": 1711950000000
  }
}
State Event

foundation.protocols.ai.claude.session.active

Tracks the currently active session in a room. Updated as sessions start/stop.

FieldTypeDescription
session_idstringActive session identifier
started_atintegerUnix millisecond start time
started_bystringMatrix user ID
modelstringModel identifier
statusstringCurrent session status
Values: running, paused, idle, terminated
{
  "type": "foundation.protocols.ai.claude.session.active",
  "state_key": "",
  "content": {
    "session_id": "sess_01ABC...",
    "started_at": 1711800000000,
    "started_by": "@user:matrix.openearth.network",
    "model": "claude-sonnet-4-20250514",
    "status": "running"
  }
}

2. Prompt & Response

5 events covering user prompts, AI responses, streaming chunks, interruptions, and extended thinking.

Timeline Event

foundation.protocols.ai.claude.prompt

A user or system prompt sent to Claude, with optional file attachments, images, and documents.

FieldTypeDescription
session_idstringSession identifier
prompt_idstringUnique prompt identifier
turnintegerTurn number within the session
rolestringMessage role (e.g., user)
textstringPrompt text content
attachmentsobject[]File attachments (path, hash, MXC URI)
imagesobject[]Image references
documentsobject[]Document references
{
  "type": "foundation.protocols.ai.claude.prompt",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "turn": 3,
    "role": "user",
    "text": "Refactor the authentication module to use JWT",
    "attachments": [
      {
        "type": "file",
        "path": "src/auth/auth.ts",
        "content_hash": "sha256:def456...",
        "mxc_uri": "mxc://matrix.openearth.network/file123"
      }
    ],
    "images": [],
    "documents": [],
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.response

Claude’s complete text response to a prompt, with token counts and stop reason.

FieldTypeDescription
session_idstringSession identifier
prompt_idstringThe prompt this responds to
turnintegerTurn number
textstringResponse text content
input_tokensintegerInput tokens for this turn
output_tokensintegerOutput tokens for this turn
cache_read_input_tokensintegerTokens read from prompt cache
cache_creation_input_tokensintegerTokens written to prompt cache
stop_reasonstringWhy generation stopped
Values: end_turn, tool_use, max_tokens, stop_sequence, interrupted
{
  "type": "foundation.protocols.ai.claude.response",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "turn": 3,
    "text": "I'll refactor the auth module. Let me start by reading the current implementation...",
    "input_tokens": 1840,
    "output_tokens": 320,
    "cache_read_input_tokens": 400,
    "cache_creation_input_tokens": 0,
    "stop_reason": "tool_use",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$prompt_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.response.chunk

An incremental streaming chunk from Claude’s response. Used when streaming is enabled.

FieldTypeDescription
session_idstringSession identifier
prompt_idstringPrompt being responded to
chunk_indexintegerSequential chunk index
delta_textstringIncremental text content
{
  "type": "foundation.protocols.ai.claude.response.chunk",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "chunk_index": 4,
    "delta_text": "...let me read the current file first",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$response_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.response.interrupted

Sent when a user interrupts Claude’s streaming response mid-flight.

FieldTypeDescription
session_idstringSession identifier
prompt_idstringPrompt being responded to
interrupted_bystringMatrix user ID who interrupted
partial_textstringText generated before interruption
chunks_receivedintegerNumber of chunks received before stop
timestampintegerUnix millisecond timestamp
{
  "type": "foundation.protocols.ai.claude.response.interrupted",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "interrupted_by": "@user:matrix.openearth.network",
    "partial_text": "I'll refactor the auth module. Let me start by...",
    "chunks_received": 4,
    "timestamp": 1711800005000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.thinking

Claude’s internal reasoning block when extended thinking is enabled.

FieldTypeDescription
session_idstringSession identifier
prompt_idstringPrompt being reasoned about
thinking_textstringInternal reasoning content
thinking_tokensintegerTokens used for thinking
{
  "type": "foundation.protocols.ai.claude.thinking",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "thinking_text": "The user wants to refactor auth to use JWT. I should first understand the current implementation...",
    "thinking_tokens": 540,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$prompt_event_id" }
    }
  }
}

3. Multimodal Input

2 events for images and documents provided as context to Claude.

Timeline Event

foundation.protocols.ai.claude.input.image

A user-provided image sent as part of a prompt. Stored via Matrix content repository (MXC URI).

FieldTypeDescription
session_idstringSession identifier
prompt_idstringAssociated prompt
mxc_uristringMXC URI of the uploaded image
media_typestringMIME type (e.g., image/png)
filenamestringOriginal filename
widthintegerImage width in pixels
heightintegerImage height in pixels
size_bytesintegerFile size in bytes
descriptionstringHuman-readable description
{
  "type": "foundation.protocols.ai.claude.input.image",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "mxc_uri": "mxc://matrix.openearth.network/image123",
    "media_type": "image/png",
    "filename": "screenshot.png",
    "width": 1920,
    "height": 1080,
    "size_bytes": 204800,
    "description": "Screenshot of the error in the browser console",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$prompt_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.input.document

A user-provided document (PDF, text file, etc.) sent as context.

FieldTypeDescription
session_idstringSession identifier
prompt_idstringAssociated prompt
mxc_uristringMXC URI of the uploaded document
media_typestringMIME type (e.g., application/pdf)
filenamestringOriginal filename
size_bytesintegerFile size in bytes
page_countintegerNumber of pages (if applicable)
descriptionstringHuman-readable description
{
  "type": "foundation.protocols.ai.claude.input.document",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "mxc_uri": "mxc://matrix.openearth.network/doc123",
    "media_type": "application/pdf",
    "filename": "architecture.pdf",
    "size_bytes": 512000,
    "page_count": 12,
    "description": "System architecture document",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$prompt_event_id" }
    }
  }
}

4. Tool Use (Built-in Tools)

3 events for built-in tool calls (bash, read_file, write_file, web_search), results, and errors.

Timeline Event

foundation.protocols.ai.claude.tool.call

Claude invoking a built-in tool (bash, read_file, write_file, web_search, etc.).

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringUnique tool use identifier
prompt_idstringAssociated prompt
tool_namestringName of the tool (e.g., bash)
tool_sourcestringSource: builtin
inputobjectTool input parameters
requires_approvalbooleanWhether human approval was required
{
  "type": "foundation.protocols.ai.claude.tool.call",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "tool_name": "bash",
    "tool_source": "builtin",
    "input": {
      "command": "cat src/auth/auth.ts"
    },
    "requires_approval": false,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$response_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.tool.result

The result returned to Claude from a built-in tool call.

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringLinks to the tool call
tool_namestringTool name
tool_sourcestringSource: builtin
outputstringTool output text
exit_codeintegerProcess exit code (for bash)
is_errorbooleanWhether the result indicates an error
duration_msintegerExecution duration in milliseconds
{
  "type": "foundation.protocols.ai.claude.tool.result",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_01ABC...",
    "tool_name": "bash",
    "tool_source": "builtin",
    "output": "import jwt from 'jsonwebtoken';\n...",
    "exit_code": 0,
    "is_error": false,
    "duration_ms": 42,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$tool_call_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.tool.error

A tool call that failed with an error (distinct from a tool result with is_error: true).

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringLinks to the tool call
tool_namestringTool name
tool_sourcestringSource: builtin
error_typestringError classification
Values: timeout, permission_denied, not_found, execution_error, serialization_error, network_error
error_messagestringHuman-readable error message
exit_codeintegerProcess exit code
duration_msintegerTime until failure in milliseconds
{
  "type": "foundation.protocols.ai.claude.tool.error",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_01ABC...",
    "tool_name": "bash",
    "tool_source": "builtin",
    "error_type": "timeout",
    "error_message": "Command timed out after 30000ms",
    "exit_code": 124,
    "duration_ms": 30000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$tool_call_event_id" }
    }
  }
}

5. MCP (Model Context Protocol) Interactions

5 events for MCP server connections, tool calls, results, prompt templates, and resource reads.

Timeline Event

foundation.protocols.ai.claude.mcp.server.connected

An MCP server was connected to the session. Lists available tools, resources, and prompts.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
server_urlstringMCP server URL
tools_availablestring[]Tools provided by this server
resources_availablestring[]Resources provided by this server
prompts_availablestring[]Prompt templates provided
protocol_versionstringMCP protocol version
{
  "type": "foundation.protocols.ai.claude.mcp.server.connected",
  "content": {
    "session_id": "sess_01ABC...",
    "server_name": "github",
    "server_url": "https://mcp.github.com/sse",
    "tools_available": ["create_issue", "list_prs", "get_file"],
    "resources_available": ["repo://owner/repo/main"],
    "prompts_available": ["summarize_pr"],
    "protocol_version": "2024-11-05",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.mcp.tool.call

A tool call made specifically to an MCP server.

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringUnique tool use identifier
prompt_idstringAssociated prompt
mcp_serverstringMCP server name
tool_namestringTool being invoked
inputobjectTool input parameters
requires_approvalbooleanWhether human approval was required
{
  "type": "foundation.protocols.ai.claude.mcp.tool.call",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_mcp_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "mcp_server": "github",
    "tool_name": "create_issue",
    "input": {
      "owner": "openearth",
      "repo": "auth-service",
      "title": "Refactor auth to JWT",
      "body": "As discussed, migrating from session-based to JWT auth."
    },
    "requires_approval": false,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$response_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.mcp.tool.result

Result returned from an MCP server tool call.

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringLinks to the MCP tool call
mcp_serverstringMCP server name
tool_namestringTool that was invoked
outputobjectTool output data
is_errorbooleanWhether the result indicates an error
duration_msintegerExecution duration in milliseconds
{
  "type": "foundation.protocols.ai.claude.mcp.tool.result",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_mcp_01ABC...",
    "mcp_server": "github",
    "tool_name": "create_issue",
    "output": {
      "issue_number": 42,
      "url": "https://github.com/openearth/auth-service/issues/42"
    },
    "is_error": false,
    "duration_ms": 380,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$mcp_tool_call_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.mcp.prompt.used

An MCP-provided prompt template was invoked.

FieldTypeDescription
session_idstringSession identifier
mcp_serverstringMCP server name
prompt_namestringPrompt template name
argumentsobjectArguments passed to the template
{
  "type": "foundation.protocols.ai.claude.mcp.prompt.used",
  "content": {
    "session_id": "sess_01ABC...",
    "mcp_server": "github",
    "prompt_name": "summarize_pr",
    "arguments": {
      "pr_number": 17
    },
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.mcp.resource.read

An MCP resource was read by Claude.

FieldTypeDescription
session_idstringSession identifier
mcp_serverstringMCP server name
resource_uristringResource URI
resource_typestringMIME type of the resource
size_bytesintegerResource size in bytes
{
  "type": "foundation.protocols.ai.claude.mcp.resource.read",
  "content": {
    "session_id": "sess_01ABC...",
    "mcp_server": "github",
    "resource_uri": "repo://openearth/auth-service/main",
    "resource_type": "text/plain",
    "size_bytes": 8192,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

6. Human-in-the-Loop Approval

2 events for requesting and receiving human approval for sensitive operations.

Timeline Event

foundation.protocols.ai.claude.approval.request

The bridge requests a human to approve a sensitive action before execution.

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringTool call awaiting approval
tool_namestringTool name
tool_sourcestringSource: builtin or MCP server name
inputobjectTool input to be approved
risk_levelstringRisk classification
Values: low, medium, high, critical
descriptionstringHuman-readable description of the action
timeout_msintegerApproval timeout in milliseconds
{
  "type": "foundation.protocols.ai.claude.approval.request",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_01ABC...",
    "tool_name": "bash",
    "tool_source": "builtin",
    "input": {
      "command": "rm -rf dist/"
    },
    "risk_level": "high",
    "description": "Claude wants to delete the dist directory",
    "timeout_ms": 60000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.approval.response

A room member approves or denies the requested action.

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringLinks to the approval request
decisionstringThe decision made
Values: approved, denied, timed_out
decided_bystringMatrix user ID of the decider
notestringOptional note from the decider
timestampintegerUnix millisecond timestamp
{
  "type": "foundation.protocols.ai.claude.approval.response",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_01ABC...",
    "decision": "approved",
    "decided_by": "@user:matrix.openearth.network",
    "note": "OK to delete, this is a clean build step",
    "timestamp": 1711800030000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$approval_request_event_id" }
    }
  }
}

7. File Change Tracking

1 event recording file mutations made by Claude during a session.

Timeline Event

foundation.protocols.ai.claude.file.change

Records a file mutation made by Claude during a session. Includes before/after hashes and diff.

FieldTypeDescription
session_idstringSession identifier
tool_use_idstringTool call that caused the change
change_typestringType of file change
Values: created, modified, deleted, renamed, moved
pathstringFile path relative to project root
before_hashstringSHA-256 hash before change
after_hashstringSHA-256 hash after change
lines_addedintegerLines added
lines_removedintegerLines removed
diff_mxc_uristringMXC URI of the patch file
{
  "type": "foundation.protocols.ai.claude.file.change",
  "content": {
    "session_id": "sess_01ABC...",
    "tool_use_id": "toolu_01ABC...",
    "change_type": "modified",
    "path": "src/auth/auth.ts",
    "before_hash": "sha256:abc123...",
    "after_hash": "sha256:789xyz...",
    "lines_added": 42,
    "lines_removed": 18,
    "diff_mxc_uri": "mxc://matrix.openearth.network/patchfile123",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$tool_call_event_id" }
    }
  }
}

8. Git Operations

3 events for commits, branch operations, and diff viewing.

Timeline Event

foundation.protocols.ai.claude.git.commit

Claude authored or staged a git commit.

FieldTypeDescription
session_idstringSession identifier
commit_hashstringGit commit hash
branchstringBranch name
messagestringCommit message
files_changedstring[]Files included in the commit
insertionsintegerLines inserted
deletionsintegerLines deleted
authored_bystringAuthor attribution
{
  "type": "foundation.protocols.ai.claude.git.commit",
  "content": {
    "session_id": "sess_01ABC...",
    "commit_hash": "a1b2c3d4...",
    "branch": "feature/jwt-auth",
    "message": "refactor: migrate auth module to JWT",
    "files_changed": ["src/auth/auth.ts", "src/auth/middleware.ts"],
    "insertions": 84,
    "deletions": 36,
    "authored_by": "Claude (claude-sonnet-4-20250514)",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.git.branch

Claude created, switched, deleted, or merged a branch.

FieldTypeDescription
session_idstringSession identifier
actionstringBranch action
Values: created, switched, deleted, merged
branch_namestringTarget branch name
from_branchstringSource branch (for create/switch)
from_commitstringSource commit hash
{
  "type": "foundation.protocols.ai.claude.git.branch",
  "content": {
    "session_id": "sess_01ABC...",
    "action": "created",
    "branch_name": "feature/jwt-auth",
    "from_branch": "main",
    "from_commit": "a1b2c3d4...",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.git.diff.viewed

Claude read a git diff as context.

FieldTypeDescription
session_idstringSession identifier
diff_typestringType of diff viewed
Values: staged, unstaged, commit, branch_compare
files_in_diffstring[]Files included in the diff
lines_addedintegerTotal lines added
lines_removedintegerTotal lines removed
{
  "type": "foundation.protocols.ai.claude.git.diff.viewed",
  "content": {
    "session_id": "sess_01ABC...",
    "diff_type": "staged",
    "files_in_diff": ["src/auth/auth.ts"],
    "lines_added": 42,
    "lines_removed": 18,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

9. Context Management

3 events for context window truncation, summarization, and overflow.

Timeline Event

foundation.protocols.ai.claude.context.truncated

The context window was trimmed to fit within limits.

FieldTypeDescription
session_idstringSession identifier
tokens_beforeintegerToken count before truncation
tokens_afterintegerToken count after truncation
tokens_droppedintegerTokens removed
strategystringTruncation strategy used
turns_droppedintegerNumber of turns removed
{
  "type": "foundation.protocols.ai.claude.context.truncated",
  "content": {
    "session_id": "sess_01ABC...",
    "tokens_before": 198000,
    "tokens_after": 160000,
    "tokens_dropped": 38000,
    "strategy": "drop_oldest_turns",
    "turns_dropped": 3,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.context.summarized

Prior conversation was summarized to compress context.

FieldTypeDescription
session_idstringSession identifier
tokens_beforeintegerToken count before summarization
tokens_afterintegerToken count after summarization
summary_textstringThe generated summary
turns_summarizedintegerNumber of turns summarized
{
  "type": "foundation.protocols.ai.claude.context.summarized",
  "content": {
    "session_id": "sess_01ABC...",
    "tokens_before": 198000,
    "tokens_after": 12000,
    "summary_text": "The user is refactoring the auth module to use JWT. So far, Claude has read auth.ts and middleware.ts and is in the process of rewriting auth.ts.",
    "turns_summarized": 8,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.context.overflow

Context window hard limit was exceeded and session cannot continue without intervention.

FieldTypeDescription
session_idstringSession identifier
token_countintegerCurrent token count
token_limitintegerMaximum token limit
{
  "type": "foundation.protocols.ai.claude.context.overflow",
  "content": {
    "session_id": "sess_01ABC...",
    "token_count": 200001,
    "token_limit": 200000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

10. Memory

2 events for reading and writing CLAUDE.md / memory files.

Timeline Event

foundation.protocols.ai.claude.memory.read

Claude read from a memory or notes file (e.g., CLAUDE.md).

FieldTypeDescription
session_idstringSession identifier
file_pathstringPath of the memory file
scopestringMemory scope
Values: project, user, global
content_hashstringSHA-256 hash of file contents
size_bytesintegerFile size in bytes
{
  "type": "foundation.protocols.ai.claude.memory.read",
  "content": {
    "session_id": "sess_01ABC...",
    "file_path": "CLAUDE.md",
    "scope": "project",
    "content_hash": "sha256:mem123...",
    "size_bytes": 2048,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.memory.write

Claude wrote to a memory or notes file.

FieldTypeDescription
session_idstringSession identifier
file_pathstringPath of the memory file
scopestringMemory scope
Values: project, user, global
before_hashstringSHA-256 hash before write
after_hashstringSHA-256 hash after write
diff_mxc_uristringMXC URI of the diff
{
  "type": "foundation.protocols.ai.claude.memory.write",
  "content": {
    "session_id": "sess_01ABC...",
    "file_path": "CLAUDE.md",
    "scope": "project",
    "before_hash": "sha256:mem123...",
    "after_hash": "sha256:mem456...",
    "diff_mxc_uri": "mxc://matrix.openearth.network/memdiff123",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

11. Multi-Agent Interactions

3 events for sub-agent spawning, results, and handoffs.

Timeline Event

foundation.protocols.ai.claude.agent.spawn

A parent agent spawning a sub-agent task.

FieldTypeDescription
parent_session_idstringParent session identifier
child_session_idstringSub-agent session identifier
taskstringTask description for the sub-agent
modelstringModel used by the sub-agent
tools_enabledstring[]Tools available to the sub-agent
max_tokensintegerMax output tokens for the sub-agent
child_room_idstringMatrix room ID for the sub-agent (optional)
{
  "type": "foundation.protocols.ai.claude.agent.spawn",
  "content": {
    "parent_session_id": "sess_01ABC...",
    "child_session_id": "sess_02DEF...",
    "task": "Run the full test suite and return a summary of failures",
    "model": "claude-sonnet-4-20250514",
    "tools_enabled": ["bash"],
    "max_tokens": 4096,
    "child_room_id": "!childroom:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$parent_session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.agent.result

A sub-agent returning its result to the parent agent.

FieldTypeDescription
parent_session_idstringParent session identifier
child_session_idstringSub-agent session identifier
resultstringResult text from the sub-agent
statusstringSub-agent completion status
Values: success, failure, timeout, interrupted
input_tokensintegerInput tokens consumed by sub-agent
output_tokensintegerOutput tokens generated by sub-agent
duration_msintegerSub-agent execution duration
{
  "type": "foundation.protocols.ai.claude.agent.result",
  "content": {
    "parent_session_id": "sess_01ABC...",
    "child_session_id": "sess_02DEF...",
    "result": "Test suite completed. 3 failures found in auth.test.ts: ...",
    "status": "success",
    "input_tokens": 3200,
    "output_tokens": 640,
    "duration_ms": 18400,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$parent_session_start_event_id",
      "m.in_reply_to": { "event_id": "$agent_spawn_event_id" }
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.agent.handoff

Control is transferred between agents.

FieldTypeDescription
from_session_idstringSource agent session
to_session_idstringTarget agent session
reasonstringReason for handoff
context_summarystringSummary of work done so far
{
  "type": "foundation.protocols.ai.claude.agent.handoff",
  "content": {
    "from_session_id": "sess_01ABC...",
    "to_session_id": "sess_03GHI...",
    "reason": "Delegating test fixing to specialist agent",
    "context_summary": "Auth module refactored. 3 test failures remain in auth.test.ts.",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

12. Errors & Safety

2 events for API errors and safety-blocked requests.

Timeline Event

foundation.protocols.ai.claude.error

A general error occurred during the session (API error, rate limit, timeout, etc.).

FieldTypeDescription
session_idstringSession identifier
error_typestringError classification
Values: api_error, rate_limit, timeout, network_failure, authentication_error, invalid_request
error_codestringAPI error code
error_messagestringHuman-readable error message
http_statusintegerHTTP status code
retryablebooleanWhether the operation can be retried
retry_after_msintegerSuggested retry delay in milliseconds
{
  "type": "foundation.protocols.ai.claude.error",
  "content": {
    "session_id": "sess_01ABC...",
    "error_type": "api_error",
    "error_code": "overloaded_error",
    "error_message": "The API is temporarily overloaded",
    "http_status": 529,
    "retryable": true,
    "retry_after_ms": 5000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.safety.blocked

A request was blocked by Claude’s safety systems.

FieldTypeDescription
session_idstringSession identifier
prompt_idstringPrompt that was blocked
block_reasonstringReason for blocking
Values: policy_violation, content_filter, rate_limit, permissions
categorystringSafety category (e.g., harmful_content)
{
  "type": "foundation.protocols.ai.claude.safety.blocked",
  "content": {
    "session_id": "sess_01ABC...",
    "prompt_id": "prm_01XYZ...",
    "block_reason": "policy_violation",
    "category": "harmful_content",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id",
      "m.in_reply_to": { "event_id": "$prompt_event_id" }
    }
  }
}

13. Configuration

2 events for mid-session changes to model, tools, and permissions.

Timeline Event

foundation.protocols.ai.claude.config.change

Model, tools, or system prompt changed mid-session.

FieldTypeDescription
session_idstringSession identifier
changed_bystringMatrix user ID who made the change
changesobjectMap of changed fields with before/after values
{
  "type": "foundation.protocols.ai.claude.config.change",
  "content": {
    "session_id": "sess_01ABC...",
    "changed_by": "@user:matrix.openearth.network",
    "changes": {
      "model": {
        "before": "claude-haiku-4-5-20251001",
        "after": "claude-sonnet-4-20250514"
      },
      "tools_enabled": {
        "before": ["bash"],
        "after": ["bash", "web_search"]
      }
    },
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.permission.change

Tool permissions or approval requirements changed during a session.

FieldTypeDescription
session_idstringSession identifier
changed_bystringMatrix user ID who made the change
changesobjectMap of changed permissions with before/after values
{
  "type": "foundation.protocols.ai.claude.permission.change",
  "content": {
    "session_id": "sess_01ABC...",
    "changed_by": "@user:matrix.openearth.network",
    "changes": {
      "approval_required_for": {
        "before": ["bash", "write_file"],
        "after": ["write_file"]
      }
    },
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

14. Cost & Usage Metering

2 events for periodic cost checkpoints and limit enforcement. All cost values use string encoding per Matrix canonical JSON.

Timeline Event

foundation.protocols.ai.claude.usage.checkpoint

Periodic token and cost snapshot during long-running sessions.

FieldTypeDescription
session_idstringSession identifier
checkpoint_indexintegerSequential checkpoint number
cumulative_input_tokensintegerTotal input tokens so far
cumulative_output_tokensintegerTotal output tokens so far
cumulative_cache_read_tokensintegerTotal cache-read tokens
cumulativeCoststringTotal cost as decimal string
currencystringISO 4217 currency code
timestampintegerUnix millisecond timestamp
{
  "type": "foundation.protocols.ai.claude.usage.checkpoint",
  "content": {
    "session_id": "sess_01ABC...",
    "checkpoint_index": 3,
    "cumulative_input_tokens": 48000,
    "cumulative_output_tokens": 9600,
    "cumulative_cache_read_tokens": 12000,
    "cumulativeCost": "0.087000",
    "currency": "USD",
    "timestamp": 1711810000000,
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.claude.cost.limit.reached

Session halted because a configured cost or token limit was reached.

FieldTypeDescription
session_idstringSession identifier
limit_typestringType of limit exceeded
Values: cost, input_tokens, output_tokens, total_tokens
limitValuestringConfigured limit as decimal string
actualValuestringActual value that exceeded the limit
currencystringISO 4217 currency code
action_takenstringAction taken by the system
Values: session_paused, session_terminated, warning_only
{
  "type": "foundation.protocols.ai.claude.cost.limit.reached",
  "content": {
    "session_id": "sess_01ABC...",
    "limit_type": "cost",
    "limitValue": "1.000000",
    "actualValue": "1.003000",
    "currency": "USD",
    "action_taken": "session_paused",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

15. State Events (Room / Space Level)

2 state events stored as persistent room state. project configures the room; session.active tracks the current session.

State Event

foundation.protocols.ai.claude.project

Associates a room or Space with a Claude Code project. Configures defaults, cost limits, and allowed operators.

FieldTypeDescription
namestringProject name
repository_urlstringGit repository URL
default_modelstringDefault model for sessions
default_toolsstring[]Default enabled tools
approval_required_forstring[]Tools requiring approval
allowed_operatorsstring[]Matrix user IDs allowed to run sessions
costLimitstringCost limit per session as decimal string
currencystringISO 4217 currency code
mcp_serversstring[]Available MCP servers
{
  "type": "foundation.protocols.ai.claude.project",
  "state_key": "",
  "content": {
    "name": "Auth Service Refactor",
    "repository_url": "https://github.com/openearth/auth-service",
    "default_model": "claude-sonnet-4-20250514",
    "default_tools": ["bash", "read_file", "write_file"],
    "approval_required_for": ["bash", "write_file"],
    "allowed_operators": ["@alice:matrix.openearth.network", "@bob:matrix.openearth.network"],
    "costLimit": "2.000000",
    "currency": "USD",
    "mcp_servers": ["github", "postgres"]
  }
}
State Event

foundation.protocols.ai.claude.session.active

Tracks the currently active session in a room. See Session Lifecycle for full schema.

FieldTypeDescription
session_idstringActive session identifier
started_atintegerUnix millisecond start time
started_bystringMatrix user ID
modelstringModel identifier
statusstringCurrent session status
Values: running, paused, idle, terminated
{
  "type": "foundation.protocols.ai.claude.session.active",
  "state_key": "",
  "content": {
    "session_id": "sess_01ABC...",
    "started_at": 1711800000000,
    "started_by": "@user:matrix.openearth.network",
    "model": "claude-sonnet-4-20250514",
    "status": "running"
  }
}

Event Relationship Graph

A complete interaction thread from session start to end, showing m.relates_to relationships.

session.start ← thread root │ ├―― memory.read │ ├―― prompt │ ├―― input.image │ ├―― input.document │ ├―― thinking │ └―― response │ ├―― response.chunk (×N, if streaming) │ ├―― tool.call │ │ ├―― approval.request │ │ │ └―― approval.response │ │ ├―― tool.result │ │ ├―― tool.error │ │ └―― file.change │ └―― mcp.tool.call │ └―― mcp.tool.result │ ├―― git.commit ├―― git.branch ├―― git.diff.viewed │ ├―― agent.spawn │ └―― agent.result │ ├―― context.truncated ├―― context.summarized ├―― memory.write ├―― usage.checkpoint ├―― config.change ├―― error ├―― safety.blocked │ └―― session.end (or session.interrupted / cost.limit.reached)

Implementation Status

25 of 42 events are implemented in the openearth-ai-bridge and tested on 3 homeservers (Synapse, Conduit, continuwuity). 17 events require the OpenEarth Messenger for interactive UI.

Event TypeCategoryMatrix TypeStatus
session.startSessionTimelineTier 1
session.endSessionTimelineTier 1
session.interruptedSessionTimeline--
session.exportedSessionTimeline--
session.replayedSessionTimeline--
session.activeSessionState--
promptPrompt/ResponseTimelineTier 1
responsePrompt/ResponseTimelineTier 1
response.chunkPrompt/ResponseTimeline--
response.interruptedPrompt/ResponseTimelineTier 2
thinkingPrompt/ResponseTimeline--
input.imageMultimodalTimelineTier 2
input.documentMultimodalTimelineTier 2
tool.callTool UseTimelineTier 1
tool.resultTool UseTimelineTier 1
tool.errorTool UseTimelineTier 1
mcp.server.connectedMCPTimeline--
mcp.tool.callMCPTimeline--
mcp.tool.resultMCPTimeline--
mcp.prompt.usedMCPTimeline--
mcp.resource.readMCPTimeline--
approval.requestApprovalTimelineTier 1
approval.responseApprovalTimelineTier 1
file.changeFileTimelineTier 2
git.commitGitTimelineTier 2
git.branchGitTimelineTier 2
git.diff.viewedGitTimelineTier 2
context.truncatedContextTimelineTier 2
context.summarizedContextTimeline--
context.overflowContextTimeline--
memory.readMemoryTimelineTier 2
memory.writeMemoryTimelineTier 2
agent.spawnMulti-AgentTimelineTier 2
agent.resultMulti-AgentTimelineTier 2
agent.handoffMulti-AgentTimeline--
errorErrorTimelineTier 2
safety.blockedErrorTimelineTier 2
config.changeConfigTimeline--
permission.changeConfigTimeline--
usage.checkpointMeteringTimelineTier 1
cost.limit.reachedMeteringTimelineTier 2
projectProjectState--

Related Event Families

FamilyRelationship
ai.* Vendor-neutral governance layer. Claude sessions operate within ai.policy constraints and can be wrapped in ai.intention → ai.decision → ai.effect flows.
ai.cost Vendor-agnostic cost accumulator. Updated from usage.checkpoint and session.end events.
data.* Data consent gates what information reaches Claude. ai.data_boundary enforces data types.
eudr.* EUDR workflow events can trigger Claude sessions for deforestation analysis and DDS generation.
legal.* Open Law sessions use Claude with MCP law servers; ai.policy restricts tool access.