ejagent-core 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. ejagent/__init__.py +335 -0
  2. ejagent/agent/__init__.py +223 -0
  3. ejagent/agent/base.py +666 -0
  4. ejagent/agent/behavior.py +115 -0
  5. ejagent/agent/cancellation.py +98 -0
  6. ejagent/agent/compaction.py +439 -0
  7. ejagent/agent/context_builder.py +125 -0
  8. ejagent/agent/context_management.py +409 -0
  9. ejagent/agent/control.py +334 -0
  10. ejagent/agent/events.py +367 -0
  11. ejagent/agent/model_compactor.py +64 -0
  12. ejagent/agent/orchestrator.py +866 -0
  13. ejagent/agent/result.py +65 -0
  14. ejagent/agent/runtime_policy.py +33 -0
  15. ejagent/agent/state.py +136 -0
  16. ejagent/agent/tool_runtime.py +517 -0
  17. ejagent/agent/types.py +64 -0
  18. ejagent/agent/usage.py +143 -0
  19. ejagent/handlers/__init__.py +23 -0
  20. ejagent/handlers/base.py +178 -0
  21. ejagent/handlers/definition.py +149 -0
  22. ejagent/handlers/mcp.py +114 -0
  23. ejagent/logger.py +44 -0
  24. ejagent/middleware/__init__.py +47 -0
  25. ejagent/middleware/base.py +113 -0
  26. ejagent/middleware/policy.py +374 -0
  27. ejagent/middleware/validation.py +189 -0
  28. ejagent/plugins/__init__.py +6 -0
  29. ejagent/plugins/mcp/mcp_manager.py +156 -0
  30. ejagent/plugins/skill/skill_manager.py +233 -0
  31. ejagent/providers/__init__.py +38 -0
  32. ejagent/providers/base.py +232 -0
  33. ejagent/providers/openai.py +429 -0
  34. ejagent/py.typed +1 -0
  35. ejagent/session/__init__.py +73 -0
  36. ejagent/session/_file_lock.py +168 -0
  37. ejagent/session/codec.py +278 -0
  38. ejagent/session/errors.py +18 -0
  39. ejagent/session/journal.py +504 -0
  40. ejagent/session/jsonl.py +963 -0
  41. ejagent/session/memory.py +20 -0
  42. ejagent/session/recorder.py +196 -0
  43. ejagent/session/storage.py +91 -0
  44. ejagent/session/tree.py +62 -0
  45. ejagent/session/types.py +290 -0
  46. ejagent_core-0.6.0.dist-info/METADATA +1075 -0
  47. ejagent_core-0.6.0.dist-info/RECORD +49 -0
  48. ejagent_core-0.6.0.dist-info/WHEEL +4 -0
  49. ejagent_core-0.6.0.dist-info/licenses/LICENSE +21 -0
ejagent/__init__.py ADDED
@@ -0,0 +1,335 @@
1
+ """Composable stateful agents with tool handlers and MCP integration."""
2
+
3
+ from ejagent.agent.base import BaseAgent
4
+ from ejagent.agent.behavior import (
5
+ BehaviorAction,
6
+ BehaviorDecision,
7
+ BehaviorHook,
8
+ BehaviorHookError,
9
+ TurnSnapshot,
10
+ )
11
+ from ejagent.agent.cancellation import (
12
+ AgentCancelledError,
13
+ CancellationSource,
14
+ CancellationToken,
15
+ )
16
+ from ejagent.agent.compaction import (
17
+ CompactionRequest,
18
+ CompactionResult,
19
+ CompactionRuntime,
20
+ CompactionStatus,
21
+ CompactionTrigger,
22
+ Compactor,
23
+ CompactorOutput,
24
+ SummaryEntry,
25
+ )
26
+ from ejagent.agent.context_builder import AgentContextBuilder, ContextBuildResult
27
+ from ejagent.agent.context_management import (
28
+ AutoCompactionPolicy,
29
+ CompactionDecision,
30
+ CompactionDecisionReason,
31
+ CompactionPolicy,
32
+ CompactionPreparation,
33
+ ContextBudget,
34
+ ContextUsageEstimate,
35
+ ContextUsageSource,
36
+ HeuristicMessageTokenEstimator,
37
+ MessageTokenEstimator,
38
+ estimate_context_usage,
39
+ prepare_compaction,
40
+ )
41
+ from ejagent.agent.control import (
42
+ ContinueRejectedError,
43
+ ContinueRejectedReason,
44
+ ControlInput,
45
+ ControlInputKind,
46
+ ControlReceipt,
47
+ ControlStatus,
48
+ FollowUpDiscardedError,
49
+ FollowUpDiscardReason,
50
+ FollowUpError,
51
+ FollowUpFailurePolicy,
52
+ FollowUpHandle,
53
+ FollowUpRejectedError,
54
+ )
55
+ from ejagent.agent.events import (
56
+ AgentContinued,
57
+ AgentEvent,
58
+ AgentEventKind,
59
+ AgentEventPayload,
60
+ AgentEventSink,
61
+ AgentEventSinkError,
62
+ AgentFinished,
63
+ AgentStarted,
64
+ AssistantTextDelta,
65
+ AssistantThinkingDelta,
66
+ CompactionCompleted,
67
+ CompactionFailed,
68
+ CompactionStarted,
69
+ CompositeAgentEventSink,
70
+ ContextPressureEvaluated,
71
+ MessageCompleted,
72
+ SteeringApplied,
73
+ SteeringDiscarded,
74
+ ToolCompleted,
75
+ ToolProgressed,
76
+ ToolStarted,
77
+ TurnCompleted,
78
+ TurnStarted,
79
+ )
80
+ from ejagent.agent.model_compactor import (
81
+ CompactionContextBuilder,
82
+ ModelCompactor,
83
+ )
84
+ from ejagent.agent.orchestrator import AgentOrchestrator
85
+ from ejagent.agent.result import (
86
+ AgentRunError,
87
+ AgentRunResult,
88
+ RunStatus,
89
+ StopReason,
90
+ )
91
+ from ejagent.agent.runtime_policy import RuntimePolicy
92
+ from ejagent.agent.state import AgentState, AgentStatus
93
+ from ejagent.agent.types import (
94
+ StepOutcome,
95
+ ToolCallResult,
96
+ ToolControl,
97
+ ToolProgressReporter,
98
+ ToolProgressUpdate,
99
+ )
100
+ from ejagent.agent.usage import RunUsage
101
+ from ejagent.handlers import (
102
+ BaseHandler,
103
+ McpToolHandler,
104
+ MethodToolHandler,
105
+ ToolDefinition,
106
+ ToolDefinitionError,
107
+ ToolEffect,
108
+ UnknownToolError,
109
+ )
110
+ from ejagent.middleware import (
111
+ Middleware,
112
+ RuleBasedToolPolicy,
113
+ ToolApprovalDecision,
114
+ ToolApprovalRequest,
115
+ ToolApprover,
116
+ ToolCallContext,
117
+ ToolExecutionPolicy,
118
+ ToolMiddleware,
119
+ ToolNext,
120
+ ToolPolicyAction,
121
+ ToolPolicyDecision,
122
+ ToolPolicyMiddleware,
123
+ ToolPolicyPredicate,
124
+ ToolPolicyRule,
125
+ ToolSchemaConfigurationError,
126
+ ToolSchemaValidationMiddleware,
127
+ compose_tool_middlewares,
128
+ format_tool_call_preview,
129
+ )
130
+ from ejagent.plugins.mcp.mcp_manager import McpServerManager
131
+ from ejagent.plugins.skill.skill_manager import SkillManager
132
+ from ejagent.providers import (
133
+ AssistantMessage,
134
+ ContextOverflowError,
135
+ ModelAdapter,
136
+ ModelAuthenticationError,
137
+ ModelConfig,
138
+ ModelErrorKind,
139
+ ModelProviderError,
140
+ ModelRateLimitError,
141
+ ModelResponseCompleted,
142
+ ModelStreamEvent,
143
+ ModelTextDelta,
144
+ ModelThinkingDelta,
145
+ ModelTimeoutError,
146
+ ModelToolCall,
147
+ ModelUsage,
148
+ OpenAIModelAdapter,
149
+ )
150
+ from ejagent.session import (
151
+ DEFAULT_SESSION_BRANCH,
152
+ SESSION_JOURNAL_SCHEMA_VERSION,
153
+ SESSION_SCHEMA_VERSION,
154
+ AgentSession,
155
+ JsonlSessionStorage,
156
+ MemorySessionStorage,
157
+ SessionBranch,
158
+ SessionBranchIntent,
159
+ SessionCheckout,
160
+ SessionCompaction,
161
+ SessionConflictError,
162
+ SessionError,
163
+ SessionJournalStorage,
164
+ SessionLockTimeoutError,
165
+ SessionMessage,
166
+ SessionRecord,
167
+ SessionRecordDraft,
168
+ SessionRecorder,
169
+ SessionRecordKind,
170
+ SessionRetry,
171
+ SessionRun,
172
+ SessionRunIntent,
173
+ SessionSerializationError,
174
+ SessionStorage,
175
+ SessionStorageError,
176
+ SessionTreeStorage,
177
+ session_from_dict,
178
+ session_to_dict,
179
+ )
180
+
181
+ __all__ = [
182
+ "BaseAgent",
183
+ "BehaviorAction",
184
+ "BehaviorDecision",
185
+ "BehaviorHook",
186
+ "BehaviorHookError",
187
+ "TurnSnapshot",
188
+ "AgentCancelledError",
189
+ "CancellationSource",
190
+ "CancellationToken",
191
+ "Compactor",
192
+ "CompactorOutput",
193
+ "CompactionRequest",
194
+ "CompactionResult",
195
+ "CompactionRuntime",
196
+ "CompactionStatus",
197
+ "CompactionTrigger",
198
+ "ControlInputKind",
199
+ "ContinueRejectedReason",
200
+ "ContinueRejectedError",
201
+ "ControlStatus",
202
+ "ControlInput",
203
+ "ControlReceipt",
204
+ "FollowUpFailurePolicy",
205
+ "FollowUpDiscardReason",
206
+ "FollowUpHandle",
207
+ "FollowUpError",
208
+ "FollowUpRejectedError",
209
+ "FollowUpDiscardedError",
210
+ "SummaryEntry",
211
+ "CompactionContextBuilder",
212
+ "ModelCompactor",
213
+ "ModelConfig",
214
+ "ModelAdapter",
215
+ "OpenAIModelAdapter",
216
+ "AssistantMessage",
217
+ "ModelErrorKind",
218
+ "ModelProviderError",
219
+ "ContextOverflowError",
220
+ "ModelRateLimitError",
221
+ "ModelTimeoutError",
222
+ "ModelAuthenticationError",
223
+ "ModelStreamEvent",
224
+ "ModelTextDelta",
225
+ "ModelThinkingDelta",
226
+ "ModelResponseCompleted",
227
+ "ModelToolCall",
228
+ "ModelUsage",
229
+ "AgentState",
230
+ "AgentStatus",
231
+ "AgentContextBuilder",
232
+ "ContextBuildResult",
233
+ "ContextBudget",
234
+ "ContextUsageEstimate",
235
+ "ContextUsageSource",
236
+ "MessageTokenEstimator",
237
+ "HeuristicMessageTokenEstimator",
238
+ "CompactionPolicy",
239
+ "AutoCompactionPolicy",
240
+ "CompactionDecision",
241
+ "CompactionDecisionReason",
242
+ "CompactionPreparation",
243
+ "estimate_context_usage",
244
+ "prepare_compaction",
245
+ "AgentEvent",
246
+ "AgentEventKind",
247
+ "AgentEventPayload",
248
+ "AgentEventSink",
249
+ "AgentEventSinkError",
250
+ "CompositeAgentEventSink",
251
+ "CompactionStarted",
252
+ "CompactionCompleted",
253
+ "CompactionFailed",
254
+ "ContextPressureEvaluated",
255
+ "AgentStarted",
256
+ "AgentContinued",
257
+ "AssistantThinkingDelta",
258
+ "AssistantTextDelta",
259
+ "TurnStarted",
260
+ "MessageCompleted",
261
+ "SteeringApplied",
262
+ "SteeringDiscarded",
263
+ "ToolStarted",
264
+ "ToolProgressed",
265
+ "ToolCompleted",
266
+ "TurnCompleted",
267
+ "AgentFinished",
268
+ "AgentOrchestrator",
269
+ "RuntimePolicy",
270
+ "AgentRunResult",
271
+ "AgentRunError",
272
+ "RunStatus",
273
+ "StopReason",
274
+ "RunUsage",
275
+ "StepOutcome",
276
+ "ToolCallResult",
277
+ "ToolControl",
278
+ "ToolProgressReporter",
279
+ "ToolProgressUpdate",
280
+ "Middleware",
281
+ "ToolMiddleware",
282
+ "ToolCallContext",
283
+ "ToolNext",
284
+ "ToolExecutionPolicy",
285
+ "RuleBasedToolPolicy",
286
+ "ToolPolicyRule",
287
+ "ToolPolicyAction",
288
+ "ToolPolicyDecision",
289
+ "ToolPolicyMiddleware",
290
+ "ToolPolicyPredicate",
291
+ "ToolApprover",
292
+ "ToolApprovalRequest",
293
+ "ToolApprovalDecision",
294
+ "ToolSchemaConfigurationError",
295
+ "ToolSchemaValidationMiddleware",
296
+ "compose_tool_middlewares",
297
+ "format_tool_call_preview",
298
+ "BaseHandler",
299
+ "MethodToolHandler",
300
+ "McpToolHandler",
301
+ "ToolDefinition",
302
+ "ToolDefinitionError",
303
+ "ToolEffect",
304
+ "UnknownToolError",
305
+ "McpServerManager",
306
+ "SkillManager",
307
+ "AgentSession",
308
+ "SessionMessage",
309
+ "SessionRun",
310
+ "SessionRunIntent",
311
+ "SessionCompaction",
312
+ "SessionStorage",
313
+ "SessionJournalStorage",
314
+ "SessionTreeStorage",
315
+ "JsonlSessionStorage",
316
+ "MemorySessionStorage",
317
+ "SessionRecorder",
318
+ "SESSION_SCHEMA_VERSION",
319
+ "session_to_dict",
320
+ "session_from_dict",
321
+ "SessionError",
322
+ "SessionConflictError",
323
+ "SessionLockTimeoutError",
324
+ "SessionSerializationError",
325
+ "SessionStorageError",
326
+ "SESSION_JOURNAL_SCHEMA_VERSION",
327
+ "DEFAULT_SESSION_BRANCH",
328
+ "SessionRecordKind",
329
+ "SessionRecordDraft",
330
+ "SessionRecord",
331
+ "SessionBranchIntent",
332
+ "SessionBranch",
333
+ "SessionCheckout",
334
+ "SessionRetry",
335
+ ]
@@ -0,0 +1,223 @@
1
+ """Agent runtime primitives."""
2
+
3
+ from ejagent.agent.base import BaseAgent
4
+ from ejagent.agent.behavior import (
5
+ BehaviorAction,
6
+ BehaviorDecision,
7
+ BehaviorHook,
8
+ BehaviorHookError,
9
+ TurnSnapshot,
10
+ )
11
+ from ejagent.agent.cancellation import (
12
+ AgentCancelledError,
13
+ CancellationSource,
14
+ CancellationToken,
15
+ )
16
+ from ejagent.agent.compaction import (
17
+ CompactionRequest,
18
+ CompactionResult,
19
+ CompactionRuntime,
20
+ CompactionStatus,
21
+ CompactionTrigger,
22
+ Compactor,
23
+ CompactorOutput,
24
+ SummaryEntry,
25
+ )
26
+ from ejagent.agent.context_builder import AgentContextBuilder, ContextBuildResult
27
+ from ejagent.agent.context_management import (
28
+ AutoCompactionPolicy,
29
+ CompactionDecision,
30
+ CompactionDecisionReason,
31
+ CompactionPolicy,
32
+ CompactionPreparation,
33
+ ContextBudget,
34
+ ContextUsageEstimate,
35
+ ContextUsageSource,
36
+ HeuristicMessageTokenEstimator,
37
+ MessageTokenEstimator,
38
+ estimate_context_usage,
39
+ prepare_compaction,
40
+ )
41
+ from ejagent.agent.control import (
42
+ ContinueRejectedError,
43
+ ContinueRejectedReason,
44
+ ControlInput,
45
+ ControlInputKind,
46
+ ControlReceipt,
47
+ ControlStatus,
48
+ FollowUpDiscardedError,
49
+ FollowUpDiscardReason,
50
+ FollowUpError,
51
+ FollowUpFailurePolicy,
52
+ FollowUpHandle,
53
+ FollowUpRejectedError,
54
+ )
55
+ from ejagent.agent.events import (
56
+ AgentContinued,
57
+ AgentEvent,
58
+ AgentEventKind,
59
+ AgentEventPayload,
60
+ AgentEventSink,
61
+ AgentEventSinkError,
62
+ AgentFinished,
63
+ AgentStarted,
64
+ AssistantTextDelta,
65
+ AssistantThinkingDelta,
66
+ CompactionCompleted,
67
+ CompactionFailed,
68
+ CompactionStarted,
69
+ CompositeAgentEventSink,
70
+ ContextPressureEvaluated,
71
+ MessageCompleted,
72
+ SteeringApplied,
73
+ SteeringDiscarded,
74
+ ToolCompleted,
75
+ ToolProgressed,
76
+ ToolStarted,
77
+ TurnCompleted,
78
+ TurnStarted,
79
+ )
80
+ from ejagent.agent.model_compactor import (
81
+ CompactionContextBuilder,
82
+ ModelCompactor,
83
+ )
84
+ from ejagent.agent.orchestrator import AgentOrchestrator
85
+ from ejagent.agent.result import (
86
+ AgentRunError,
87
+ AgentRunResult,
88
+ RunStatus,
89
+ StopReason,
90
+ )
91
+ from ejagent.agent.runtime_policy import RuntimePolicy
92
+ from ejagent.agent.state import AgentState, AgentStatus
93
+ from ejagent.agent.types import (
94
+ StepOutcome,
95
+ ToolCallResult,
96
+ ToolControl,
97
+ ToolProgressReporter,
98
+ ToolProgressUpdate,
99
+ )
100
+ from ejagent.agent.usage import RunUsage
101
+ from ejagent.middleware import (
102
+ Middleware,
103
+ RuleBasedToolPolicy,
104
+ ToolApprovalDecision,
105
+ ToolApprovalRequest,
106
+ ToolApprover,
107
+ ToolCallContext,
108
+ ToolExecutionPolicy,
109
+ ToolMiddleware,
110
+ ToolNext,
111
+ ToolPolicyAction,
112
+ ToolPolicyDecision,
113
+ ToolPolicyMiddleware,
114
+ ToolPolicyPredicate,
115
+ ToolPolicyRule,
116
+ ToolSchemaConfigurationError,
117
+ ToolSchemaValidationMiddleware,
118
+ compose_tool_middlewares,
119
+ format_tool_call_preview,
120
+ )
121
+
122
+ __all__ = [
123
+ "BaseAgent",
124
+ "BehaviorAction",
125
+ "BehaviorDecision",
126
+ "BehaviorHook",
127
+ "BehaviorHookError",
128
+ "TurnSnapshot",
129
+ "AgentCancelledError",
130
+ "CancellationSource",
131
+ "CancellationToken",
132
+ "Compactor",
133
+ "CompactorOutput",
134
+ "CompactionRequest",
135
+ "CompactionResult",
136
+ "CompactionRuntime",
137
+ "CompactionStatus",
138
+ "CompactionTrigger",
139
+ "SummaryEntry",
140
+ "CompactionContextBuilder",
141
+ "ModelCompactor",
142
+ "AgentState",
143
+ "AgentStatus",
144
+ "AgentContextBuilder",
145
+ "ContextBuildResult",
146
+ "ContextBudget",
147
+ "ContextUsageEstimate",
148
+ "ContextUsageSource",
149
+ "MessageTokenEstimator",
150
+ "HeuristicMessageTokenEstimator",
151
+ "CompactionPolicy",
152
+ "AutoCompactionPolicy",
153
+ "CompactionDecision",
154
+ "CompactionDecisionReason",
155
+ "CompactionPreparation",
156
+ "estimate_context_usage",
157
+ "prepare_compaction",
158
+ "ControlInputKind",
159
+ "ContinueRejectedReason",
160
+ "ContinueRejectedError",
161
+ "ControlStatus",
162
+ "ControlInput",
163
+ "ControlReceipt",
164
+ "FollowUpFailurePolicy",
165
+ "FollowUpDiscardReason",
166
+ "FollowUpHandle",
167
+ "FollowUpError",
168
+ "FollowUpRejectedError",
169
+ "FollowUpDiscardedError",
170
+ "AgentEvent",
171
+ "AgentEventKind",
172
+ "AgentEventPayload",
173
+ "AgentEventSink",
174
+ "AgentEventSinkError",
175
+ "CompositeAgentEventSink",
176
+ "CompactionStarted",
177
+ "CompactionCompleted",
178
+ "CompactionFailed",
179
+ "ContextPressureEvaluated",
180
+ "AgentStarted",
181
+ "AgentContinued",
182
+ "AssistantThinkingDelta",
183
+ "AssistantTextDelta",
184
+ "TurnStarted",
185
+ "MessageCompleted",
186
+ "SteeringApplied",
187
+ "SteeringDiscarded",
188
+ "ToolStarted",
189
+ "ToolProgressed",
190
+ "ToolCompleted",
191
+ "TurnCompleted",
192
+ "AgentFinished",
193
+ "AgentOrchestrator",
194
+ "RuntimePolicy",
195
+ "AgentRunResult",
196
+ "AgentRunError",
197
+ "RunStatus",
198
+ "StopReason",
199
+ "RunUsage",
200
+ "StepOutcome",
201
+ "ToolCallResult",
202
+ "ToolControl",
203
+ "ToolProgressReporter",
204
+ "ToolProgressUpdate",
205
+ "Middleware",
206
+ "ToolMiddleware",
207
+ "ToolCallContext",
208
+ "ToolNext",
209
+ "ToolExecutionPolicy",
210
+ "RuleBasedToolPolicy",
211
+ "ToolPolicyRule",
212
+ "ToolPolicyAction",
213
+ "ToolPolicyDecision",
214
+ "ToolPolicyMiddleware",
215
+ "ToolPolicyPredicate",
216
+ "ToolApprover",
217
+ "ToolApprovalRequest",
218
+ "ToolApprovalDecision",
219
+ "ToolSchemaConfigurationError",
220
+ "ToolSchemaValidationMiddleware",
221
+ "compose_tool_middlewares",
222
+ "format_tool_call_preview",
223
+ ]