acontext 0.0.16__tar.gz → 0.0.17__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 (43) hide show
  1. {acontext-0.0.16 → acontext-0.0.17}/PKG-INFO +1 -1
  2. {acontext-0.0.16 → acontext-0.0.17}/pyproject.toml +1 -1
  3. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/agent/disk.py +106 -0
  4. acontext-0.0.17/src/acontext/resources/async_users.py +57 -0
  5. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/disks.py +81 -0
  6. acontext-0.0.17/src/acontext/resources/users.py +57 -0
  7. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/__init__.py +11 -0
  8. acontext-0.0.17/src/acontext/types/user.py +36 -0
  9. acontext-0.0.16/src/acontext/resources/async_users.py +0 -20
  10. acontext-0.0.16/src/acontext/resources/users.py +0 -20
  11. {acontext-0.0.16 → acontext-0.0.17}/README.md +0 -0
  12. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/__init__.py +0 -0
  13. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/_constants.py +0 -0
  14. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/_utils.py +0 -0
  15. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/agent/__init__.py +0 -0
  16. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/agent/base.py +0 -0
  17. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/agent/skill.py +0 -0
  18. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/async_client.py +0 -0
  19. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/client.py +0 -0
  20. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/client_types.py +0 -0
  21. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/errors.py +0 -0
  22. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/messages.py +0 -0
  23. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/py.typed +0 -0
  24. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/__init__.py +0 -0
  25. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/async_blocks.py +0 -0
  26. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/async_disks.py +0 -0
  27. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/async_sessions.py +0 -0
  28. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/async_skills.py +0 -0
  29. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/async_spaces.py +0 -0
  30. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/async_tools.py +0 -0
  31. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/blocks.py +0 -0
  32. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/sessions.py +0 -0
  33. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/skills.py +0 -0
  34. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/spaces.py +0 -0
  35. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/resources/tools.py +0 -0
  36. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/block.py +0 -0
  37. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/common.py +0 -0
  38. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/disk.py +0 -0
  39. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/session.py +0 -0
  40. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/skill.py +0 -0
  41. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/space.py +0 -0
  42. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/types/tool.py +0 -0
  43. {acontext-0.0.16 → acontext-0.0.17}/src/acontext/uploads.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: acontext
3
- Version: 0.0.16
3
+ Version: 0.0.17
4
4
  Summary: Python SDK for the Acontext API
5
5
  Keywords: acontext,sdk,client,api
6
6
  Requires-Dist: httpx>=0.28.1
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "acontext"
3
- version = "0.0.16"
3
+ version = "0.0.17"
4
4
  description = "Python SDK for the Acontext API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -328,6 +328,110 @@ class DownloadFileTool(BaseTool):
328
328
  return f"Public download URL for '{normalized_path}{filename}' (expires in {expire}s):\n{result.public_url}"
329
329
 
330
330
 
331
+ class GrepArtifactsTool(BaseTool):
332
+ """Tool for searching artifact content using regex patterns."""
333
+
334
+ @property
335
+ def name(self) -> str:
336
+ return "grep_artifacts"
337
+
338
+ @property
339
+ def description(self) -> str:
340
+ return "Search for text patterns within file contents using regex. Only searches text-based files (code, markdown, json, csv, etc.). Use this to find specific code patterns, TODO comments, function definitions, or any text content."
341
+
342
+ @property
343
+ def arguments(self) -> dict:
344
+ return {
345
+ "query": {
346
+ "type": "string",
347
+ "description": "Regex pattern to search for (e.g., 'TODO.*', 'function.*calculate', 'import.*pandas')",
348
+ },
349
+ "limit": {
350
+ "type": "integer",
351
+ "description": "Maximum number of results to return (default 100)",
352
+ },
353
+ }
354
+
355
+ @property
356
+ def required_arguments(self) -> list[str]:
357
+ return ["query"]
358
+
359
+ def execute(self, ctx: DiskContext, llm_arguments: dict) -> str:
360
+ """Search artifact content using regex pattern."""
361
+ query = llm_arguments.get("query")
362
+ limit = llm_arguments.get("limit", 100)
363
+
364
+ if not query:
365
+ raise ValueError("query is required")
366
+
367
+ results = ctx.client.disks.artifacts.grep_artifacts(
368
+ ctx.disk_id,
369
+ query=query,
370
+ limit=limit,
371
+ )
372
+
373
+ if not results:
374
+ return f"No matches found for pattern '{query}'"
375
+
376
+ matches = []
377
+ for artifact in results:
378
+ matches.append(f"{artifact.path}{artifact.filename}")
379
+
380
+ return f"Found {len(matches)} file(s) matching '{query}':\n" + "\n".join(matches)
381
+
382
+
383
+ class GlobArtifactsTool(BaseTool):
384
+ """Tool for finding files by path pattern using glob syntax."""
385
+
386
+ @property
387
+ def name(self) -> str:
388
+ return "glob_artifacts"
389
+
390
+ @property
391
+ def description(self) -> str:
392
+ return "Find files by path pattern using glob syntax. Use * for any characters, ? for single character, ** for recursive directories. Perfect for finding files by extension or location."
393
+
394
+ @property
395
+ def arguments(self) -> dict:
396
+ return {
397
+ "query": {
398
+ "type": "string",
399
+ "description": "Glob pattern (e.g., '**/*.py' for all Python files, '*.txt' for text files in root, '/docs/**/*.md' for markdown in docs)",
400
+ },
401
+ "limit": {
402
+ "type": "integer",
403
+ "description": "Maximum number of results to return (default 100)",
404
+ },
405
+ }
406
+
407
+ @property
408
+ def required_arguments(self) -> list[str]:
409
+ return ["query"]
410
+
411
+ def execute(self, ctx: DiskContext, llm_arguments: dict) -> str:
412
+ """Search artifact paths using glob pattern."""
413
+ query = llm_arguments.get("query")
414
+ limit = llm_arguments.get("limit", 100)
415
+
416
+ if not query:
417
+ raise ValueError("query is required")
418
+
419
+ results = ctx.client.disks.artifacts.glob_artifacts(
420
+ ctx.disk_id,
421
+ query=query,
422
+ limit=limit,
423
+ )
424
+
425
+ if not results:
426
+ return f"No files found matching pattern '{query}'"
427
+
428
+ matches = []
429
+ for artifact in results:
430
+ matches.append(f"{artifact.path}{artifact.filename}")
431
+
432
+ return f"Found {len(matches)} file(s) matching '{query}':\n" + "\n".join(matches)
433
+
434
+
331
435
  class DiskToolPool(BaseToolPool):
332
436
  """Tool pool for disk operations on Acontext disks."""
333
437
 
@@ -340,6 +444,8 @@ DISK_TOOLS.add_tool(WriteFileTool())
340
444
  DISK_TOOLS.add_tool(ReadFileTool())
341
445
  DISK_TOOLS.add_tool(ReplaceStringTool())
342
446
  DISK_TOOLS.add_tool(ListTool())
447
+ DISK_TOOLS.add_tool(GrepArtifactsTool())
448
+ DISK_TOOLS.add_tool(GlobArtifactsTool())
343
449
  DISK_TOOLS.add_tool(DownloadFileTool())
344
450
 
345
451
 
@@ -0,0 +1,57 @@
1
+ """
2
+ User management endpoints (async).
3
+ """
4
+
5
+ from urllib.parse import quote
6
+
7
+ from .._utils import build_params
8
+ from ..client_types import AsyncRequesterProtocol
9
+ from ..types.user import GetUserResourcesOutput, ListUsersOutput
10
+
11
+
12
+ class AsyncUsersAPI:
13
+ def __init__(self, requester: AsyncRequesterProtocol) -> None:
14
+ self._requester = requester
15
+
16
+ async def list(
17
+ self,
18
+ *,
19
+ limit: int | None = None,
20
+ cursor: str | None = None,
21
+ time_desc: bool | None = None,
22
+ ) -> ListUsersOutput:
23
+ """List all users in the project.
24
+
25
+ Args:
26
+ limit: Maximum number of users to return. If not provided or 0, all users will be returned. Defaults to None.
27
+ cursor: Cursor for pagination. Defaults to None.
28
+ time_desc: Order by created_at descending if True, ascending if False. Defaults to None.
29
+
30
+ Returns:
31
+ ListUsersOutput containing the list of users and pagination information.
32
+ """
33
+ params = build_params(limit=limit, cursor=cursor, time_desc=time_desc)
34
+ data = await self._requester.request("GET", "/user/ls", params=params or None)
35
+ return ListUsersOutput.model_validate(data)
36
+
37
+ async def get_resources(self, identifier: str) -> GetUserResourcesOutput:
38
+ """Get resource counts for a user.
39
+
40
+ Args:
41
+ identifier: The user identifier string.
42
+
43
+ Returns:
44
+ GetUserResourcesOutput containing counts for Spaces, Sessions, Disks, and Skills.
45
+ """
46
+ data = await self._requester.request(
47
+ "GET", f"/user/{quote(identifier, safe='')}/resources"
48
+ )
49
+ return GetUserResourcesOutput.model_validate(data)
50
+
51
+ async def delete(self, identifier: str) -> None:
52
+ """Delete a user and cascade delete all associated resources (Space, Session, Disk, Skill).
53
+
54
+ Args:
55
+ identifier: The user identifier string.
56
+ """
57
+ await self._requester.request("DELETE", f"/user/{quote(identifier, safe='')}")
@@ -2,10 +2,14 @@
2
2
  Disk and artifact endpoints.
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  import json
6
8
  from collections.abc import Mapping
7
9
  from typing import Any, BinaryIO, cast
8
10
 
11
+ from pydantic import TypeAdapter
12
+
9
13
  from .._utils import build_params
10
14
  from ..client_types import RequesterProtocol
11
15
  from ..types.disk import (
@@ -195,8 +199,85 @@ class DiskArtifactsAPI:
195
199
  *,
196
200
  path: str | None = None,
197
201
  ) -> ListArtifactsResp:
202
+ """List artifacts in a disk at a specific path.
203
+
204
+ Args:
205
+ disk_id: The UUID of the disk.
206
+ path: Directory path to list. Defaults to None (root).
207
+
208
+ Returns:
209
+ ListArtifactsResp containing the list of artifacts.
210
+ """
198
211
  params: dict[str, Any] = {}
199
212
  if path is not None:
200
213
  params["path"] = path
201
214
  data = self._requester.request("GET", f"/disk/{disk_id}/artifact/ls", params=params or None)
202
215
  return ListArtifactsResp.model_validate(data)
216
+
217
+ def grep_artifacts(
218
+ self,
219
+ disk_id: str,
220
+ *,
221
+ query: str,
222
+ limit: int = 100,
223
+ ) -> list[Artifact]:
224
+ """Search artifact content using regex pattern.
225
+
226
+ Args:
227
+ disk_id: The disk ID to search in
228
+ query: Regex pattern to search for in file content
229
+ limit: Maximum number of results (default 100, max 1000)
230
+
231
+ Returns:
232
+ List of matching artifacts
233
+
234
+ Example:
235
+ ```python
236
+ # Search for TODO comments in code
237
+ results = client.disks.artifacts.grep_artifacts(
238
+ disk_id="disk-uuid",
239
+ query="TODO.*bug"
240
+ )
241
+ ```
242
+ """
243
+ params = build_params(query=query, limit=limit)
244
+ data = self._requester.request(
245
+ "GET",
246
+ f"/disk/{disk_id}/artifact/grep",
247
+ params=params
248
+ )
249
+ return TypeAdapter(list[Artifact]).validate_python(data)
250
+
251
+ def glob_artifacts(
252
+ self,
253
+ disk_id: str,
254
+ *,
255
+ query: str,
256
+ limit: int = 100,
257
+ ) -> list[Artifact]:
258
+ """Search artifact paths using glob pattern.
259
+
260
+ Args:
261
+ disk_id: The disk ID to search in
262
+ query: Glob pattern (e.g., '**/*.py', '*.txt')
263
+ limit: Maximum number of results (default 100, max 1000)
264
+
265
+ Returns:
266
+ List of matching artifacts
267
+
268
+ Example:
269
+ ```python
270
+ # Find all Python files
271
+ results = client.disks.artifacts.glob_artifacts(
272
+ disk_id="disk-uuid",
273
+ query="**/*.py"
274
+ )
275
+ ```
276
+ """
277
+ params = build_params(query=query, limit=limit)
278
+ data = self._requester.request(
279
+ "GET",
280
+ f"/disk/{disk_id}/artifact/glob",
281
+ params=params
282
+ )
283
+ return TypeAdapter(list[Artifact]).validate_python(data)
@@ -0,0 +1,57 @@
1
+ """
2
+ User management endpoints.
3
+ """
4
+
5
+ from urllib.parse import quote
6
+
7
+ from .._utils import build_params
8
+ from ..client_types import RequesterProtocol
9
+ from ..types.user import GetUserResourcesOutput, ListUsersOutput
10
+
11
+
12
+ class UsersAPI:
13
+ def __init__(self, requester: RequesterProtocol) -> None:
14
+ self._requester = requester
15
+
16
+ def list(
17
+ self,
18
+ *,
19
+ limit: int | None = None,
20
+ cursor: str | None = None,
21
+ time_desc: bool | None = None,
22
+ ) -> ListUsersOutput:
23
+ """List all users in the project.
24
+
25
+ Args:
26
+ limit: Maximum number of users to return. If not provided or 0, all users will be returned. Defaults to None.
27
+ cursor: Cursor for pagination. Defaults to None.
28
+ time_desc: Order by created_at descending if True, ascending if False. Defaults to None.
29
+
30
+ Returns:
31
+ ListUsersOutput containing the list of users and pagination information.
32
+ """
33
+ params = build_params(limit=limit, cursor=cursor, time_desc=time_desc)
34
+ data = self._requester.request("GET", "/user/ls", params=params or None)
35
+ return ListUsersOutput.model_validate(data)
36
+
37
+ def get_resources(self, identifier: str) -> GetUserResourcesOutput:
38
+ """Get resource counts for a user.
39
+
40
+ Args:
41
+ identifier: The user identifier string.
42
+
43
+ Returns:
44
+ GetUserResourcesOutput containing counts for Spaces, Sessions, Disks, and Skills.
45
+ """
46
+ data = self._requester.request(
47
+ "GET", f"/user/{quote(identifier, safe='')}/resources"
48
+ )
49
+ return GetUserResourcesOutput.model_validate(data)
50
+
51
+ def delete(self, identifier: str) -> None:
52
+ """Delete a user and cascade delete all associated resources (Space, Session, Disk, Skill).
53
+
54
+ Args:
55
+ identifier: The user identifier string.
56
+ """
57
+ self._requester.request("DELETE", f"/user/{quote(identifier, safe='')}")
@@ -45,6 +45,12 @@ from .skill import (
45
45
  Skill,
46
46
  SkillCatalogItem,
47
47
  )
48
+ from .user import (
49
+ GetUserResourcesOutput,
50
+ ListUsersOutput,
51
+ User,
52
+ UserResourceCounts,
53
+ )
48
54
 
49
55
  __all__ = [
50
56
  # Disk types
@@ -88,4 +94,9 @@ __all__ = [
88
94
  "SkillCatalogItem",
89
95
  "ListSkillsOutput",
90
96
  "GetSkillFileResp",
97
+ # User types
98
+ "GetUserResourcesOutput",
99
+ "ListUsersOutput",
100
+ "User",
101
+ "UserResourceCounts",
91
102
  ]
@@ -0,0 +1,36 @@
1
+ """Type definitions for user resources."""
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+
6
+ class User(BaseModel):
7
+ """User model representing a user resource."""
8
+
9
+ id: str = Field(..., description="User UUID")
10
+ project_id: str = Field(..., description="Project UUID")
11
+ identifier: str = Field(..., description="User identifier string")
12
+ created_at: str = Field(..., description="ISO 8601 formatted creation timestamp")
13
+ updated_at: str = Field(..., description="ISO 8601 formatted update timestamp")
14
+
15
+
16
+ class ListUsersOutput(BaseModel):
17
+ """Response model for listing users."""
18
+
19
+ items: list[User] = Field(..., description="List of users")
20
+ next_cursor: str | None = Field(None, description="Cursor for pagination")
21
+ has_more: bool = Field(..., description="Whether there are more items")
22
+
23
+
24
+ class UserResourceCounts(BaseModel):
25
+ """Resource counts for a user."""
26
+
27
+ spaces_count: int = Field(..., description="Number of spaces")
28
+ sessions_count: int = Field(..., description="Number of sessions")
29
+ disks_count: int = Field(..., description="Number of disks")
30
+ skills_count: int = Field(..., description="Number of skills")
31
+
32
+
33
+ class GetUserResourcesOutput(BaseModel):
34
+ """Response model for getting user resources."""
35
+
36
+ counts: UserResourceCounts = Field(..., description="Resource counts")
@@ -1,20 +0,0 @@
1
- """
2
- User management endpoints (async).
3
- """
4
-
5
- from urllib.parse import quote
6
-
7
- from ..client_types import AsyncRequesterProtocol
8
-
9
-
10
- class AsyncUsersAPI:
11
- def __init__(self, requester: AsyncRequesterProtocol) -> None:
12
- self._requester = requester
13
-
14
- async def delete(self, identifier: str) -> None:
15
- """Delete a user and cascade delete all associated resources (Space, Session, Disk, Skill).
16
-
17
- Args:
18
- identifier: The user identifier string.
19
- """
20
- await self._requester.request("DELETE", f"/user/{quote(identifier, safe='')}")
@@ -1,20 +0,0 @@
1
- """
2
- User management endpoints.
3
- """
4
-
5
- from urllib.parse import quote
6
-
7
- from ..client_types import RequesterProtocol
8
-
9
-
10
- class UsersAPI:
11
- def __init__(self, requester: RequesterProtocol) -> None:
12
- self._requester = requester
13
-
14
- def delete(self, identifier: str) -> None:
15
- """Delete a user and cascade delete all associated resources (Space, Session, Disk, Skill).
16
-
17
- Args:
18
- identifier: The user identifier string.
19
- """
20
- self._requester.request("DELETE", f"/user/{quote(identifier, safe='')}")
File without changes