acontext 0.1.2__py3-none-any.whl → 0.1.4__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.
acontext/__init__.py CHANGED
@@ -8,16 +8,12 @@ from .async_client import AcontextAsyncClient
8
8
  from .client import AcontextClient, FileUpload, MessagePart
9
9
  from .messages import AcontextMessage
10
10
  from .resources import (
11
- AsyncBlocksAPI,
12
11
  AsyncDiskArtifactsAPI,
13
12
  AsyncDisksAPI,
14
13
  AsyncSessionsAPI,
15
- AsyncSpacesAPI,
16
- BlocksAPI,
17
14
  DiskArtifactsAPI,
18
15
  DisksAPI,
19
16
  SessionsAPI,
20
- SpacesAPI,
21
17
  )
22
18
  from .types import Task, TaskData
23
19
 
@@ -29,14 +25,10 @@ __all__ = [
29
25
  "AcontextMessage",
30
26
  "DisksAPI",
31
27
  "DiskArtifactsAPI",
32
- "BlocksAPI",
33
28
  "SessionsAPI",
34
- "SpacesAPI",
35
29
  "AsyncDisksAPI",
36
30
  "AsyncDiskArtifactsAPI",
37
- "AsyncBlocksAPI",
38
31
  "AsyncSessionsAPI",
39
- "AsyncSpacesAPI",
40
32
  "Task",
41
33
  "TaskData",
42
34
  "__version__",
@@ -1,9 +1,11 @@
1
1
  """Agent tools for LLM function calling."""
2
2
 
3
3
  from .disk import DISK_TOOLS
4
+ from .sandbox import SANDBOX_TOOLS
4
5
  from .skill import SKILL_TOOLS
5
6
 
6
7
  __all__ = [
7
8
  "DISK_TOOLS",
9
+ "SANDBOX_TOOLS",
8
10
  "SKILL_TOOLS",
9
11
  ]
acontext/agent/base.py CHANGED
@@ -1,5 +1,6 @@
1
1
  class BaseContext:
2
- pass
2
+ def get_context_prompt(self, *args, **kwargs) -> str:
3
+ return ""
3
4
 
4
5
 
5
6
  class BaseConverter:
acontext/agent/disk.py CHANGED
@@ -11,11 +11,18 @@ class DiskContext(BaseContext):
11
11
  client: AcontextClient
12
12
  disk_id: str
13
13
 
14
+ def get_context_prompt(self) -> str:
15
+ return """<disk>
16
+ Consider Disk as the google drive for you and user to store and share files.
17
+ You can use tool ends with `*_disk` to read, write, edit, and share files with users.
18
+ Disk is only a sharable file storage, you can't use it to execute code or run commands.
19
+ </disk>
20
+ """
21
+
14
22
 
15
23
  @dataclass
16
- class AsyncDiskContext(BaseContext):
24
+ class AsyncDiskContext(DiskContext):
17
25
  client: AcontextAsyncClient
18
- disk_id: str
19
26
 
20
27
 
21
28
  def _normalize_path(path: str | None) -> str:
@@ -33,7 +40,7 @@ class WriteFileTool(BaseTool):
33
40
 
34
41
  @property
35
42
  def name(self) -> str:
36
- return "write_file"
43
+ return "write_file_disk"
37
44
 
38
45
  @property
39
46
  def description(self) -> str:
@@ -43,7 +50,7 @@ class WriteFileTool(BaseTool):
43
50
  def arguments(self) -> dict:
44
51
  return {
45
52
  "file_path": {
46
- "type": "string",
53
+ "type": ["string", "null"],
47
54
  "description": "Optional folder path to organize files, e.g. '/notes/' or '/documents/'. Defaults to root '/' if not specified.",
48
55
  },
49
56
  "filename": {
@@ -106,7 +113,7 @@ class ReadFileTool(BaseTool):
106
113
 
107
114
  @property
108
115
  def name(self) -> str:
109
- return "read_file"
116
+ return "read_file_disk"
110
117
 
111
118
  @property
112
119
  def description(self) -> str:
@@ -116,7 +123,7 @@ class ReadFileTool(BaseTool):
116
123
  def arguments(self) -> dict:
117
124
  return {
118
125
  "file_path": {
119
- "type": "string",
126
+ "type": ["string", "null"],
120
127
  "description": "Optional directory path where the file is located, e.g. '/notes/'. Defaults to root '/' if not specified.",
121
128
  },
122
129
  "filename": {
@@ -124,11 +131,11 @@ class ReadFileTool(BaseTool):
124
131
  "description": "Filename to read.",
125
132
  },
126
133
  "line_offset": {
127
- "type": "integer",
134
+ "type": ["integer", "null"],
128
135
  "description": "The line number to start reading from. Default to 0",
129
136
  },
130
137
  "line_limit": {
131
- "type": "integer",
138
+ "type": ["integer", "null"],
132
139
  "description": "The maximum number of lines to return. Default to 100",
133
140
  },
134
141
  }
@@ -199,7 +206,7 @@ class ReplaceStringTool(BaseTool):
199
206
 
200
207
  @property
201
208
  def name(self) -> str:
202
- return "replace_string"
209
+ return "replace_string_disk"
203
210
 
204
211
  @property
205
212
  def description(self) -> str:
@@ -209,7 +216,7 @@ class ReplaceStringTool(BaseTool):
209
216
  def arguments(self) -> dict:
210
217
  return {
211
218
  "file_path": {
212
- "type": "string",
219
+ "type": ["string", "null"],
213
220
  "description": "Optional directory path where the file is located, e.g. '/notes/'. Defaults to root '/' if not specified.",
214
221
  },
215
222
  "filename": {
@@ -328,7 +335,7 @@ class ListTool(BaseTool):
328
335
 
329
336
  @property
330
337
  def name(self) -> str:
331
- return "list_artifacts"
338
+ return "list_disk"
332
339
 
333
340
  @property
334
341
  def description(self) -> str:
@@ -403,7 +410,7 @@ class DownloadFileTool(BaseTool):
403
410
 
404
411
  @property
405
412
  def name(self) -> str:
406
- return "download_file"
413
+ return "download_file_disk"
407
414
 
408
415
  @property
409
416
  def description(self) -> str:
@@ -413,7 +420,7 @@ class DownloadFileTool(BaseTool):
413
420
  def arguments(self) -> dict:
414
421
  return {
415
422
  "file_path": {
416
- "type": "string",
423
+ "type": ["string", "null"],
417
424
  "description": "Optional directory path where the file is located, e.g. '/notes/'. Defaults to root '/' if not specified.",
418
425
  },
419
426
  "filename": {
@@ -421,7 +428,7 @@ class DownloadFileTool(BaseTool):
421
428
  "description": "Filename to get the download URL for.",
422
429
  },
423
430
  "expire": {
424
- "type": "integer",
431
+ "type": ["integer", "null"],
425
432
  "description": "URL expiration time in seconds. Defaults to 3600 (1 hour).",
426
433
  },
427
434
  }
@@ -482,7 +489,7 @@ class GrepArtifactsTool(BaseTool):
482
489
 
483
490
  @property
484
491
  def name(self) -> str:
485
- return "grep_artifacts"
492
+ return "grep_disk"
486
493
 
487
494
  @property
488
495
  def description(self) -> str:
@@ -496,7 +503,7 @@ class GrepArtifactsTool(BaseTool):
496
503
  "description": "Regex pattern to search for (e.g., 'TODO.*', 'function.*calculate', 'import.*pandas')",
497
504
  },
498
505
  "limit": {
499
- "type": "integer",
506
+ "type": ["integer", "null"],
500
507
  "description": "Maximum number of results to return (default 100)",
501
508
  },
502
509
  }
@@ -561,7 +568,7 @@ class GlobArtifactsTool(BaseTool):
561
568
 
562
569
  @property
563
570
  def name(self) -> str:
564
- return "glob_artifacts"
571
+ return "glob_disk"
565
572
 
566
573
  @property
567
574
  def description(self) -> str:
@@ -575,7 +582,7 @@ class GlobArtifactsTool(BaseTool):
575
582
  "description": "Glob pattern (e.g., '**/*.py' for all Python files, '*.txt' for text files in root, '/docs/**/*.md' for markdown in docs)",
576
583
  },
577
584
  "limit": {
578
- "type": "integer",
585
+ "type": ["integer", "null"],
579
586
  "description": "Maximum number of results to return (default 100)",
580
587
  },
581
588
  }
@@ -0,0 +1,96 @@
1
+ SKILL_REMINDER = """MANDATORY SKILL READING AND EXECUTION PROTOCOL:
2
+ BEFORE writing ANY code or using ANY execution tools, You MUST complete ALL of
3
+ these steps:
4
+
5
+ STEP 1 - IDENTIFY ALL RELEVANT SKILLS:
6
+ - Scan the user message for ALL trigger words from ALL skills
7
+ - Identify EVERY skill that matches ANY trigger word
8
+ - If multiple skills match, ALL must be processed
9
+ - If no skills match, you can skip the following steps
10
+
11
+ STEP 2 - READ ALL SKILL FILES:
12
+ - Use the text_editor_sandbox tool to view EACH identified skill's SKILL.md file
13
+ - READ COMPLETELY - do not skim or skip sections
14
+ - This step is MANDATORY even if multiple skills are involved
15
+ - DO NOT proceed until ALL relevant skill files have been read
16
+
17
+ STEP 3 - EXECUTE ALL SKILL INSTRUCTIONS:
18
+ - Follow the EXACT instructions from EACH skill file read
19
+ - If a skill file says to execute file X, then EXECUTE file X
20
+ - If a skill file provides code patterns, USE those patterns
21
+ - Apply instructions from ALL skills, not just the first one
22
+ - NEVER write generic code when skill-specific code exists
23
+
24
+ CRITICAL RULES:
25
+ - Reading the skill file is NOT sufficient - you must FOLLOW its instructions
26
+ - Multiple skills = multiple skill files to read AND follow
27
+ - Each skill's instructions must be executed, not just acknowledged
28
+ - NEVER skip a skill because you already read another skill
29
+ - The skills contain specialized, tested code that MUST be used
30
+
31
+ DO NOT SKIP ANY SKILL FILES OR THEIR INSTRUCTIONS. This protocol applies to EVERY
32
+ skill that matches the user's request, without exception."""
33
+
34
+ SANDBOX_TEXT_EDITOR_REMINDER = """The text_editor_sandbox tool enables viewing, creating, and modifying text files within
35
+ the secure sandboxed container environment.
36
+
37
+ How it works:
38
+ - All file operations occur within the sandboxed container filesystem
39
+
40
+ Command guidelines:
41
+ - Always use view before editing to understand file structure
42
+ - For str_replace commands, ensure search strings are unique and exact
43
+ - Include sufficient context in str_replace for accurate placement
44
+ - Use proper escaping for special characters in search/replace strings"""
45
+
46
+ SANDBOX_BASH_REMINDER = """When to use the bash_execution_sandbox tool directly:
47
+ - File system operations requiring shell commands (moving, copying, renaming, organizing files)
48
+ - Text processing and manipulation using standard Unix tools (grep, sed, awk, cut, sort, etc.) that
49
+ should not be done by the text editor tool
50
+ - Batch processing of multiple files using shell loops and wildcards
51
+ - System inspection tasks (checking file sizes, permissions, directory structures)
52
+ - Combining multiple command-line tools in pipelines for complex data processing
53
+ - Archive operations (tar, unzip) and file compression/decompression
54
+ - Converting between file formats using command-line utilities
55
+
56
+ When you should write Python file and use bash tool to run it:
57
+ - Complex data analysis or numerical computation (use file operations to write a Python script instead, and
58
+ then the bash to run the script)
59
+ - Tasks requiring advanced programming logic or data structures
60
+
61
+ When NOT to use the bash_execution_sandbox tool:
62
+ - Simple questions that can be answered without executing commands
63
+ - Tasks that only require explaining shell concepts without actual execution
64
+
65
+ How it works:
66
+ - Scripts are saved to a temporary sandbox and executed with bash
67
+ - Tool results will include stdout, stderr, and return code
68
+ - User-uploaded files are accessible in the directory specified by the INPUT_DIR environment variable. If
69
+ you know the file path and don't need to open the full INPUT_DIR, then just open the file directly
70
+
71
+ File Operations (CRITICAL - READ CAREFULLY):
72
+ - use text_editor_sandbox tool to view, create, and edit files.
73
+
74
+ Export Your Result:
75
+ - All the files you created kept in the sandbox, which user can't see or access.
76
+ - If you want to export them to user, use `export_file_sandbox` tool.
77
+ - If too many files to export(>= 6 files), zip those files and export the zip file.
78
+ - Result files' names should be unique and descriptive, (wrong: result.md, output.md... right: 2026_us_market_trending.png)
79
+
80
+ Script guidelines:
81
+ - Write POSIX-compliant bash scripts
82
+ - Use proper error handling and exit codes
83
+ - Quote variables appropriately to handle spaces in filenames
84
+ - Keep scripts clean and well-organized
85
+ - For file operations, use text_editor_sandbox tool instead of bash commands.
86
+
87
+ Never write blocking script:
88
+ - python codes like `plt.show()` or `input()`... will block the execution of the script, don't use them. write non-blocking code instead.
89
+
90
+ Container environment:
91
+ - Filesystem persists across multiple executions within the same container
92
+ - Standard Unix utilities available (grep, sed, awk, etc.)
93
+ - Archive tools: tar, unzip, zip
94
+ - Additional tools: ripgrep, fd, sqlite3, jq, imagemagick
95
+ - Do not try to install new packages and libraries with pip as there is no internet access
96
+ """