event_emitter
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AgentEventEmitter llmling_agent.agent.event_emitter Event emitter delegate that automatically injects context. |
||
| LocationContentItem llmling_agent.agent.events A file location being accessed or modified. |
🛈 DocStrings¶
Event emitter delegate for AgentContext with fluent API.
AgentEventEmitter
¶
Event emitter delegate that automatically injects context.
Provides a fluent, developer-friendly API for emitting domain events with context (tool_call_id, etc.) automatically injected.
Source code in src/llmling_agent/agent/event_emitter.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
__init__
¶
__init__(context: AgentContext) -> None
Initialize event emitter with agent context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
AgentContext
|
Agent context to extract metadata from |
required |
Source code in src/llmling_agent/agent/event_emitter.py
24 25 26 27 28 29 30 | |
custom
async
¶
Emit custom event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_data
|
Any
|
The custom event data of any type |
required |
event_type
|
str
|
Type identifier for the custom event |
'custom'
|
source
|
str | None
|
Optional source identifier |
None
|
Source code in src/llmling_agent/agent/event_emitter.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
emit_event
async
¶
emit_event(event: RichAgentStreamEvent[Any]) -> None
Emit a typed event into the agent's event stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
RichAgentStreamEvent[Any]
|
The event instance (PlanUpdateEvent, FileOperationEvent, etc.) |
required |
Source code in src/llmling_agent/agent/event_emitter.py
329 330 331 332 333 334 335 | |
file_edit_progress
async
¶
file_edit_progress(
path: str,
old_text: str,
new_text: str,
status: Literal["in_progress", "completed", "failed"],
changed_lines: list[int] | None = None,
) -> None
Emit file edit progress event with diff information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The file path being edited |
required |
old_text
|
str
|
Original file content |
required |
new_text
|
str
|
New file content |
required |
status
|
Literal['in_progress', 'completed', 'failed']
|
Current status of the edit operation |
required |
changed_lines
|
list[int] | None
|
Line numbers that were changed |
None
|
Source code in src/llmling_agent/agent/event_emitter.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
file_operation
async
¶
file_operation(
operation: Literal["read", "write", "delete", "list", "edit"],
path: str,
success: bool,
error: str | None = None,
size: int | None = None,
title: str | None = None,
kind: str | None = None,
locations: list[str] | None = None,
raw_output: Any | None = None,
) -> None
Emit file operation event with rich metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['read', 'write', 'delete', 'list', 'edit']
|
The filesystem operation performed |
required |
path
|
str
|
The file/directory path that was operated on |
required |
success
|
bool
|
Whether the operation completed successfully |
required |
error
|
str | None
|
Error message if operation failed |
None
|
size
|
int | None
|
Size of file in bytes (for successful operations) |
None
|
title
|
str | None
|
Display title for the operation |
None
|
kind
|
str | None
|
Tool operation kind (edit, read, write, etc.) |
None
|
locations
|
list[str] | None
|
File paths affected by the operation |
None
|
raw_output
|
Any | None
|
Tool result data for failed operations |
None
|
Source code in src/llmling_agent/agent/event_emitter.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
plan_updated
async
¶
Emit plan update event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entries
|
list[PlanEntry]
|
Current plan entries |
required |
Source code in src/llmling_agent/agent/event_emitter.py
103 104 105 106 107 108 109 110 111 112 | |
process_exit
async
¶
process_exit(
process_id: str,
exit_code: int,
final_output: str | None = None,
truncated: bool = False,
) -> None
Emit process exit event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
str
|
Process identifier |
required |
exit_code
|
int
|
Process exit code |
required |
final_output
|
str | None
|
Final process output |
None
|
truncated
|
bool
|
Whether output was truncated due to limits |
False
|
Source code in src/llmling_agent/agent/event_emitter.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
process_killed
async
¶
Emit process kill event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
str
|
Process identifier |
required |
success
|
bool
|
Whether the process was successfully killed |
True
|
error
|
str | None
|
Error message if kill failed |
None
|
Source code in src/llmling_agent/agent/event_emitter.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
process_output
async
¶
process_output(
process_id: str,
output: str,
stdout: str | None = None,
stderr: str | None = None,
truncated: bool = False,
) -> None
Emit process output event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
str
|
Process identifier |
required |
output
|
str
|
Process output (stdout/stderr combined) |
required |
stdout
|
str | None
|
Standard output (if separated) |
None
|
stderr
|
str | None
|
Standard error (if separated) |
None
|
truncated
|
bool
|
Whether output was truncated due to limits |
False
|
Source code in src/llmling_agent/agent/event_emitter.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
process_released
async
¶
Emit process release event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
str
|
Process identifier |
required |
success
|
bool
|
Whether resources were successfully released |
True
|
error
|
str | None
|
Error message if release failed |
None
|
Source code in src/llmling_agent/agent/event_emitter.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
process_started
async
¶
process_started(
process_id: str,
command: str,
args: list[str] | None = None,
cwd: str | None = None,
env: dict[str, str] | None = None,
output_limit: int | None = None,
success: bool = True,
error: str | None = None,
) -> None
Emit process start event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
str
|
Unique process identifier |
required |
command
|
str
|
Command being executed |
required |
args
|
list[str] | None
|
Command arguments |
None
|
cwd
|
str | None
|
Working directory |
None
|
env
|
dict[str, str] | None
|
Environment variables |
None
|
output_limit
|
int | None
|
Maximum bytes of output to retain |
None
|
success
|
bool
|
Whether the process started successfully |
True
|
error
|
str | None
|
Error message if start failed |
None
|
Source code in src/llmling_agent/agent/event_emitter.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
progress
async
¶
Emit progress event (delegates to existing method).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
progress
|
float
|
Current progress value |
required |
total
|
float | None
|
Total progress value |
required |
message
|
str
|
Progress message |
required |
Source code in src/llmling_agent/agent/event_emitter.py
114 115 116 117 118 119 120 121 122 | |
tool_call_start
async
¶
tool_call_start(
title: str,
kind: ToolKind = "other",
content: list[ToolCallContentItem] | None = None,
locations: list[str | LocationContentItem] | None = None,
) -> None
Emit tool call start event with rich ACP metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Human-readable title describing what the tool is doing |
required |
kind
|
ToolKind
|
Tool kind (read, edit, delete, move, search, execute, think, fetch, other) |
'other'
|
content
|
list[ToolCallContentItem] | None
|
Content produced by the tool call (terminals, diffs, text) |
None
|
locations
|
list[str | LocationContentItem] | None
|
File paths or LocationContentItem objects affected by this tool call |
None
|
Source code in src/llmling_agent/agent/event_emitter.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |