feat(runtime): enforce native tool calls and web-only stack scripts

Apply a global native tool_calls-only prompt rule to prevent DSML/textual protocol outputs, and expand start_web/stop_web to manage gateway, sidecars, and wiki worker without launching desktop.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-10 20:08:03 +08:00
parent 4335040a27
commit 2c7b318561
4 changed files with 100 additions and 7 deletions

View file

@ -2,9 +2,55 @@ param(
[string]$BindHost = "127.0.0.1",
[int]$Port = 8787,
[switch]$SkipInstall = $false,
[switch]$Background = $false
[bool]$Background = $true,
[switch]$WithoutWeixin = $false,
[switch]$WithoutWhatsApp = $false,
[bool]$WithWikiWorker = $true,
[string]$WeixinChannelId = "oclaw-weixin",
[string]$WeixinGatewayBaseUrl = "",
[string]$WhatsAppChannelId = "whatsapp"
)
# 网页端(/admin、/chat)由网关进程提供,这里只是一个语义化别名。
& "$PSScriptRoot/start_gateway.ps1" -BindHost $BindHost -Port $Port -SkipInstall:$SkipInstall -Background:$Background
function Write-Step([string]$msg) {
Write-Host "==> $msg" -ForegroundColor Cyan
}
function Warn([string]$msg) {
Write-Host "[WARN] $msg" -ForegroundColor Yellow
}
Write-Step "Starting web stack (gateway + sidecars; desktop excluded)"
& "$PSScriptRoot/start_gateway.ps1" -BindHost $BindHost -Port $Port -SkipInstall:$SkipInstall -Background:$Background -WithWikiWorker:$WithWikiWorker
if (-not $Background) {
Write-Host ""
Write-Host "[INFO] Gateway is running in foreground; sidecars were not started in this mode." -ForegroundColor Yellow
Write-Host " Run start_web.ps1 with -Background:`$true for one-command full web startup." -ForegroundColor Yellow
exit 0
}
if (-not $WithoutWeixin) {
$gwBase = ($WeixinGatewayBaseUrl | ForEach-Object { "$_".Trim() })
if (-not $gwBase) {
$gwBase = "http://$BindHost`:$Port"
}
Write-Step "Starting weixin sidecar"
try {
& "$PSScriptRoot/weixin_start.ps1" -ChannelId $WeixinChannelId -GatewayBaseUrl $gwBase
} catch {
Warn "weixin sidecar skipped: $($_.Exception.Message)"
}
}
if (-not $WithoutWhatsApp) {
$waBase = "http://$BindHost`:$Port"
Write-Step "Starting whatsapp sidecar"
try {
& "$PSScriptRoot/whatsapp_start.ps1" -ChannelId $WhatsAppChannelId -GatewayBaseUrl $waBase
} catch {
Warn "whatsapp sidecar skipped: $($_.Exception.Message)"
}
}
Write-Host ""
Write-Host "Web stack started." -ForegroundColor Green

View file

@ -1,8 +1,52 @@
param(
[int]$Port = 8787,
[switch]$Force = $false
[switch]$Force = $false,
[switch]$WithoutWeixin = $false,
[switch]$WithoutWhatsApp = $false,
[bool]$WithWikiWorker = $true,
[string]$WeixinChannelId = "oclaw-weixin",
[string]$WhatsAppChannelId = "whatsapp"
)
# 网页端(/admin、/chat)由网关进程提供,这里只是一个语义化别名。
& "$PSScriptRoot/stop_gateway.ps1" -Port $Port -Force:$Force
function Write-Step([string]$msg) {
Write-Host "==> $msg" -ForegroundColor Cyan
}
Write-Step "Stopping web stack (gateway + sidecars; desktop excluded)"
if (-not $WithoutWeixin) {
Write-Step "Stopping weixin sidecar"
try {
& "$PSScriptRoot/weixin_stop.ps1" -ChannelId $WeixinChannelId -Force:$Force
} catch {
if (-not $Force) { throw }
}
}
if (-not $WithoutWhatsApp) {
Write-Step "Stopping whatsapp sidecar"
try {
& "$PSScriptRoot/whatsapp_stop.ps1" -ChannelId $WhatsAppChannelId -Force:$Force
} catch {
if (-not $Force) { throw }
}
}
Write-Step "Stopping gateway/web"
try {
& "$PSScriptRoot/stop_gateway.ps1" -Port $Port -Force:$Force
} catch {
if (-not $Force) { throw }
}
if ($WithWikiWorker) {
Write-Step "Stopping wiki worker"
try {
& "$PSScriptRoot/stop_wiki_worker.ps1" -Force:$Force
} catch {
if (-not $Force) { throw }
}
}
Write-Host ""
Write-Host "Web stack stopped." -ForegroundColor Green

View file

@ -98,6 +98,7 @@ def _executor_prompt_settings_signature(store: Any) -> tuple[str, ...]:
def _unified_skill_policy_guidance() -> str:
# Global policy for all agents (including dynamic/ephemeral) — appended to base_system in build_executor_system_prompt.
return (
"## 技能使用政策(Skill Usage Policy):\n"
"- 如果用户问你有哪些技能(skill/技能),请直接根据已注入的技能目录及其 description 回答。\n"
"- 不要为了“列出技能”而去读取 SKILL.md。只有在你确实需要某个技能的详细使用说明时,才读取对应 SKILL.md。\n"
"- 当你需要技能细节时,请按目录中给出的 path 读取对应的 SKILL.md。\n"
@ -113,6 +114,8 @@ def _unified_skill_policy_guidance() -> str:
"- 如果脚本依赖相对路径(例如 `.learnings/`),请将工作目录设置为用户工作区。\n"
"- 在没有显式工具调用成功结果前,不要假设脚本已经执行。\n"
"- 在 Windows 上,`.sh` 可能需要 Git Bash、WSL 或等效环境。\n"
"- 工具调用必须通过模型的原生 `tool_calls` 协议返回;不要在正文输出 DSML/XML/工具协议 JSON 模板。\n"
"- 若当前模型链路不支持原生 `tool_calls`,请用自然语言明确说明“当前无法发起工具调用”,并请求切换到支持该协议的链路;不要伪造或模拟工具调用。\n"
"- 当用户目标是“安装 skill/技能”时,必须遵循 `oclaw-skill-manager` 的安装策略,并以其为唯一规范来源。\n"
"- 安装路径强约束:仅允许 `skill_auto_install`(`_workspace` lane);不得改用任何非 auto 路径或脚本绕过。\n"
"- 严禁臆测前置条件:不要把未在规范中声明的环境变量、端口、服务启动状态当作必需前提。\n"

View file

@ -7,7 +7,7 @@
## 执行规则:
1. 涉及外部数据/执行动作时,必须优先调用可用工具,不允许猜测式回答。
2. 若回答声明“已读取/已检查/已执行”,必须有对应工具证据。
3. 若模型接口不支持原生 tool_calls 闭环,不要继续原生 tool_calls;改为纯文本或纯 JSON 意图。
3. 若模型接口不支持原生 tool_calls 闭环,不要在正文输出 DSML/XML/工具协议 JSON 模板;改为自然语言说明“当前无法发起工具调用”并请求切换到支持原生 tool_calls 的链路。
4. 目录列举/文件读取优先低风险工具;高风险执行工具需用户明确要求。
5. 工具调用由平台协议承载,不要在正文里输出工具协议 JSON。