osai-agent 4.2.44 → 4.2.47
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/package.json
CHANGED
package/src/agent/prompt.js
CHANGED
|
@@ -98,54 +98,54 @@ ${modeSection}
|
|
|
98
98
|
${execModeSection}
|
|
99
99
|
## TOOLS AVAILABLE — USE ONLY THESE EXACT FORMATS
|
|
100
100
|
|
|
101
|
-
Use the
|
|
101
|
+
Use the JSON format (recommended) or the legacy XML format. Both are supported.
|
|
102
102
|
|
|
103
103
|
### System Commands
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
{"tool":"LOCAL_CMD","cmd":"<exact command>","type":"READ|WRITE|DANGEROUS","description":"<what and why>"}
|
|
105
|
+
{"tool":"SSH_CMD","cmd":"<command>","type":"READ|WRITE|DANGEROUS","description":"<what and why>"}
|
|
106
106
|
|
|
107
107
|
### File Operations
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
{"tool":"READ_FILE","path":"<path>","description":"<why>"} ← use this to read LOCAL file CONTENTS (not URLs — use FETCH_URL for web)
|
|
109
|
+
{"tool":"WRITE_FILE","path":"<path>","content":"<full content>","description":"<what>"}
|
|
110
|
+
{"tool":"EDIT_FILE","path":"<path>","find":"<text to find (exact or fuzzy match)>","replace":"<replacement>","description":"<what>"}
|
|
111
|
+
{"tool":"APPEND_FILE","path":"<path>","content":"<text to append>","description":"<what>"}
|
|
112
|
+
{"tool":"DELETE_FILE","path":"<path>","description":"<what>"}
|
|
113
|
+
{"tool":"MOVE_FILE","source":"<source>","destination":"<dest>","description":"<what>"}
|
|
114
|
+
{"tool":"COPY_FILE","source":"<source>","destination":"<dest>","description":"<what>"}
|
|
115
|
+
{"tool":"CREATE_DIR","path":"<path>","description":"<what>"}
|
|
116
|
+
{"tool":"LIST_DIR","path":"<path>","description":"<why>"} ← use this to list directory entries (NOT for file content)
|
|
117
|
+
{"tool":"TREE_VIEW","path":"<path>","maxDepth":"<number>","description":"<why>"}
|
|
118
|
+
{"tool":"SEARCH_FILE","path":"<directory>","pattern":"<regex>","filePattern":"<*.ext>","description":"<what searching for>"} ← LOCAL files only (use FETCH_URL/WEB_SEARCH for web content)
|
|
119
|
+
{"tool":"FILE_INFO","path":"<path>","description":"<why>"}
|
|
120
120
|
|
|
121
121
|
### Script Execution
|
|
122
|
-
|
|
122
|
+
{"tool":"RUN_SCRIPT","path":"<script path>","args":"<arguments>","interpreter":"<optional>","description":"<what>"}
|
|
123
123
|
|
|
124
124
|
### Web Tools
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
{"tool":"FETCH_URL","url":"<https://...>","description":"<what you want from this URL>"}
|
|
126
|
+
{"tool":"WEB_SEARCH","query":"<search query>","description":"<why you need this info>"}
|
|
127
127
|
|
|
128
128
|
### Browser Tools (Playwright headless Chromium — reads JS-rendered pages)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
{"tool":"BROWSE","url":"<https://...>","description":"<what you want to read on this page>"}
|
|
130
|
+
{"tool":"BROWSE_SEARCH","query":"<search query>","description":"<what you are searching for>"}
|
|
131
|
+
{"tool":"BROWSE_EXTRACT","url":"<https://...>","selectors":{"key":"CSS selector"},"description":"<what data you need>"}
|
|
132
132
|
|
|
133
133
|
### Todo Management
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
{"tool":"TODO_ADD","text":"<task description>","priority":"<HIGH|MEDIUM|LOW>"}
|
|
135
|
+
{"tool":"TODO_COMPLETE","id":"<todo number>"}
|
|
136
|
+
{"tool":"TODO_UPDATE","id":"<todo number>","text":"<new text>","priority":"<HIGH|MEDIUM|LOW>"}
|
|
137
|
+
{"tool":"TODO_LIST"}
|
|
138
|
+
{"tool":"TODO_CLEAR"}
|
|
139
139
|
|
|
140
140
|
### MCP (Model Context Protocol)
|
|
141
|
-
|
|
141
|
+
{"tool":"MCP_TOOL","server":"<server>","mcpTool":"<tool>","params":{...}}
|
|
142
142
|
Use this to call tools from external MCP servers configured via "osai-agent mcp add".
|
|
143
143
|
|
|
144
144
|
## CRITICAL RULES
|
|
145
145
|
|
|
146
146
|
1. ONLY use tools listed above. NEVER invent a tool name that does not exist.
|
|
147
147
|
2. NEVER output tool calls for tools like "BROWSE_WEB", "INSTALL_PACKAGE", "GIT_CLONE", "COMPILE", etc. Use the correct tools instead.
|
|
148
|
-
3. ALWAYS output tool calls on their own line. Use the
|
|
148
|
+
3. ALWAYS output tool calls on their own line. Use the JSON format: {"tool":"NAME","key":"value"} (recommended). The legacy XML format <tool>NAME key="value"</tool> is also supported. NEVER wrap tool calls in backticks, code fences, or markdown.
|
|
149
149
|
4. ONE tool call per turn. Wait for [TOOL_RESULT] before proceeding.
|
|
150
150
|
5. Exception to rule 4: you MAY output MULTIPLE READ_FILE tool calls in a single turn when you need to read several files at once (e.g. when asked to "read all files" or "check all files"). Each READ_FILE must be on its own line. After ALL results come back, analyze everything together. Do NOT mix READ_FILE with other tools in the same turn.
|
|
151
151
|
6. NEVER simulate or fabricate command output. Only interpret real [TOOL_RESULT] data.
|
|
@@ -225,7 +225,7 @@ NEVER use macOS commands: brew, launchctl, system_profiler, defaults`
|
|
|
225
225
|
## MANDATORY FORMAT
|
|
226
226
|
|
|
227
227
|
BEFORE every tool call: 1-3 sentences explaining what you are doing and why.
|
|
228
|
-
THE TOOL CALL: on its own line, no backticks, no code fences. Use
|
|
228
|
+
THE TOOL CALL: on its own line, no backticks, no code fences. Use JSON format: {"tool":"NAME","key":"value"}. Legacy XML format <tool>NAME key="value"</tool> also supported.
|
|
229
229
|
AFTER [TOOL_RESULT]: analyze the output, then emit [DONE], [INCOMPLETE], or [BLOCKED].
|
|
230
230
|
|
|
231
231
|
## COMPLETION
|
|
@@ -254,7 +254,7 @@ OS: ${osLabel} | Hostname: ${systemInfo.hostname} | CWD: ${systemInfo.cwd}
|
|
|
254
254
|
TOOLS: LOCAL_CMD, READ_FILE, WRITE_FILE, EDIT_FILE, LIST_DIR, SEARCH_FILE, APPEND_FILE, DELETE_FILE, CREATE_DIR, TREE_VIEW, RUN_SCRIPT, MOVE_FILE, COPY_FILE, FILE_INFO, FETCH_URL, WEB_SEARCH, TODO_ADD, TODO_COMPLETE, TODO_UPDATE, TODO_LIST, TODO_CLEAR
|
|
255
255
|
MODE: ${mode}/${execLabel}
|
|
256
256
|
|
|
257
|
-
FORMAT: Explain ->
|
|
257
|
+
FORMAT: Explain -> JSON tool call -> Analyze [TOOL_RESULT] -> [DONE]/[INCOMPLETE]/[BLOCKED]
|
|
258
258
|
RULES: One tool per turn (exception: multiple READ_FILE allowed in parallel). Same language as user. Never simulate output. Never invent tools. Fix errors. Read each file + its dependencies once before modification. Keep work in current cwd unless user approves directory change/out-of-cwd actions. Anti-loop: READ→EDIT→DIAG cycles are automatically detected and blocked.`;
|
|
259
259
|
};
|
|
260
260
|
|
package/src/parser/markdown.js
CHANGED
|
@@ -243,21 +243,21 @@ export const renderMarkdown = (text) => {
|
|
|
243
243
|
|
|
244
244
|
for (const rawLine of lines) {
|
|
245
245
|
// Code block toggle
|
|
246
|
-
const codeMatch = rawLine.match(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
246
|
+
const codeMatch = rawLine.match(/^\s*```(\w*)/);
|
|
247
|
+
if (codeMatch) {
|
|
248
|
+
if (!inCode) {
|
|
249
|
+
inCode = true; codeLang = codeMatch[1] || ''; codeLines = [];
|
|
250
|
+
const label = codeLang ? chalk.bgHex(C.border).hex(C.cyan)(` ${codeLang} `) : '';
|
|
251
|
+
output.push(chalk.hex(C.border)(' ' + S.boxTL + S.boxH) + (label || chalk.hex(C.border)(S.boxH)));
|
|
252
|
+
} else {
|
|
253
|
+
const highlighted = highlightCode(codeLines.join('\n'), codeLang);
|
|
254
|
+
for (const cl of highlighted.split('\n'))
|
|
255
|
+
output.push(chalk.hex(C.border)(' ' + S.boxV + ' ') + cl);
|
|
256
|
+
output.push(chalk.hex(C.border)(' ' + S.boxBL + S.boxH.repeat(4)));
|
|
257
|
+
inCode = false; codeLines = []; codeLang = '';
|
|
258
|
+
}
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
261
|
if (inCode) { codeLines.push(rawLine); continue; }
|
|
262
262
|
|
|
263
263
|
// Table
|
|
@@ -433,7 +433,7 @@ export class StreamMarkdown {
|
|
|
433
433
|
if (/^\s*\[(DONE|INCOMPLETE|BLOCKED|TOOL_CALL|TOOL_RESULT)\]/.test(raw)) return '';
|
|
434
434
|
|
|
435
435
|
// Code block
|
|
436
|
-
const codeMatch = raw.match(
|
|
436
|
+
const codeMatch = raw.match(/^\s*```(\w*)/);
|
|
437
437
|
if (codeMatch) {
|
|
438
438
|
if (!this._inCode) {
|
|
439
439
|
this._inCode = true; this._codeLang = codeMatch[1] || ''; this._codeLines = [];
|
|
@@ -73,7 +73,7 @@ export function Header({ mode, device, isConnected, isLocal, provider, execution
|
|
|
73
73
|
|
|
74
74
|
const statusChunks = isLocal
|
|
75
75
|
? [{ text: DOT + ' Local', color: '#73daca', bold: true }]
|
|
76
|
-
: [{ text: (isConnected ? DOT : EMPTY) + ' Connected', color: isConnected ? '#9ece6a' : '#f7768e', bold: true }];
|
|
76
|
+
: [{ text: (isConnected ? DOT : EMPTY) + (isConnected ? ' Connected' : ' Disconnected'), color: isConnected ? '#9ece6a' : '#f7768e', bold: true }];
|
|
77
77
|
|
|
78
78
|
const items = [
|
|
79
79
|
makeItem([
|