@blockrun/runcode 1.6.1 → 1.6.3
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/context.js +14 -1
- package/dist/tools/askuser.d.ts +6 -0
- package/dist/tools/askuser.js +58 -0
- package/dist/tools/index.js +2 -0
- package/package.json +1 -1
package/dist/agent/context.js
CHANGED
|
@@ -35,10 +35,23 @@ You have access to tools for reading, writing, editing files, running shell comm
|
|
|
35
35
|
- Use Bash for builds, tests, git operations, and system commands.
|
|
36
36
|
- Use WebSearch + WebFetch together to research topics.
|
|
37
37
|
|
|
38
|
+
# Safety
|
|
39
|
+
- Never write to system paths (/etc, /usr, ~/.ssh, ~/.aws).
|
|
40
|
+
- Avoid destructive git operations (force push, reset --hard) unless explicitly asked.
|
|
41
|
+
- Don't commit secrets, credentials, or .env files.
|
|
42
|
+
- When unsure about a destructive action, use AskUser to confirm.
|
|
43
|
+
|
|
38
44
|
# Communication
|
|
39
45
|
- Be concise. Lead with the answer or action.
|
|
40
46
|
- Show what you changed and why.
|
|
41
|
-
- When blocked, explain what you tried and ask for guidance
|
|
47
|
+
- When blocked, explain what you tried and ask for guidance.
|
|
48
|
+
- Use AskUser when you need clarification before proceeding with ambiguous requests.
|
|
49
|
+
|
|
50
|
+
# Slash Commands Available
|
|
51
|
+
The user can type these shortcuts: /commit, /review, /test, /fix, /debug, /explain <file>,
|
|
52
|
+
/search <query>, /find <pattern>, /refactor <desc>, /init, /todo, /deps, /diff, /status,
|
|
53
|
+
/log, /branch, /stash, /plan, /execute, /compact, /retry, /sessions, /resume, /tasks,
|
|
54
|
+
/context, /doctor, /model, /cost, /clear, /help, /exit.`;
|
|
42
55
|
/**
|
|
43
56
|
* Build the full system instructions array for a session.
|
|
44
57
|
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AskUser capability — let the agent ask the user a clarifying question.
|
|
3
|
+
* The question is displayed and the response is returned as tool output.
|
|
4
|
+
*/
|
|
5
|
+
import type { CapabilityHandler } from '../agent/types.js';
|
|
6
|
+
export declare const askUserCapability: CapabilityHandler;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AskUser capability — let the agent ask the user a clarifying question.
|
|
3
|
+
* The question is displayed and the response is returned as tool output.
|
|
4
|
+
*/
|
|
5
|
+
import readline from 'node:readline';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
async function execute(input, _ctx) {
|
|
8
|
+
const { question, options } = input;
|
|
9
|
+
if (!question) {
|
|
10
|
+
return { output: 'Error: question is required', isError: true };
|
|
11
|
+
}
|
|
12
|
+
console.error('');
|
|
13
|
+
console.error(chalk.yellow(' ╭─ Question ────────────────────────────'));
|
|
14
|
+
console.error(chalk.yellow(` │ ${question}`));
|
|
15
|
+
if (options && options.length > 0) {
|
|
16
|
+
for (let i = 0; i < options.length; i++) {
|
|
17
|
+
console.error(chalk.dim(` │ ${i + 1}. ${options[i]}`));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
console.error(chalk.yellow(' ╰───────────────────────────────────────'));
|
|
21
|
+
const rl = readline.createInterface({
|
|
22
|
+
input: process.stdin,
|
|
23
|
+
output: process.stderr,
|
|
24
|
+
terminal: process.stdin.isTTY ?? false,
|
|
25
|
+
});
|
|
26
|
+
return new Promise((resolve) => {
|
|
27
|
+
let answered = false;
|
|
28
|
+
rl.question(chalk.bold(' answer> '), (answer) => {
|
|
29
|
+
answered = true;
|
|
30
|
+
rl.close();
|
|
31
|
+
resolve({ output: answer.trim() || '(no response)' });
|
|
32
|
+
});
|
|
33
|
+
rl.on('close', () => {
|
|
34
|
+
if (!answered)
|
|
35
|
+
resolve({ output: '(user skipped)' });
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export const askUserCapability = {
|
|
40
|
+
spec: {
|
|
41
|
+
name: 'AskUser',
|
|
42
|
+
description: 'Ask the user a clarifying question. Use when you need more information before proceeding.',
|
|
43
|
+
input_schema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
question: { type: 'string', description: 'The question to ask the user' },
|
|
47
|
+
options: {
|
|
48
|
+
type: 'array',
|
|
49
|
+
items: { type: 'string' },
|
|
50
|
+
description: 'Optional list of suggested answers to present',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
required: ['question'],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
execute,
|
|
57
|
+
concurrent: false,
|
|
58
|
+
};
|
package/dist/tools/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { webFetchCapability } from './webfetch.js';
|
|
|
11
11
|
import { webSearchCapability } from './websearch.js';
|
|
12
12
|
import { taskCapability } from './task.js';
|
|
13
13
|
import { imageGenCapability } from './imagegen.js';
|
|
14
|
+
import { askUserCapability } from './askuser.js';
|
|
14
15
|
/** All capabilities available to the runcode agent (excluding sub-agent, which needs config). */
|
|
15
16
|
export const allCapabilities = [
|
|
16
17
|
readCapability,
|
|
@@ -23,6 +24,7 @@ export const allCapabilities = [
|
|
|
23
24
|
webSearchCapability,
|
|
24
25
|
taskCapability,
|
|
25
26
|
imageGenCapability,
|
|
27
|
+
askUserCapability,
|
|
26
28
|
];
|
|
27
29
|
export { readCapability, writeCapability, editCapability, bashCapability, globCapability, grepCapability, webFetchCapability, webSearchCapability, taskCapability, };
|
|
28
30
|
export { createSubAgentCapability } from './subagent.js';
|