fix(test): resolve embedded runner crash and timeout
This commit is contained in:
parent
7101cba543
commit
c7ea713c61
@ -101,7 +101,7 @@ beforeAll(async () => {
|
|||||||
workspaceDir = path.join(tempRoot, "workspace");
|
workspaceDir = path.join(tempRoot, "workspace");
|
||||||
await fs.mkdir(agentDir, { recursive: true });
|
await fs.mkdir(agentDir, { recursive: true });
|
||||||
await fs.mkdir(workspaceDir, { recursive: true });
|
await fs.mkdir(workspaceDir, { recursive: true });
|
||||||
}, 20_000);
|
}, 120_000);
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (!tempRoot) return;
|
if (!tempRoot) return;
|
||||||
|
|||||||
@ -83,21 +83,21 @@ function buildMessagingSection(params: {
|
|||||||
"- Never use exec/curl for provider messaging; Moltbot handles all routing internally.",
|
"- Never use exec/curl for provider messaging; Moltbot handles all routing internally.",
|
||||||
params.availableTools.has("message")
|
params.availableTools.has("message")
|
||||||
? [
|
? [
|
||||||
"",
|
"",
|
||||||
"### message tool",
|
"### message tool",
|
||||||
"- Use `message` for proactive sends + channel actions (polls, reactions, etc.).",
|
"- Use `message` for proactive sends + channel actions (polls, reactions, etc.).",
|
||||||
"- For `action=send`, include `to` and `message`.",
|
"- For `action=send`, include `to` and `message`.",
|
||||||
`- If multiple channels are configured, pass \`channel\` (${params.messageChannelOptions}).`,
|
`- If multiple channels are configured, pass \`channel\` (${params.messageChannelOptions}).`,
|
||||||
`- If you use \`message\` (\`action=send\`) to deliver your user-visible reply, respond with ONLY: ${SILENT_REPLY_TOKEN} (avoid duplicate replies).`,
|
`- If you use \`message\` (\`action=send\`) to deliver your user-visible reply, respond with ONLY: ${SILENT_REPLY_TOKEN} (avoid duplicate replies).`,
|
||||||
params.inlineButtonsEnabled
|
params.inlineButtonsEnabled
|
||||||
? "- Inline buttons supported. Use `action=send` with `buttons=[[{text,callback_data}]]` (callback_data routes back as a user message)."
|
? "- Inline buttons supported. Use `action=send` with `buttons=[[{text,callback_data}]]` (callback_data routes back as a user message)."
|
||||||
: params.runtimeChannel
|
: params.runtimeChannel
|
||||||
? `- Inline buttons not enabled for ${params.runtimeChannel}. If you need them, ask to set ${params.runtimeChannel}.capabilities.inlineButtons ("dm"|"group"|"all"|"allowlist").`
|
? `- Inline buttons not enabled for ${params.runtimeChannel}. If you need them, ask to set ${params.runtimeChannel}.capabilities.inlineButtons ("dm"|"group"|"all"|"allowlist").`
|
||||||
: "",
|
: "",
|
||||||
...(params.messageToolHints ?? []),
|
...(params.messageToolHints ?? []),
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join("\n")
|
.join("\n")
|
||||||
: "",
|
: "",
|
||||||
"",
|
"",
|
||||||
];
|
];
|
||||||
@ -282,15 +282,15 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
: undefined;
|
: undefined;
|
||||||
const reasoningHint = params.reasoningTagHint
|
const reasoningHint = params.reasoningTagHint
|
||||||
? [
|
? [
|
||||||
"ALL internal reasoning MUST be inside <think>...</think>.",
|
"ALL internal reasoning MUST be inside <think>...</think>.",
|
||||||
"Do not output any analysis outside <think>.",
|
"Do not output any analysis outside <think>.",
|
||||||
"Format every reply as <think>...</think> then <final>...</final>, with no other text.",
|
"Format every reply as <think>...</think> then <final>...</final>, with no other text.",
|
||||||
"Only the final user-visible reply may appear inside <final>.",
|
"Only the final user-visible reply may appear inside <final>.",
|
||||||
"Only text inside <final> is shown to the user; everything else is discarded and never seen by the user.",
|
"Only text inside <final> is shown to the user; everything else is discarded and never seen by the user.",
|
||||||
"Example:",
|
"Example:",
|
||||||
"<think>Short internal reasoning.</think>",
|
"<think>Short internal reasoning.</think>",
|
||||||
"<final>Hey there! What would you like to do next?</final>",
|
"<final>Hey there! What would you like to do next?</final>",
|
||||||
].join(" ")
|
].join(" ")
|
||||||
: undefined;
|
: undefined;
|
||||||
const reasoningLevel = params.reasoningLevel ?? "off";
|
const reasoningLevel = params.reasoningLevel ?? "off";
|
||||||
const userTimezone = params.userTimezone?.trim();
|
const userTimezone = params.userTimezone?.trim();
|
||||||
@ -336,21 +336,21 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
toolLines.length > 0
|
toolLines.length > 0
|
||||||
? toolLines.join("\n")
|
? toolLines.join("\n")
|
||||||
: [
|
: [
|
||||||
"Pi lists the standard tools above. This runtime enables:",
|
"Pi lists the standard tools above. This runtime enables:",
|
||||||
"- grep: search file contents for patterns",
|
"- grep: search file contents for patterns",
|
||||||
"- find: find files by glob pattern",
|
"- find: find files by glob pattern",
|
||||||
"- ls: list directory contents",
|
"- ls: list directory contents",
|
||||||
"- apply_patch: apply multi-file patches",
|
"- apply_patch: apply multi-file patches",
|
||||||
`- ${execToolName}: run shell commands (supports background via yieldMs/background)`,
|
`- ${execToolName}: run shell commands (supports background via yieldMs/background)`,
|
||||||
`- ${processToolName}: manage background exec sessions`,
|
`- ${processToolName}: manage background exec sessions`,
|
||||||
"- browser: control clawd's dedicated browser",
|
"- browser: control clawd's dedicated browser",
|
||||||
"- canvas: present/eval/snapshot the Canvas",
|
"- canvas: present/eval/snapshot the Canvas",
|
||||||
"- nodes: list/describe/notify/camera/screen on paired nodes",
|
"- nodes: list/describe/notify/camera/screen on paired nodes",
|
||||||
"- cron: manage cron jobs and wake events (use for reminders; when scheduling a reminder, write the systemEvent text as something that will read like a reminder when it fires, and mention that it is a reminder depending on the time gap between setting and firing; include recent context in reminder text if appropriate)",
|
"- cron: manage cron jobs and wake events (use for reminders; when scheduling a reminder, write the systemEvent text as something that will read like a reminder when it fires, and mention that it is a reminder depending on the time gap between setting and firing; include recent context in reminder text if appropriate)",
|
||||||
"- sessions_list: list sessions",
|
"- sessions_list: list sessions",
|
||||||
"- sessions_history: fetch session history",
|
"- sessions_history: fetch session history",
|
||||||
"- sessions_send: send to another session",
|
"- sessions_send: send to another session",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"TOOLS.md does not control tool availability; it is user guidance for how to use external tools.",
|
"TOOLS.md does not control tool availability; it is user guidance for how to use external tools.",
|
||||||
"If a task is more complex or takes longer, spawn a sub-agent. It will do the work for you and ping you when it's done. You can always check up on it.",
|
"If a task is more complex or takes longer, spawn a sub-agent. It will do the work for you and ping you when it's done. You can always check up on it.",
|
||||||
"",
|
"",
|
||||||
@ -375,11 +375,11 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
hasGateway && !isMinimal ? "## Moltbot Self-Update" : "",
|
hasGateway && !isMinimal ? "## Moltbot Self-Update" : "",
|
||||||
hasGateway && !isMinimal
|
hasGateway && !isMinimal
|
||||||
? [
|
? [
|
||||||
"Get Updates (self-update) is ONLY allowed when the user explicitly asks for it.",
|
"Get Updates (self-update) is ONLY allowed when the user explicitly asks for it.",
|
||||||
"Do not run config.apply or update.run unless the user explicitly requests an update or config change; if it's not explicit, ask first.",
|
"Do not run config.apply or update.run unless the user explicitly requests an update or config change; if it's not explicit, ask first.",
|
||||||
"Actions: config.get, config.schema, config.apply (validate + write full config, then restart), update.run (update deps or git, then restart).",
|
"Actions: config.get, config.schema, config.apply (validate + write full config, then restart), update.run (update deps or git, then restart).",
|
||||||
"After restart, Moltbot pings the last active session automatically.",
|
"After restart, Moltbot pings the last active session automatically.",
|
||||||
].join("\n")
|
].join("\n")
|
||||||
: "",
|
: "",
|
||||||
hasGateway && !isMinimal ? "" : "",
|
hasGateway && !isMinimal ? "" : "",
|
||||||
"",
|
"",
|
||||||
@ -396,61 +396,57 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
params.modelAliasLines && params.modelAliasLines.length > 0 && !isMinimal ? "" : "",
|
params.modelAliasLines && params.modelAliasLines.length > 0 && !isMinimal ? "" : "",
|
||||||
"## Workspace",
|
"## Workspace",
|
||||||
`Your working directory is: ${params.workspaceDir}`,
|
`Your working directory is: ${params.workspaceDir}`,
|
||||||
"Treat this directory as the single global workspace for file operations unless explicitly instructed otherwise.",
|
...(runtimeInfo?.os?.toLowerCase()?.includes("windows")
|
||||||
...workspaceNotes,
|
|
||||||
"",
|
|
||||||
...(runtimeInfo?.os?.toLowerCase().includes("windows")
|
|
||||||
? [
|
? [
|
||||||
"## Windows Shell Guidance",
|
"## Windows Shell Guidance",
|
||||||
"You are running on Windows (PowerShell).",
|
"You are running on Windows (PowerShell).",
|
||||||
"- Use PowerShell syntax (e.g. `$env:VAR` instead of `%VAR%` or `$VAR`).",
|
"- Use PowerShell syntax (e.g. `$env:VAR` instead of `%VAR%` or `$VAR`).",
|
||||||
"- Do NOT use Unix commands like `grep`, `sed`, `awk`, `head`, `tail` in exec/shell (PowerShell) commands unless you are sure they are installed. Pi's built-in tools named `grep`, `find`, and `ls` are safe to use.",
|
"- Do NOT use Unix commands like `grep`, `sed`, `awk`, `head`, `tail` in exec/shell (PowerShell) commands unless you are sure they are installed. Pi's built-in tools named `grep`, `find`, and `ls` are safe to use.",
|
||||||
"- Use `findstr` or `Select-String` instead of `grep`.",
|
"- Use `findstr` or `Select-String` instead of `grep`.",
|
||||||
"- Use `Get-ChildItem` (dir/ls) with `-Recurse` instead of `find`.",
|
"- Use `Get-ChildItem` (dir/ls) with `-Recurse` instead of `find`.",
|
||||||
"",
|
"",
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...docsSection,
|
...docsSection,
|
||||||
params.sandboxInfo?.enabled ? "## Sandbox" : "",
|
params.sandboxInfo?.enabled ? "## Sandbox" : "",
|
||||||
params.sandboxInfo?.enabled
|
params.sandboxInfo?.enabled
|
||||||
? [
|
? [
|
||||||
"You are running in a sandboxed runtime (tools execute in Docker).",
|
"You are running in a sandboxed runtime (tools execute in Docker).",
|
||||||
"Some tools may be unavailable due to sandbox policy.",
|
"Some tools may be unavailable due to sandbox policy.",
|
||||||
"Sub-agents stay sandboxed (no elevated/host access). Need outside-sandbox read/write? Don't spawn; ask first.",
|
"Sub-agents stay sandboxed (no elevated/host access). Need outside-sandbox read/write? Don't spawn; ask first.",
|
||||||
params.sandboxInfo.workspaceDir
|
params.sandboxInfo.workspaceDir
|
||||||
? `Sandbox workspace: ${params.sandboxInfo.workspaceDir}`
|
? `Sandbox workspace: ${params.sandboxInfo.workspaceDir}`
|
||||||
|
: "",
|
||||||
|
params.sandboxInfo.workspaceAccess
|
||||||
|
? `Agent workspace access: ${params.sandboxInfo.workspaceAccess}${params.sandboxInfo.agentWorkspaceMount
|
||||||
|
? ` (mounted at ${params.sandboxInfo.agentWorkspaceMount})`
|
||||||
|
: ""
|
||||||
|
}`
|
||||||
|
: "",
|
||||||
|
params.sandboxInfo.browserBridgeUrl ? "Sandbox browser: enabled." : "",
|
||||||
|
params.sandboxInfo.browserNoVncUrl
|
||||||
|
? `Sandbox browser observer (noVNC): ${params.sandboxInfo.browserNoVncUrl}`
|
||||||
|
: "",
|
||||||
|
params.sandboxInfo.hostBrowserAllowed === true
|
||||||
|
? "Host browser control: allowed."
|
||||||
|
: params.sandboxInfo.hostBrowserAllowed === false
|
||||||
|
? "Host browser control: blocked."
|
||||||
: "",
|
: "",
|
||||||
params.sandboxInfo.workspaceAccess
|
params.sandboxInfo.elevated?.allowed
|
||||||
? `Agent workspace access: ${params.sandboxInfo.workspaceAccess}${
|
? "Elevated exec is available for this session."
|
||||||
params.sandboxInfo.agentWorkspaceMount
|
: "",
|
||||||
? ` (mounted at ${params.sandboxInfo.agentWorkspaceMount})`
|
params.sandboxInfo.elevated?.allowed
|
||||||
: ""
|
? "User can toggle with /elevated on|off|ask|full."
|
||||||
}`
|
: "",
|
||||||
: "",
|
params.sandboxInfo.elevated?.allowed
|
||||||
params.sandboxInfo.browserBridgeUrl ? "Sandbox browser: enabled." : "",
|
? "You may also send /elevated on|off|ask|full when needed."
|
||||||
params.sandboxInfo.browserNoVncUrl
|
: "",
|
||||||
? `Sandbox browser observer (noVNC): ${params.sandboxInfo.browserNoVncUrl}`
|
params.sandboxInfo.elevated?.allowed
|
||||||
: "",
|
? `Current elevated level: ${params.sandboxInfo.elevated.defaultLevel} (ask runs exec on host with approvals; full auto-approves).`
|
||||||
params.sandboxInfo.hostBrowserAllowed === true
|
: "",
|
||||||
? "Host browser control: allowed."
|
]
|
||||||
: params.sandboxInfo.hostBrowserAllowed === false
|
.filter(Boolean)
|
||||||
? "Host browser control: blocked."
|
.join("\n")
|
||||||
: "",
|
|
||||||
params.sandboxInfo.elevated?.allowed
|
|
||||||
? "Elevated exec is available for this session."
|
|
||||||
: "",
|
|
||||||
params.sandboxInfo.elevated?.allowed
|
|
||||||
? "User can toggle with /elevated on|off|ask|full."
|
|
||||||
: "",
|
|
||||||
params.sandboxInfo.elevated?.allowed
|
|
||||||
? "You may also send /elevated on|off|ask|full when needed."
|
|
||||||
: "",
|
|
||||||
params.sandboxInfo.elevated?.allowed
|
|
||||||
? `Current elevated level: ${params.sandboxInfo.elevated.defaultLevel} (ask runs exec on host with approvals; full auto-approves).`
|
|
||||||
: "",
|
|
||||||
]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join("\n")
|
|
||||||
: "",
|
: "",
|
||||||
params.sandboxInfo?.enabled ? "" : "",
|
params.sandboxInfo?.enabled ? "" : "",
|
||||||
...buildUserIdentitySection(ownerLine, isMinimal),
|
...buildUserIdentitySection(ownerLine, isMinimal),
|
||||||
@ -483,22 +479,22 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
const guidanceText =
|
const guidanceText =
|
||||||
level === "minimal"
|
level === "minimal"
|
||||||
? [
|
? [
|
||||||
`Reactions are enabled for ${channel} in MINIMAL mode.`,
|
`Reactions are enabled for ${channel} in MINIMAL mode.`,
|
||||||
"React ONLY when truly relevant:",
|
"React ONLY when truly relevant:",
|
||||||
"- Acknowledge important user requests or confirmations",
|
"- Acknowledge important user requests or confirmations",
|
||||||
"- Express genuine sentiment (humor, appreciation) sparingly",
|
"- Express genuine sentiment (humor, appreciation) sparingly",
|
||||||
"- Avoid reacting to routine messages or your own replies",
|
"- Avoid reacting to routine messages or your own replies",
|
||||||
"Guideline: at most 1 reaction per 5-10 exchanges.",
|
"Guideline: at most 1 reaction per 5-10 exchanges.",
|
||||||
].join("\n")
|
].join("\n")
|
||||||
: [
|
: [
|
||||||
`Reactions are enabled for ${channel} in EXTENSIVE mode.`,
|
`Reactions are enabled for ${channel} in EXTENSIVE mode.`,
|
||||||
"Feel free to react liberally:",
|
"Feel free to react liberally:",
|
||||||
"- Acknowledge messages with appropriate emojis",
|
"- Acknowledge messages with appropriate emojis",
|
||||||
"- Express sentiment and personality through reactions",
|
"- Express sentiment and personality through reactions",
|
||||||
"- React to interesting content, humor, or notable events",
|
"- React to interesting content, humor, or notable events",
|
||||||
"- Use reactions to confirm understanding or agreement",
|
"- Use reactions to confirm understanding or agreement",
|
||||||
"Guideline: react whenever it feels natural.",
|
"Guideline: react whenever it feels natural.",
|
||||||
].join("\n");
|
].join("\n");
|
||||||
lines.push("## Reactions", guidanceText, "");
|
lines.push("## Reactions", guidanceText, "");
|
||||||
}
|
}
|
||||||
if (reasoningHint) {
|
if (reasoningHint) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user