acontext 0.1.1__tar.gz → 0.1.2__tar.gz

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 (41) hide show
  1. {acontext-0.1.1 → acontext-0.1.2}/PKG-INFO +2 -2
  2. {acontext-0.1.1 → acontext-0.1.2}/pyproject.toml +1 -1
  3. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/async_sessions.py +42 -0
  4. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/sessions.py +51 -8
  5. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/session.py +25 -1
  6. {acontext-0.1.1 → acontext-0.1.2}/README.md +0 -0
  7. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/__init__.py +0 -0
  8. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/_constants.py +0 -0
  9. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/_utils.py +0 -0
  10. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/agent/__init__.py +0 -0
  11. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/agent/base.py +0 -0
  12. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/agent/disk.py +0 -0
  13. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/agent/skill.py +0 -0
  14. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/async_client.py +0 -0
  15. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/client.py +0 -0
  16. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/client_types.py +0 -0
  17. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/errors.py +0 -0
  18. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/messages.py +0 -0
  19. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/py.typed +0 -0
  20. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/__init__.py +0 -0
  21. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/async_blocks.py +0 -0
  22. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/async_disks.py +0 -0
  23. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/async_skills.py +0 -0
  24. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/async_spaces.py +0 -0
  25. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/async_tools.py +0 -0
  26. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/async_users.py +0 -0
  27. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/blocks.py +0 -0
  28. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/disks.py +0 -0
  29. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/skills.py +0 -0
  30. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/spaces.py +0 -0
  31. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/tools.py +0 -0
  32. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/resources/users.py +0 -0
  33. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/__init__.py +0 -0
  34. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/block.py +0 -0
  35. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/common.py +0 -0
  36. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/disk.py +0 -0
  37. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/skill.py +0 -0
  38. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/space.py +0 -0
  39. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/tool.py +0 -0
  40. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/types/user.py +0 -0
  41. {acontext-0.1.1 → acontext-0.1.2}/src/acontext/uploads.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: acontext
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Python SDK for the Acontext API
5
5
  Keywords: acontext,sdk,client,api
6
6
  Requires-Dist: httpx>=0.28.1
@@ -10,8 +10,8 @@ Requires-Dist: pydantic>=2.12.3
10
10
  Requires-Dist: urllib3>=2.6.3
11
11
  Requires-Python: >=3.10
12
12
  Project-URL: Homepage, https://github.com/memodb-io/Acontext
13
- Project-URL: Issues, https://github.com/memodb-io/Acontext/issues
14
13
  Project-URL: Repository, https://github.com/memodb-io/Acontext
14
+ Project-URL: Issues, https://github.com/memodb-io/Acontext/issues
15
15
  Description-Content-Type: text/markdown
16
16
 
17
17
  ## acontext client for python
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "acontext"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Python SDK for the Acontext API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -180,6 +180,47 @@ class AsyncSessionsAPI:
180
180
  )
181
181
  return GetTasksOutput.model_validate(data)
182
182
 
183
+ async def get_session_summary(
184
+ self,
185
+ session_id: str,
186
+ *,
187
+ limit: int | None = None,
188
+ ) -> str:
189
+ """Get a summary of all tasks in a session as a formatted string.
190
+
191
+ Args:
192
+ session_id: The UUID of the session.
193
+ limit: Maximum number of tasks to include in the summary. Defaults to None (all tasks).
194
+
195
+ Returns:
196
+ A formatted string containing the session summary with all task information.
197
+ """
198
+ tasks_output = await self.get_tasks(session_id, limit=limit, time_desc=False)
199
+ tasks = tasks_output.items
200
+
201
+ if not tasks:
202
+ return ""
203
+
204
+ parts: list[str] = []
205
+ for task in tasks:
206
+ task_lines = [
207
+ f'<task id="{task.order}" description="{task.data.task_description}">'
208
+ ]
209
+ if task.data.progresses:
210
+ task_lines.append("<progress>")
211
+ for i, p in enumerate(task.data.progresses, 1):
212
+ task_lines.append(f"{i}. {p}")
213
+ task_lines.append("</progress>")
214
+ if task.data.user_preferences:
215
+ task_lines.append("<user_preference>")
216
+ for i, pref in enumerate(task.data.user_preferences, 1):
217
+ task_lines.append(f"{i}. {pref}")
218
+ task_lines.append("</user_preference>")
219
+ task_lines.append("</task>")
220
+ parts.append("\n".join(task_lines))
221
+
222
+ return "\n".join(parts)
223
+
183
224
  async def store_message(
184
225
  self,
185
226
  session_id: str,
@@ -294,6 +335,7 @@ class AsyncSessionsAPI:
294
335
  Each strategy is a dict with 'type' and 'params' keys.
295
336
  Examples:
296
337
  - Remove tool results: [{"type": "remove_tool_result", "params": {"keep_recent_n_tool_results": 3}}]
338
+ - Middle out: [{"type": "middle_out", "params": {"token_reduce_to": 5000}}]
297
339
  - Token limit: [{"type": "token_limit", "params": {"limit_tokens": 20000}}]
298
340
  Defaults to None.
299
341
  pin_editing_strategies_at_message: Message ID to pin editing strategies at.
@@ -180,6 +180,47 @@ class SessionsAPI:
180
180
  )
181
181
  return GetTasksOutput.model_validate(data)
182
182
 
183
+ def get_session_summary(
184
+ self,
185
+ session_id: str,
186
+ *,
187
+ limit: int | None = None,
188
+ ) -> str:
189
+ """Get a summary of all tasks in a session as a formatted string.
190
+
191
+ Args:
192
+ session_id: The UUID of the session.
193
+ limit: Maximum number of tasks to include in the summary. Defaults to None (all tasks).
194
+
195
+ Returns:
196
+ A formatted string containing the session summary with all task information.
197
+ """
198
+ tasks_output = self.get_tasks(session_id, limit=limit, time_desc=False)
199
+ tasks = tasks_output.items
200
+
201
+ if not tasks:
202
+ return ""
203
+
204
+ parts: list[str] = []
205
+ for task in tasks:
206
+ task_lines = [
207
+ f'<task id="{task.order}" description="{task.data.task_description}">'
208
+ ]
209
+ if task.data.progresses:
210
+ task_lines.append("<progress>")
211
+ for i, p in enumerate(task.data.progresses, 1):
212
+ task_lines.append(f"{i}. {p}")
213
+ task_lines.append("</progress>")
214
+ if task.data.user_preferences:
215
+ task_lines.append("<user_preference>")
216
+ for i, pref in enumerate(task.data.user_preferences, 1):
217
+ task_lines.append(f"{i}. {pref}")
218
+ task_lines.append("</user_preference>")
219
+ task_lines.append("</task>")
220
+ parts.append("\n".join(task_lines))
221
+
222
+ return "\n".join(parts)
223
+
183
224
  def store_message(
184
225
  self,
185
226
  session_id: str,
@@ -294,6 +335,7 @@ class SessionsAPI:
294
335
  Each strategy is a dict with 'type' and 'params' keys.
295
336
  Examples:
296
337
  - Remove tool results: [{"type": "remove_tool_result", "params": {"keep_recent_n_tool_results": 3}}]
338
+ - Middle out: [{"type": "middle_out", "params": {"token_reduce_to": 5000}}]
297
339
  - Token limit: [{"type": "token_limit", "params": {"limit_tokens": 20000}}]
298
340
  Defaults to None.
299
341
  pin_editing_strategies_at_message: Message ID to pin editing strategies at.
@@ -320,7 +362,9 @@ class SessionsAPI:
320
362
  if edit_strategies is not None:
321
363
  params["edit_strategies"] = json.dumps(edit_strategies)
322
364
  if pin_editing_strategies_at_message is not None:
323
- params["pin_editing_strategies_at_message"] = pin_editing_strategies_at_message
365
+ params["pin_editing_strategies_at_message"] = (
366
+ pin_editing_strategies_at_message
367
+ )
324
368
  data = self._requester.request(
325
369
  "GET", f"/session/{session_id}/messages", params=params or None
326
370
  )
@@ -366,20 +410,19 @@ class SessionsAPI:
366
410
  """
367
411
  data = self._requester.request("GET", f"/session/{session_id}/token_counts")
368
412
  return TokenCounts.model_validate(data)
413
+
369
414
  def messages_observing_status(self, session_id: str) -> MessageObservingStatus:
370
415
  """Get message observing status counts for a session.
371
-
416
+
372
417
  Returns the count of messages by their observing status:
373
418
  observed, in_process, and pending.
374
-
419
+
375
420
  Args:
376
421
  session_id: The UUID of the session.
377
-
422
+
378
423
  Returns:
379
- MessageObservingStatus object containing observed, in_process,
424
+ MessageObservingStatus object containing observed, in_process,
380
425
  pending counts and updated_at timestamp.
381
426
  """
382
- data = self._requester.request(
383
- "GET", f"/session/{session_id}/observing_status"
384
- )
427
+ data = self._requester.request("GET", f"/session/{session_id}/observing_status")
385
428
  return MessageObservingStatus.model_validate(data)
@@ -89,10 +89,34 @@ class TokenLimitStrategy(TypedDict):
89
89
  params: TokenLimitParams
90
90
 
91
91
 
92
+ class MiddleOutParams(TypedDict):
93
+ """Parameters for the middle_out edit strategy.
94
+
95
+ Attributes:
96
+ token_reduce_to: Target token count to reduce the prompt to. Required parameter.
97
+ """
98
+
99
+ token_reduce_to: int
100
+
101
+
102
+ class MiddleOutStrategy(TypedDict):
103
+ """Edit strategy to reduce prompt size by removing middle messages.
104
+
105
+ Example:
106
+ {"type": "middle_out", "params": {"token_reduce_to": 5000}}
107
+ """
108
+
109
+ type: Literal["middle_out"]
110
+ params: MiddleOutParams
111
+
112
+
92
113
  # Union type for all edit strategies
93
114
  # When adding new strategies, add them to this Union: EditStrategy = Union[RemoveToolResultStrategy, OtherStrategy, ...]
94
115
  EditStrategy = Union[
95
- RemoveToolResultStrategy, RemoveToolCallParamsStrategy, TokenLimitStrategy
116
+ RemoveToolResultStrategy,
117
+ RemoveToolCallParamsStrategy,
118
+ TokenLimitStrategy,
119
+ MiddleOutStrategy,
96
120
  ]
97
121
 
98
122
 
File without changes
File without changes