惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
博客园_首页
博客园 - 【当耐特】
V
Visual Studio Blog
博客园 - 叶小钗
月光博客
月光博客
美团技术团队
J
Java Code Geeks
小众软件
小众软件
Y
Y Combinator Blog
博客园 - Franky
Martin Fowler
Martin Fowler
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
docs: document cli runner execution helpers · openclaw/op...
steipete · 2026-06-04 · via Recent Commits to openclaw:main

@@ -1,3 +1,7 @@

1+

/**

2+

* Shared helpers for CLI runner prompts, args, queueing, sessions, and image

3+

* payload preparation.

4+

*/

15

import crypto from "node:crypto";

26

import fs from "node:fs/promises";

37

import os from "node:os";

@@ -31,6 +35,7 @@ import { buildSystemPromptParams } from "../system-prompt-params.js";

3135

import type { SilentReplyPromptMode } from "../system-prompt.types.js";

3236

import { sanitizeImageBlocks } from "../tool-images.js";

3337

import { formatTomlConfigOverride } from "./toml-inline.js";

38+

/** Re-export CLI reliability helpers used by older runner call sites. */

3439

export { buildCliSupervisorScopeKey, resolveCliNoOutputTimeoutMs } from "./reliability.js";

35403641

const CLI_RUN_QUEUE = new KeyedAsyncQueue();

@@ -39,10 +44,12 @@ function isClaudeCliProvider(providerId: string): boolean {

3944

return normalizeOptionalLowercaseString(providerId) === "claude-cli";

4045

}

414647+

/** Enqueues a CLI run under a backend/session key to prevent unsafe overlap. */

4248

export function enqueueCliRun<T>(key: string, task: () => Promise<T>): Promise<T> {

4349

return CLI_RUN_QUEUE.enqueue(key, task);

4450

}

455152+

/** Resolves the serialization key for a CLI backend run. */

4653

export function resolveCliRunQueueKey(params: {

4754

backendId: string;

4855

serialize?: boolean;

@@ -66,6 +73,7 @@ export function resolveCliRunQueueKey(params: {

6673

return params.backendId;

6774

}

687576+

/** Builds the system prompt sent to a CLI-backed agent runtime. */

6977

export function buildCliAgentSystemPrompt(params: {

7078

workspaceDir: string;

7179

cwd?: string;

@@ -133,8 +141,10 @@ export function buildCliAgentSystemPrompt(params: {

133141

});

134142

}

135143144+

/** Back-compat alias for the CLI system prompt builder. */

136145

export const buildSystemPrompt = buildCliAgentSystemPrompt;

137146147+

/** Applies backend model aliases to a requested CLI model id. */

138148

export function normalizeCliModel(modelId: string, backend: CliBackendConfig): string {

139149

const trimmed = modelId.trim();

140150

if (!trimmed) {

@@ -152,6 +162,7 @@ export function normalizeCliModel(modelId: string, backend: CliBackendConfig): s

152162

return trimmed;

153163

}

154164165+

/** Decides whether a system prompt should be sent for this CLI turn. */

155166

export function resolveSystemPromptUsage(params: {

156167

backend: CliBackendConfig;

157168

isNewSession: boolean;

@@ -178,6 +189,7 @@ export function resolveSystemPromptUsage(params: {

178189

return systemPrompt;

179190

}

180191192+

/** Resolves the CLI session id to send and whether the turn starts a new session. */

181193

export function resolveSessionIdToSend(params: {

182194

backend: CliBackendConfig;

183195

cliSessionId?: string;

@@ -196,6 +208,7 @@ export function resolveSessionIdToSend(params: {

196208

return { sessionId: crypto.randomUUID(), isNew: true };

197209

}

198210211+

/** Routes prompt text to argv or stdin based on backend input policy. */

199212

export function resolvePromptInput(params: { backend: CliBackendConfig; prompt: string }): {

200213

argsPrompt?: string;

201214

stdin?: string;

@@ -237,6 +250,7 @@ function appendImagePathsToPrompt(prompt: string, paths: string[], prefix = ""):

237250

return `${trimmed}${separator}${paths.map((entry) => `${prefix}${entry}`).join("\n")}`;

238251

}

239252253+

/** Loads and sanitizes image references found in prompt text. */

240254

export async function loadPromptRefImages(params: {

241255

prompt: string;

242256

workspaceDir: string;

@@ -274,6 +288,7 @@ export async function loadPromptRefImages(params: {

274288

return sanitizedImages;

275289

}

276290291+

/** Writes CLI image payloads to private paths and returns their file paths. */

277292

export async function writeCliImages(params: {

278293

backend: CliBackendConfig;

279294

workspaceDir: string;

@@ -298,6 +313,7 @@ export async function writeCliImages(params: {

298313

return { paths, cleanup };

299314

}

300315316+

/** Writes a temporary system prompt file when the backend needs file-based prompts. */

301317

export async function writeCliSystemPromptFile(params: {

302318

backend: CliBackendConfig;

303319

systemPrompt: string;

@@ -322,6 +338,7 @@ export async function writeCliSystemPromptFile(params: {

322338

};

323339

}

324340341+

/** Prepares prompt text and image paths for a CLI backend run. */

325342

export async function prepareCliPromptImagePayload(params: {

326343

backend: CliBackendConfig;

327344

prompt: string;

@@ -364,6 +381,7 @@ export async function prepareCliPromptImagePayload(params: {

364381

};

365382

}

366383384+

/** Builds final CLI argv from backend config and prepared prompt/session inputs. */

367385

export function buildCliArgs(params: {

368386

backend: CliBackendConfig;

369387

baseArgs: string[];