@acontext/acontext 0.1.0 → 0.1.1
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.
- package/dist/agent/base.d.ts +2 -1
- package/dist/agent/disk.d.ts +8 -7
- package/dist/agent/disk.js +16 -7
- package/dist/agent/index.d.ts +2 -0
- package/dist/agent/index.js +2 -0
- package/dist/agent/prompts.d.ts +6 -0
- package/dist/agent/prompts.js +100 -0
- package/dist/agent/sandbox.d.ts +102 -0
- package/dist/agent/sandbox.js +309 -0
- package/dist/agent/skill.d.ts +2 -8
- package/dist/agent/skill.js +26 -24
- package/dist/agent/text-editor.d.ts +44 -0
- package/dist/agent/text-editor.js +201 -0
- package/dist/client-types.d.ts +1 -0
- package/dist/client.d.ts +1 -4
- package/dist/client.js +4 -6
- package/dist/resources/index.d.ts +0 -2
- package/dist/resources/index.js +0 -2
- package/dist/resources/sandboxes.d.ts +18 -1
- package/dist/resources/sandboxes.js +24 -0
- package/dist/resources/sessions.d.ts +1 -17
- package/dist/resources/sessions.js +0 -26
- package/dist/resources/skills.d.ts +14 -1
- package/dist/resources/skills.js +17 -0
- package/dist/resources/users.d.ts +2 -2
- package/dist/resources/users.js +2 -2
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/sandbox.d.ts +47 -0
- package/dist/types/sandbox.js +24 -1
- package/dist/types/session.d.ts +0 -12
- package/dist/types/session.js +1 -8
- package/dist/types/skill.d.ts +7 -0
- package/dist/types/skill.js +7 -1
- package/dist/types/tool.d.ts +0 -4
- package/dist/types/tool.js +1 -4
- package/dist/types/user.d.ts +0 -2
- package/dist/types/user.js +0 -1
- package/package.json +8 -8
- package/dist/resources/blocks.d.ts +0 -33
- package/dist/resources/blocks.js +0 -85
- package/dist/resources/spaces.d.ts +0 -68
- package/dist/resources/spaces.js +0 -109
- package/dist/types/block.d.ts +0 -18
- package/dist/types/block.js +0 -20
- package/dist/types/space.d.ts +0 -67
- package/dist/types/space.js +0 -44
package/dist/agent/base.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Base classes for agent tools.
|
|
3
3
|
*/
|
|
4
4
|
export interface BaseContext {
|
|
5
|
+
getContextPrompt(): string;
|
|
5
6
|
}
|
|
6
7
|
export interface BaseConverter {
|
|
7
8
|
toOpenAIToolSchema(): Record<string, unknown>;
|
|
@@ -35,5 +36,5 @@ export declare abstract class BaseToolPool {
|
|
|
35
36
|
toOpenAIToolSchema(): Record<string, unknown>[];
|
|
36
37
|
toAnthropicToolSchema(): Record<string, unknown>[];
|
|
37
38
|
toGeminiToolSchema(): Record<string, unknown>[];
|
|
38
|
-
abstract formatContext(...args: unknown[]): BaseContext
|
|
39
|
+
abstract formatContext(...args: unknown[]): BaseContext | Promise<BaseContext>;
|
|
39
40
|
}
|
package/dist/agent/disk.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import { AbstractBaseTool, BaseContext, BaseToolPool } from './base';
|
|
|
6
6
|
export interface DiskContext extends BaseContext {
|
|
7
7
|
client: AcontextClient;
|
|
8
8
|
diskId: string;
|
|
9
|
+
getContextPrompt(): string;
|
|
9
10
|
}
|
|
10
11
|
export declare class WriteFileTool extends AbstractBaseTool {
|
|
11
|
-
readonly name = "
|
|
12
|
+
readonly name = "write_file_disk";
|
|
12
13
|
readonly description = "Write text content to a file in the file system. Creates the file if it doesn't exist, overwrites if it does.";
|
|
13
14
|
readonly arguments: {
|
|
14
15
|
file_path: {
|
|
@@ -28,7 +29,7 @@ export declare class WriteFileTool extends AbstractBaseTool {
|
|
|
28
29
|
execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
29
30
|
}
|
|
30
31
|
export declare class ReadFileTool extends AbstractBaseTool {
|
|
31
|
-
readonly name = "
|
|
32
|
+
readonly name = "read_file_disk";
|
|
32
33
|
readonly description = "Read a text file from the file system and return its content.";
|
|
33
34
|
readonly arguments: {
|
|
34
35
|
file_path: {
|
|
@@ -52,7 +53,7 @@ export declare class ReadFileTool extends AbstractBaseTool {
|
|
|
52
53
|
execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
53
54
|
}
|
|
54
55
|
export declare class ReplaceStringTool extends AbstractBaseTool {
|
|
55
|
-
readonly name = "
|
|
56
|
+
readonly name = "replace_string_disk";
|
|
56
57
|
readonly description = "Replace an old string with a new string in a file. Reads the file, performs the replacement, and writes it back.";
|
|
57
58
|
readonly arguments: {
|
|
58
59
|
file_path: {
|
|
@@ -76,7 +77,7 @@ export declare class ReplaceStringTool extends AbstractBaseTool {
|
|
|
76
77
|
execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
77
78
|
}
|
|
78
79
|
export declare class ListTool extends AbstractBaseTool {
|
|
79
|
-
readonly name = "
|
|
80
|
+
readonly name = "list_disk";
|
|
80
81
|
readonly description = "List all files and directories in a specified path on the disk.";
|
|
81
82
|
readonly arguments: {
|
|
82
83
|
file_path: {
|
|
@@ -88,7 +89,7 @@ export declare class ListTool extends AbstractBaseTool {
|
|
|
88
89
|
execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
89
90
|
}
|
|
90
91
|
export declare class DownloadFileTool extends AbstractBaseTool {
|
|
91
|
-
readonly name = "
|
|
92
|
+
readonly name = "download_file_disk";
|
|
92
93
|
readonly description = "Get a public URL to download a file. Returns a presigned URL that can be shared or used to access the file.";
|
|
93
94
|
readonly arguments: {
|
|
94
95
|
file_path: {
|
|
@@ -108,7 +109,7 @@ export declare class DownloadFileTool extends AbstractBaseTool {
|
|
|
108
109
|
execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
109
110
|
}
|
|
110
111
|
export declare class GrepArtifactsTool extends AbstractBaseTool {
|
|
111
|
-
readonly name = "
|
|
112
|
+
readonly name = "grep_disk";
|
|
112
113
|
readonly description = "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.";
|
|
113
114
|
readonly arguments: {
|
|
114
115
|
query: {
|
|
@@ -124,7 +125,7 @@ export declare class GrepArtifactsTool extends AbstractBaseTool {
|
|
|
124
125
|
execute(ctx: DiskContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
125
126
|
}
|
|
126
127
|
export declare class GlobArtifactsTool extends AbstractBaseTool {
|
|
127
|
-
readonly name = "
|
|
128
|
+
readonly name = "glob_disk";
|
|
128
129
|
readonly description = "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.";
|
|
129
130
|
readonly arguments: {
|
|
130
131
|
query: {
|
package/dist/agent/disk.js
CHANGED
|
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DISK_TOOLS = exports.DiskToolPool = exports.GlobArtifactsTool = exports.GrepArtifactsTool = exports.DownloadFileTool = exports.ListTool = exports.ReplaceStringTool = exports.ReadFileTool = exports.WriteFileTool = void 0;
|
|
7
7
|
const uploads_1 = require("../uploads");
|
|
8
8
|
const base_1 = require("./base");
|
|
9
|
+
const DISK_CONTEXT_PROMPT = `<disk>
|
|
10
|
+
Consider Disk as the google drive for you and user to store and share files.
|
|
11
|
+
You can use tool ends with \`*_disk\` to read, write, edit, and share files with users.
|
|
12
|
+
Disk is only a sharable file storage, you can't use it to execute code or run commands.
|
|
13
|
+
</disk>
|
|
14
|
+
`;
|
|
9
15
|
function normalizePath(path) {
|
|
10
16
|
if (!path) {
|
|
11
17
|
return '/';
|
|
@@ -19,7 +25,7 @@ function normalizePath(path) {
|
|
|
19
25
|
class WriteFileTool extends base_1.AbstractBaseTool {
|
|
20
26
|
constructor() {
|
|
21
27
|
super(...arguments);
|
|
22
|
-
this.name = '
|
|
28
|
+
this.name = 'write_file_disk';
|
|
23
29
|
this.description = "Write text content to a file in the file system. Creates the file if it doesn't exist, overwrites if it does.";
|
|
24
30
|
this.arguments = {
|
|
25
31
|
file_path: {
|
|
@@ -64,7 +70,7 @@ exports.WriteFileTool = WriteFileTool;
|
|
|
64
70
|
class ReadFileTool extends base_1.AbstractBaseTool {
|
|
65
71
|
constructor() {
|
|
66
72
|
super(...arguments);
|
|
67
|
-
this.name = '
|
|
73
|
+
this.name = 'read_file_disk';
|
|
68
74
|
this.description = 'Read a text file from the file system and return its content.';
|
|
69
75
|
this.arguments = {
|
|
70
76
|
file_path: {
|
|
@@ -115,7 +121,7 @@ exports.ReadFileTool = ReadFileTool;
|
|
|
115
121
|
class ReplaceStringTool extends base_1.AbstractBaseTool {
|
|
116
122
|
constructor() {
|
|
117
123
|
super(...arguments);
|
|
118
|
-
this.name = '
|
|
124
|
+
this.name = 'replace_string_disk';
|
|
119
125
|
this.description = 'Replace an old string with a new string in a file. Reads the file, performs the replacement, and writes it back.';
|
|
120
126
|
this.arguments = {
|
|
121
127
|
file_path: {
|
|
@@ -195,7 +201,7 @@ exports.ReplaceStringTool = ReplaceStringTool;
|
|
|
195
201
|
class ListTool extends base_1.AbstractBaseTool {
|
|
196
202
|
constructor() {
|
|
197
203
|
super(...arguments);
|
|
198
|
-
this.name = '
|
|
204
|
+
this.name = 'list_disk';
|
|
199
205
|
this.description = 'List all files and directories in a specified path on the disk.';
|
|
200
206
|
this.arguments = {
|
|
201
207
|
file_path: {
|
|
@@ -223,7 +229,7 @@ exports.ListTool = ListTool;
|
|
|
223
229
|
class DownloadFileTool extends base_1.AbstractBaseTool {
|
|
224
230
|
constructor() {
|
|
225
231
|
super(...arguments);
|
|
226
|
-
this.name = '
|
|
232
|
+
this.name = 'download_file_disk';
|
|
227
233
|
this.description = 'Get a public URL to download a file. Returns a presigned URL that can be shared or used to access the file.';
|
|
228
234
|
this.arguments = {
|
|
229
235
|
file_path: {
|
|
@@ -265,7 +271,7 @@ exports.DownloadFileTool = DownloadFileTool;
|
|
|
265
271
|
class GrepArtifactsTool extends base_1.AbstractBaseTool {
|
|
266
272
|
constructor() {
|
|
267
273
|
super(...arguments);
|
|
268
|
-
this.name = '
|
|
274
|
+
this.name = 'grep_disk';
|
|
269
275
|
this.description = '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.';
|
|
270
276
|
this.arguments = {
|
|
271
277
|
query: {
|
|
@@ -300,7 +306,7 @@ exports.GrepArtifactsTool = GrepArtifactsTool;
|
|
|
300
306
|
class GlobArtifactsTool extends base_1.AbstractBaseTool {
|
|
301
307
|
constructor() {
|
|
302
308
|
super(...arguments);
|
|
303
|
-
this.name = '
|
|
309
|
+
this.name = 'glob_disk';
|
|
304
310
|
this.description = '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.';
|
|
305
311
|
this.arguments = {
|
|
306
312
|
query: {
|
|
@@ -337,6 +343,9 @@ class DiskToolPool extends base_1.BaseToolPool {
|
|
|
337
343
|
return {
|
|
338
344
|
client,
|
|
339
345
|
diskId,
|
|
346
|
+
getContextPrompt() {
|
|
347
|
+
return DISK_CONTEXT_PROMPT;
|
|
348
|
+
},
|
|
340
349
|
};
|
|
341
350
|
}
|
|
342
351
|
}
|
package/dist/agent/index.d.ts
CHANGED
package/dist/agent/index.js
CHANGED
|
@@ -19,4 +19,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
__exportStar(require("./base"), exports);
|
|
21
21
|
__exportStar(require("./disk"), exports);
|
|
22
|
+
__exportStar(require("./prompts"), exports);
|
|
23
|
+
__exportStar(require("./sandbox"), exports);
|
|
22
24
|
__exportStar(require("./skill"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt constants for agent tools.
|
|
3
|
+
*/
|
|
4
|
+
export declare const SKILL_REMINDER = "MANDATORY SKILL READING AND EXECUTION PROTOCOL:\nBEFORE writing ANY code or using ANY execution tools, You MUST complete ALL of\nthese steps:\n\nSTEP 1 - IDENTIFY ALL RELEVANT SKILLS:\n- Scan the user message for ALL trigger words from ALL skills\n- Identify EVERY skill that matches ANY trigger word\n- If multiple skills match, ALL must be processed\n- If no skills match, you can skip the following steps\n\nSTEP 2 - READ ALL SKILL FILES:\n- Use the text_editor_sandbox tool to view EACH identified skill's SKILL.md file\n- READ COMPLETELY - do not skim or skip sections\n- This step is MANDATORY even if multiple skills are involved\n- DO NOT proceed until ALL relevant skill files have been read\n\nSTEP 3 - EXECUTE ALL SKILL INSTRUCTIONS:\n- Follow the EXACT instructions from EACH skill file read\n- If a skill file says to execute file X, then EXECUTE file X\n- If a skill file provides code patterns, USE those patterns\n- Apply instructions from ALL skills, not just the first one\n- NEVER write generic code when skill-specific code exists\n\nCRITICAL RULES:\n- Reading the skill file is NOT sufficient - you must FOLLOW its instructions\n- Multiple skills = multiple skill files to read AND follow\n- Each skill's instructions must be executed, not just acknowledged\n- NEVER skip a skill because you already read another skill\n- The skills contain specialized, tested code that MUST be used\n\nDO NOT SKIP ANY SKILL FILES OR THEIR INSTRUCTIONS. This protocol applies to EVERY\nskill that matches the user's request, without exception.";
|
|
5
|
+
export declare const SANDBOX_TEXT_EDITOR_REMINDER = "The text_editor_sandbox tool enables viewing, creating, and modifying text files within\nthe secure sandboxed container environment.\n\nHow it works:\n- All file operations occur within the sandboxed container filesystem\n\nCommand guidelines:\n- Always use view before editing to understand file structure\n- For str_replace commands, ensure search strings are unique and exact\n- Include sufficient context in str_replace for accurate placement\n- Use proper escaping for special characters in search/replace strings";
|
|
6
|
+
export declare const SANDBOX_BASH_REMINDER = "When to use the bash_execution_sandbox tool directly:\n- File system operations requiring shell commands (moving, copying, renaming, organizing files)\n- Text processing and manipulation using standard Unix tools (grep, sed, awk, cut, sort, etc.) that\nshould not be done by the text editor tool\n- Batch processing of multiple files using shell loops and wildcards\n- System inspection tasks (checking file sizes, permissions, directory structures)\n- Combining multiple command-line tools in pipelines for complex data processing\n- Archive operations (tar, unzip) and file compression/decompression\n- Converting between file formats using command-line utilities\n\nWhen you should write Python file and use bash tool to run it:\n- Complex data analysis or numerical computation (use file operations to write a Python script instead, and\nthen the bash to run the script)\n- Tasks requiring advanced programming logic or data structures\n\nWhen NOT to use the bash_execution_sandbox tool:\n- Simple questions that can be answered without executing commands\n- Tasks that only require explaining shell concepts without actual execution\n\nHow it works:\n- Scripts are saved to a temporary sandbox and executed with bash\n- Tool results will include stdout, stderr, and return code\n- User-uploaded files are accessible in the directory specified by the INPUT_DIR environment variable. If\nyou know the file path and don't need to open the full INPUT_DIR, then just open the file directly\n\nFile Operations (CRITICAL - READ CAREFULLY):\n- use text_editor_sandbox tool to view, create, and edit files.\n\nExport Your Result:\n- All the files you created kept in the sandbox, which user can't see or access.\n- If you want to export them to user, use `export_file_sandbox` tool.\n- If too many files to export(>= 6 files), zip those files and export the zip file.\n- Result files' names should be unique and descriptive, (wrong: result.md, output.md... right: 2026_us_market_trending.png)\n\nScript guidelines:\n- Write POSIX-compliant bash scripts\n- Use proper error handling and exit codes\n- Quote variables appropriately to handle spaces in filenames\n- Keep scripts clean and well-organized\n- For file operations, use text_editor_sandbox tool instead of bash commands.\n\nNever write blocking script:\n- python codes like `plt.show()` or `input()`... will block the execution of the script, don't use them. write non-blocking code instead.\n\nContainer environment:\n- Filesystem persists across multiple executions within the same container\n- Standard Unix utilities available (grep, sed, awk, etc.)\n- Archive tools: tar, unzip, zip\n- Additional tools: ripgrep, fd, sqlite3, jq, imagemagick\n- Do not try to install new packages and libraries with pip as there is no internet access\n";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompt constants for agent tools.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SANDBOX_BASH_REMINDER = exports.SANDBOX_TEXT_EDITOR_REMINDER = exports.SKILL_REMINDER = void 0;
|
|
7
|
+
exports.SKILL_REMINDER = `MANDATORY SKILL READING AND EXECUTION PROTOCOL:
|
|
8
|
+
BEFORE writing ANY code or using ANY execution tools, You MUST complete ALL of
|
|
9
|
+
these steps:
|
|
10
|
+
|
|
11
|
+
STEP 1 - IDENTIFY ALL RELEVANT SKILLS:
|
|
12
|
+
- Scan the user message for ALL trigger words from ALL skills
|
|
13
|
+
- Identify EVERY skill that matches ANY trigger word
|
|
14
|
+
- If multiple skills match, ALL must be processed
|
|
15
|
+
- If no skills match, you can skip the following steps
|
|
16
|
+
|
|
17
|
+
STEP 2 - READ ALL SKILL FILES:
|
|
18
|
+
- Use the text_editor_sandbox tool to view EACH identified skill's SKILL.md file
|
|
19
|
+
- READ COMPLETELY - do not skim or skip sections
|
|
20
|
+
- This step is MANDATORY even if multiple skills are involved
|
|
21
|
+
- DO NOT proceed until ALL relevant skill files have been read
|
|
22
|
+
|
|
23
|
+
STEP 3 - EXECUTE ALL SKILL INSTRUCTIONS:
|
|
24
|
+
- Follow the EXACT instructions from EACH skill file read
|
|
25
|
+
- If a skill file says to execute file X, then EXECUTE file X
|
|
26
|
+
- If a skill file provides code patterns, USE those patterns
|
|
27
|
+
- Apply instructions from ALL skills, not just the first one
|
|
28
|
+
- NEVER write generic code when skill-specific code exists
|
|
29
|
+
|
|
30
|
+
CRITICAL RULES:
|
|
31
|
+
- Reading the skill file is NOT sufficient - you must FOLLOW its instructions
|
|
32
|
+
- Multiple skills = multiple skill files to read AND follow
|
|
33
|
+
- Each skill's instructions must be executed, not just acknowledged
|
|
34
|
+
- NEVER skip a skill because you already read another skill
|
|
35
|
+
- The skills contain specialized, tested code that MUST be used
|
|
36
|
+
|
|
37
|
+
DO NOT SKIP ANY SKILL FILES OR THEIR INSTRUCTIONS. This protocol applies to EVERY
|
|
38
|
+
skill that matches the user's request, without exception.`;
|
|
39
|
+
exports.SANDBOX_TEXT_EDITOR_REMINDER = `The text_editor_sandbox tool enables viewing, creating, and modifying text files within
|
|
40
|
+
the secure sandboxed container environment.
|
|
41
|
+
|
|
42
|
+
How it works:
|
|
43
|
+
- All file operations occur within the sandboxed container filesystem
|
|
44
|
+
|
|
45
|
+
Command guidelines:
|
|
46
|
+
- Always use view before editing to understand file structure
|
|
47
|
+
- For str_replace commands, ensure search strings are unique and exact
|
|
48
|
+
- Include sufficient context in str_replace for accurate placement
|
|
49
|
+
- Use proper escaping for special characters in search/replace strings`;
|
|
50
|
+
exports.SANDBOX_BASH_REMINDER = `When to use the bash_execution_sandbox tool directly:
|
|
51
|
+
- File system operations requiring shell commands (moving, copying, renaming, organizing files)
|
|
52
|
+
- Text processing and manipulation using standard Unix tools (grep, sed, awk, cut, sort, etc.) that
|
|
53
|
+
should not be done by the text editor tool
|
|
54
|
+
- Batch processing of multiple files using shell loops and wildcards
|
|
55
|
+
- System inspection tasks (checking file sizes, permissions, directory structures)
|
|
56
|
+
- Combining multiple command-line tools in pipelines for complex data processing
|
|
57
|
+
- Archive operations (tar, unzip) and file compression/decompression
|
|
58
|
+
- Converting between file formats using command-line utilities
|
|
59
|
+
|
|
60
|
+
When you should write Python file and use bash tool to run it:
|
|
61
|
+
- Complex data analysis or numerical computation (use file operations to write a Python script instead, and
|
|
62
|
+
then the bash to run the script)
|
|
63
|
+
- Tasks requiring advanced programming logic or data structures
|
|
64
|
+
|
|
65
|
+
When NOT to use the bash_execution_sandbox tool:
|
|
66
|
+
- Simple questions that can be answered without executing commands
|
|
67
|
+
- Tasks that only require explaining shell concepts without actual execution
|
|
68
|
+
|
|
69
|
+
How it works:
|
|
70
|
+
- Scripts are saved to a temporary sandbox and executed with bash
|
|
71
|
+
- Tool results will include stdout, stderr, and return code
|
|
72
|
+
- User-uploaded files are accessible in the directory specified by the INPUT_DIR environment variable. If
|
|
73
|
+
you know the file path and don't need to open the full INPUT_DIR, then just open the file directly
|
|
74
|
+
|
|
75
|
+
File Operations (CRITICAL - READ CAREFULLY):
|
|
76
|
+
- use text_editor_sandbox tool to view, create, and edit files.
|
|
77
|
+
|
|
78
|
+
Export Your Result:
|
|
79
|
+
- All the files you created kept in the sandbox, which user can't see or access.
|
|
80
|
+
- If you want to export them to user, use \`export_file_sandbox\` tool.
|
|
81
|
+
- If too many files to export(>= 6 files), zip those files and export the zip file.
|
|
82
|
+
- Result files' names should be unique and descriptive, (wrong: result.md, output.md... right: 2026_us_market_trending.png)
|
|
83
|
+
|
|
84
|
+
Script guidelines:
|
|
85
|
+
- Write POSIX-compliant bash scripts
|
|
86
|
+
- Use proper error handling and exit codes
|
|
87
|
+
- Quote variables appropriately to handle spaces in filenames
|
|
88
|
+
- Keep scripts clean and well-organized
|
|
89
|
+
- For file operations, use text_editor_sandbox tool instead of bash commands.
|
|
90
|
+
|
|
91
|
+
Never write blocking script:
|
|
92
|
+
- python codes like \`plt.show()\` or \`input()\`... will block the execution of the script, don't use them. write non-blocking code instead.
|
|
93
|
+
|
|
94
|
+
Container environment:
|
|
95
|
+
- Filesystem persists across multiple executions within the same container
|
|
96
|
+
- Standard Unix utilities available (grep, sed, awk, etc.)
|
|
97
|
+
- Archive tools: tar, unzip, zip
|
|
98
|
+
- Additional tools: ripgrep, fd, sqlite3, jq, imagemagick
|
|
99
|
+
- Do not try to install new packages and libraries with pip as there is no internet access
|
|
100
|
+
`;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent tools for sandbox operations using the Acontext Sandbox API.
|
|
3
|
+
*/
|
|
4
|
+
import { AcontextClient } from '../client';
|
|
5
|
+
import { AbstractBaseTool, BaseContext, BaseToolPool } from './base';
|
|
6
|
+
export interface MountedSkill {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
basePath: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SandboxContext extends BaseContext {
|
|
12
|
+
client: AcontextClient;
|
|
13
|
+
sandboxId: string;
|
|
14
|
+
diskId: string;
|
|
15
|
+
mountedSkillPaths: Map<string, MountedSkill>;
|
|
16
|
+
getContextPrompt(): string;
|
|
17
|
+
formatMountedSkills(): string;
|
|
18
|
+
mountSkills(skillIds: string[]): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare class BashTool extends AbstractBaseTool {
|
|
21
|
+
private _timeout?;
|
|
22
|
+
constructor(timeout?: number);
|
|
23
|
+
readonly name = "bash_execution_sandbox";
|
|
24
|
+
readonly description = "The bash_execution_sandbox tool enables execution of bash scripts in a secure sandboxed container environment.";
|
|
25
|
+
readonly arguments: {
|
|
26
|
+
command: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
timeout: {
|
|
31
|
+
type: string[];
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
readonly requiredArguments: string[];
|
|
36
|
+
execute(ctx: SandboxContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
37
|
+
}
|
|
38
|
+
export declare class TextEditorTool extends AbstractBaseTool {
|
|
39
|
+
private _timeout?;
|
|
40
|
+
constructor(timeout?: number);
|
|
41
|
+
readonly name = "text_editor_sandbox";
|
|
42
|
+
readonly description = "A tool for viewing, creating, and editing text files in the sandbox.";
|
|
43
|
+
readonly arguments: {
|
|
44
|
+
command: {
|
|
45
|
+
type: string;
|
|
46
|
+
enum: string[];
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
path: {
|
|
50
|
+
type: string;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
file_text: {
|
|
54
|
+
type: string[];
|
|
55
|
+
description: string;
|
|
56
|
+
};
|
|
57
|
+
old_str: {
|
|
58
|
+
type: string[];
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
new_str: {
|
|
62
|
+
type: string[];
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
view_range: {
|
|
66
|
+
type: string[];
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly requiredArguments: string[];
|
|
71
|
+
execute(ctx: SandboxContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
72
|
+
}
|
|
73
|
+
export declare class ExportSandboxFileTool extends AbstractBaseTool {
|
|
74
|
+
readonly name = "export_file_sandbox";
|
|
75
|
+
readonly description = "Export a file from the sandbox to persistent, shared disk storage, and return you a public download URL.\nIf the sandbox file is changed, the disk file won't be updated unless you export the file again.";
|
|
76
|
+
readonly arguments: {
|
|
77
|
+
sandbox_path: {
|
|
78
|
+
type: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
sandbox_filename: {
|
|
82
|
+
type: string;
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
readonly requiredArguments: string[];
|
|
87
|
+
execute(ctx: SandboxContext, llmArguments: Record<string, unknown>): Promise<string>;
|
|
88
|
+
}
|
|
89
|
+
export declare class SandboxToolPool extends BaseToolPool {
|
|
90
|
+
/**
|
|
91
|
+
* Create a sandbox context.
|
|
92
|
+
*
|
|
93
|
+
* @param client - The Acontext client instance.
|
|
94
|
+
* @param sandboxId - The UUID of the sandbox.
|
|
95
|
+
* @param diskId - The UUID of the disk for file exports.
|
|
96
|
+
* @param mountSkills - Optional list of skill IDs to download to the sandbox.
|
|
97
|
+
* Skills are downloaded to /skills/{skill_name}/ in the sandbox.
|
|
98
|
+
* @returns Promise resolving to SandboxContext for use with sandbox tools.
|
|
99
|
+
*/
|
|
100
|
+
formatContext(client: AcontextClient, sandboxId: string, diskId: string, mountSkills?: string[]): Promise<SandboxContext>;
|
|
101
|
+
}
|
|
102
|
+
export declare const SANDBOX_TOOLS: SandboxToolPool;
|