@acontext/acontext 0.1.1 → 0.1.2
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/prompts.d.ts +1 -1
- package/dist/agent/prompts.js +3 -1
- package/dist/agent/sandbox.js +19 -8
- package/dist/agent/text-editor.js +14 -2
- package/package.json +1 -1
package/dist/agent/prompts.d.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
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
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-
|
|
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- You can install new packages with pip if needed (internet access is available)\n\nRemember to always export your artifacts at the end of your task so that the user can view them.\n";
|
package/dist/agent/prompts.js
CHANGED
|
@@ -96,5 +96,7 @@ Container environment:
|
|
|
96
96
|
- Standard Unix utilities available (grep, sed, awk, etc.)
|
|
97
97
|
- Archive tools: tar, unzip, zip
|
|
98
98
|
- Additional tools: ripgrep, fd, sqlite3, jq, imagemagick
|
|
99
|
-
-
|
|
99
|
+
- You can install new packages with pip if needed (internet access is available)
|
|
100
|
+
|
|
101
|
+
Remember to always export your artifacts at the end of your task so that the user can view them.
|
|
100
102
|
`;
|
package/dist/agent/sandbox.js
CHANGED
|
@@ -41,6 +41,13 @@ const path = __importStar(require("path"));
|
|
|
41
41
|
const base_1 = require("./base");
|
|
42
42
|
const prompts_1 = require("./prompts");
|
|
43
43
|
const text_editor_1 = require("./text-editor");
|
|
44
|
+
const MAX_OUTPUT_CHARS = 20000;
|
|
45
|
+
function truncateOutput(text, maxChars = MAX_OUTPUT_CHARS) {
|
|
46
|
+
if (text.length > maxChars) {
|
|
47
|
+
return text.slice(0, maxChars) + '...[truncated]';
|
|
48
|
+
}
|
|
49
|
+
return text;
|
|
50
|
+
}
|
|
44
51
|
function formatMountedSkills(mountedSkillPaths) {
|
|
45
52
|
if (mountedSkillPaths.size === 0) {
|
|
46
53
|
return '';
|
|
@@ -120,8 +127,8 @@ class BashTool extends base_1.AbstractBaseTool {
|
|
|
120
127
|
timeout,
|
|
121
128
|
});
|
|
122
129
|
return JSON.stringify({
|
|
123
|
-
stdout: result.stdout,
|
|
124
|
-
stderr: result.stderr,
|
|
130
|
+
stdout: truncateOutput(result.stdout),
|
|
131
|
+
stderr: truncateOutput(result.stderr),
|
|
125
132
|
exit_code: result.exit_code,
|
|
126
133
|
});
|
|
127
134
|
}
|
|
@@ -136,27 +143,31 @@ class TextEditorTool extends base_1.AbstractBaseTool {
|
|
|
136
143
|
command: {
|
|
137
144
|
type: 'string',
|
|
138
145
|
enum: ['view', 'create', 'str_replace'],
|
|
139
|
-
description: "The operation to perform: 'view', 'create', or 'str_replace'"
|
|
146
|
+
description: "The operation to perform: 'view', 'create', or 'str_replace'. " +
|
|
147
|
+
"Required parameters per command: " +
|
|
148
|
+
"'view' requires path (view_range is optional); " +
|
|
149
|
+
"'create' requires path and file_text; " +
|
|
150
|
+
"'str_replace' requires path, old_str, and new_str.",
|
|
140
151
|
},
|
|
141
152
|
path: {
|
|
142
153
|
type: 'string',
|
|
143
|
-
description: "The file path in the sandbox (e.g., '/workspace/script.py')",
|
|
154
|
+
description: "Required for all commands. The file path in the sandbox (e.g., '/workspace/script.py')",
|
|
144
155
|
},
|
|
145
156
|
file_text: {
|
|
146
157
|
type: ['string', 'null'],
|
|
147
|
-
description: "
|
|
158
|
+
description: "Required for 'create' command. The content to write to the file.",
|
|
148
159
|
},
|
|
149
160
|
old_str: {
|
|
150
161
|
type: ['string', 'null'],
|
|
151
|
-
description: "
|
|
162
|
+
description: "Required for 'str_replace' command. The exact string to find and replace.",
|
|
152
163
|
},
|
|
153
164
|
new_str: {
|
|
154
165
|
type: ['string', 'null'],
|
|
155
|
-
description: "
|
|
166
|
+
description: "Required for 'str_replace' command. The string to replace old_str with.",
|
|
156
167
|
},
|
|
157
168
|
view_range: {
|
|
158
169
|
type: ['array', 'null'],
|
|
159
|
-
description: "
|
|
170
|
+
description: "Optional for 'view' command. An array [start_line, end_line] to view specific lines. If not provided, shows the first 200 lines.",
|
|
160
171
|
},
|
|
161
172
|
};
|
|
162
173
|
this.requiredArguments = ['command', 'path'];
|
|
@@ -7,6 +7,16 @@ exports.escapeForShell = escapeForShell;
|
|
|
7
7
|
exports.viewFile = viewFile;
|
|
8
8
|
exports.createFile = createFile;
|
|
9
9
|
exports.strReplace = strReplace;
|
|
10
|
+
const MAX_CONTENT_CHARS = 20000;
|
|
11
|
+
/**
|
|
12
|
+
* Truncate text to maxChars, appending a truncation flag if needed.
|
|
13
|
+
*/
|
|
14
|
+
function truncateContent(text, maxChars = MAX_CONTENT_CHARS) {
|
|
15
|
+
if (text.length > maxChars) {
|
|
16
|
+
return text.slice(0, maxChars) + '...[truncated]';
|
|
17
|
+
}
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
10
20
|
/**
|
|
11
21
|
* Escape a string for safe use in shell commands.
|
|
12
22
|
*/
|
|
@@ -43,7 +53,9 @@ async function viewFile(ctx, path, viewRange, timeout) {
|
|
|
43
53
|
startLine = rangeStart;
|
|
44
54
|
}
|
|
45
55
|
else {
|
|
46
|
-
|
|
56
|
+
// Default to first 200 lines if no range specified
|
|
57
|
+
const maxLines = 200;
|
|
58
|
+
cmd = `head -n ${maxLines} ${escapeForShell(path)} | nl -ba`;
|
|
47
59
|
startLine = 1;
|
|
48
60
|
}
|
|
49
61
|
const result = await ctx.client.sandboxes.execCommand({
|
|
@@ -64,7 +76,7 @@ async function viewFile(ctx, path, viewRange, timeout) {
|
|
|
64
76
|
const numLines = contentLines.length;
|
|
65
77
|
return {
|
|
66
78
|
file_type: 'text',
|
|
67
|
-
content: result.stdout,
|
|
79
|
+
content: truncateContent(result.stdout),
|
|
68
80
|
numLines,
|
|
69
81
|
startLine: viewRange ? startLine : 1,
|
|
70
82
|
totalLines: totalLines + 1, // wc -l doesn't count last line without newline
|