Merge branch 'main' into meow/fix-gateway-systemd-install-runtime

This commit is contained in:
Val Alexander
2026-05-04 01:43:05 -05:00
committed by GitHub
76 changed files with 2093 additions and 340 deletions

View File

@@ -72,6 +72,9 @@ Use this skill for Parallels guest workflows and smoke interpretation. Do not lo
- For full beta validation after a tag is published, prefer one command:
- `timeout --foreground 150m pnpm test:parallels:npm-update -- --beta-validation beta3 --json`
This resolves `beta3` to the latest `*-beta.3` version, runs latest->that-version same-guest update coverage, and then runs fresh install smoke for that exact published target on the same selected OS matrix. Use `--platform macos|windows|linux` to narrow reruns.
- For beta 4 npm validation with agent turns, the known-good shape is:
- `gtimeout --foreground 150m pnpm test:parallels:npm-update -- --beta-validation beta4 --model openai/gpt-5.4 --json`
Prefer the explicit `beta4` alias over `openclaw@beta` when validating a specific prerelease number; npm tags can move.
- If the wrapper fails a lane, read the auto-dumped tail first, then the full nested lane log under `.artifacts/parallels/openclaw-parallels-npm-update.*`.
- Current known macOS update-lane transport signature when the fallback is missing or bypassed: `Unable to authenticate the user. Make sure that the specified credentials are correct and try again.` Treat that as Parallels current-user authentication before blaming npm or OpenClaw.
- A macOS packaged fresh install with global package directories or bundled files mode `0777` usually means the harness used the root `prlctl exec` fallback under a permissive umask. The POSIX guest transports should prepend `umask 022`; verify the phase preflight line before blaming npm.

View File

@@ -139,6 +139,20 @@ pnpm test:docker:npm-telegram-live
- `OPENCLAW_QA_CONVEX_SITE_URL`
- `OPENCLAW_QA_CONVEX_SECRET_MAINTAINER`
- `OPENCLAW_NPM_TELEGRAM_PROVIDER_MODE=mock-openai`
- If direct Telegram env is missing locally and `op signin` blocks, prefer dispatching the manual GitHub lane because the `qa-live-shared` environment already has Convex CI credentials:
```bash
gh workflow run "NPM Telegram Beta E2E" --repo openclaw/openclaw --ref main \
-f package_spec=openclaw@YYYY.M.D-beta.N \
-f package_label=openclaw@YYYY.M.D-beta.N \
-f provider_mode=mock-openai
```
- Poll the exact run id from the dispatch URL. `gh run view --json artifacts` is not supported; list artifacts with:
```bash
gh api repos/openclaw/openclaw/actions/runs/<run-id>/artifacts
```
## Character evals

View File

@@ -220,6 +220,23 @@ jobs:
echo "output_dir=${output_dir}" >> "$GITHUB_OUTPUT"
export OPENCLAW_NPM_TELEGRAM_OUTPUT_DIR="${output_dir}"
append_telegram_summary() {
local status=$?
local report="${output_dir}/telegram-qa-report.md"
if [[ -n "${GITHUB_STEP_SUMMARY:-}" && -f "${report}" ]]; then
{
echo "## Package Telegram E2E"
echo
echo "- Package: ${OPENCLAW_NPM_TELEGRAM_PACKAGE_LABEL:-${OPENCLAW_NPM_TELEGRAM_PACKAGE_SPEC}}"
echo "- Provider mode: ${OPENCLAW_NPM_TELEGRAM_PROVIDER_MODE}"
echo
cat "${report}"
} >> "${GITHUB_STEP_SUMMARY}"
fi
return "${status}"
}
trap append_telegram_summary EXIT
if [[ -n "${PACKAGE_ARTIFACT_NAME// }" ]]; then
mapfile -t package_tgzs < <(find .artifacts/telegram-package-under-test -type f -name "*.tgz" | sort)
if [[ "${#package_tgzs[@]}" -ne 1 ]]; then

View File

@@ -11,7 +11,7 @@ Docs: https://docs.openclaw.ai
### Changes
- Gateway/startup: keep model-catalog test helpers and run-session lookup code out of the hot `server.impl` import graph, reducing default gateway benchmark readiness latency.
- Gateway/startup: keep model-catalog test helpers, run-session lookup code, QR pairing helpers, and TypeBox memory-tool schema construction out of hot startup import paths, reducing default gateway benchmark plugin-load and memory pressure.
- Channels/streaming: add unified `streaming.mode: "progress"` drafts with auto single-word status labels and shared progress configuration across Discord, Telegram, Matrix, Slack, and Microsoft Teams.
- Slack/streaming: add `streaming.progress.render: "rich"` for Block Kit progress drafts backed by structured progress line data.
- Slack/streaming: keep the newest rich progress lines when Block Kit limits trim long progress drafts. Thanks @vincentkoc.
@@ -56,10 +56,15 @@ Docs: https://docs.openclaw.ai
### Fixes
- Release/beta smoke: resolve the dispatched Telegram beta E2E run from `gh run list` when `gh workflow run` returns no run URL, so the maintainer helper does not fail immediately after dispatch. Thanks @vincentkoc.
- Media/images: keep HEIC/HEIF attachments fail-closed when optional Sharp conversion is unavailable instead of sending originals that still need conversion. Thanks @vincentkoc.
- Google Meet: fork the caller's current agent transcript into agent-mode meeting consultant sessions, so Meet replies inherit the context from the tool call that joined the meeting.
- Telegram/streaming: sanitize tool-progress draft preview backticks before shared compaction, so long backtick-heavy progress text still renders inside the safe code-formatted preview instead of collapsing to an ellipsis.
- UI/chat: remove the unsupported `line-clamp` declaration from the chat queue text rule to eliminate Firefox console noise without changing visible truncation behavior. Thanks @ZanderH-code.
- Agents/Pi: suppress persistence for synthetic mid-turn overflow continuation prompts, so transcript-retry recovery does not write the "continue from transcript" prompt as a new user turn. Thanks @vincentkoc.
- Agents/tools: strip reasoning text from visible rich presentation titles, blocks, buttons, and select labels before message-tool sends, so structured channel payloads cannot leak hidden planning. Thanks @vincentkoc.
- Telegram: keep reply-dispatch lazy provider runtime chunks behind stable dist names and delete `/reasoning stream` previews after final delivery so package updates and live reasoning drafts do not leave Telegram turns broken or noisy. Thanks @BunsDev.
- Discord: start the gateway monitor without waiting for the startup bot/application probe, so WSL2 hosts with a slow `/users/@me` REST path still bring the channel online while status enrichment finishes asynchronously. Fixes #77103. Thanks @Suited78.
- Exec approvals: detect `env -S` split-string command-carrier risks when `-S`/`-s` is combined with other env short options, so approval explanations do not miss split payloads hidden behind `env -iS...`. Thanks @vincentkoc.
- Google Meet: log the concrete agent-mode TTS provider, model, voice, output format, and sample rate after speech synthesis, so Meet logs show which voice backend spoke each reply.
- Voice Call: mark realtime calls completed when the realtime provider closes normally, so Twilio/OpenAI/Google realtime stop events do not leave active call records behind. Thanks @vincentkoc.
@@ -88,6 +93,9 @@ Docs: https://docs.openclaw.ai
- Media: treat `EPERM` from the post-write media fsync step as best-effort, allowing WebChat and channel uploads to finish on Windows filesystems that reject `fsync` after a successful write. Fixes #76844.
- Media/Telegram: send in-limit original images when optional image optimization is unavailable, so Telegram MEDIA replies and message-tool image sends do not fail just because `sharp` is missing. Fixes #77081. (#77117) Thanks @pfrederiksen.
- Diagnostics: include last progress, cron job/run ids, stopped cron job name, and the last assistant transcript snippet in stalled-session and stuck-session recovery logs so cron stalls show what was stopped.
- Streaming channels: add `streaming.preview.commandText: "status"` / `streaming.progress.commandText: "status"` to hide command/exec text in preview progress lines while keeping the released raw command text default. Fixes #77072.
- Agents/cron: let explicit cron `timeoutSeconds` drive both CLI no-output and embedded LLM idle watchdogs instead of being capped by resume defaults. Fixes #76289.
- Plugins/catalog: suppress missing `channelConfigs` compatibility diagnostics for external channel plugins that are disabled, denied, or outside a restrictive allowlist. Fixes #76095.
- Diagnostics: keep webhook/message OTEL attributes and Prometheus delivery labels low-cardinality and omit raw chat/message IDs from spans, so progress-draft and message-tool modes do not leak high-cardinality messaging identifiers.
- Google Meet: stop advertising legacy `mode: "realtime"` to agents and config UIs, while keeping it as a hidden compatibility alias for `mode: "agent"`, so new joins use the STT -> OpenClaw agent -> TTS path instead of selecting the direct realtime voice fallback.
- Google Meet: add `chrome.audioBufferBytes` for generated command-pair SoX audio commands and lower the default buffer from SoX's 8192 bytes to 4096 bytes to reduce Chrome talk-back latency.

View File

@@ -1,4 +1,4 @@
953aece02c70b8df690b51e865a4aea838b53bbe9d43ef9495f80f719a831e38 config-baseline.json
2c78fb7af01e2ee9e919be5ab7b675347b36cae1e347f97fd2640a6f7c72f3ac config-baseline.json
31ec333df9f8b92c7656ac7107cecd5860dd02e08f7e18c7c674dc47a8811baa config-baseline.core.json
e10ba2f29f25fc665b96c714075af954eed686c56ca12783cf1f49498f86ac98 config-baseline.channel.json
606641569764473005f8343f4550500dcbe99cf54e1dc21960018cf455912196 config-baseline.plugin.json
cd7c0c7fb1435bc7e59099e9ac334462d5ad444016e9ab4512aae63a238f78dc config-baseline.channel.json
9832b30a696930a3da7efccf38073137571e1b66cae84e54d747b733fdafcc54 config-baseline.plugin.json

View File

@@ -685,6 +685,25 @@ Default slash command settings:
- `block` emits draft-sized chunks (use `draftChunk` to tune size and breakpoints, clamped to `textChunkLimit`).
- Media, error, and explicit-reply finals cancel pending preview edits.
- `streaming.preview.toolProgress` (default `true`) controls whether tool/progress updates reuse the preview message.
- `streaming.preview.commandText` / `streaming.progress.commandText` controls command/exec detail in compact progress lines: `raw` (default) or `status` (tool label only).
Hide raw command/exec text while keeping compact progress lines:
```json
{
"channels": {
"discord": {
"streaming": {
"mode": "progress",
"progress": {
"toolProgress": true,
"commandText": "status"
}
}
}
}
}
```
Preview streaming is text-only; media replies fall back to normal delivery. When `block` streaming is explicitly enabled, OpenClaw skips the preview stream to avoid double-streaming.

View File

@@ -666,6 +666,25 @@ Notes:
- `block`: append chunked preview updates.
- `progress`: show progress status text while generating, then send final text.
- `streaming.preview.toolProgress`: when draft preview is active, route tool/progress updates into the same edited preview message (default: `true`). Set `false` to keep separate tool/progress messages.
- `streaming.preview.commandText` / `streaming.progress.commandText`: set to `status` to keep compact tool-progress lines while hiding raw command/exec text (default: `raw`).
Hide raw command/exec text while keeping compact progress lines:
```json
{
"channels": {
"slack": {
"streaming": {
"mode": "progress",
"progress": {
"toolProgress": true,
"commandText": "status"
}
}
}
}
}
```
`channels.slack.streaming.nativeTransport` controls Slack native text streaming when `channels.slack.streaming.mode` is `partial` (default: `true`).

View File

@@ -280,6 +280,7 @@ curl "https://api.telegram.org/bot<bot_token>/getUpdates"
- `channels.telegram.streaming` is `off | partial | block | progress` (default: `partial`)
- `progress` keeps one editable status draft and updates it with tool progress until final delivery
- `streaming.preview.toolProgress` controls whether tool/progress updates reuse the same edited preview message (default: `true` when preview streaming is active)
- `streaming.preview.commandText` controls command/exec detail inside those tool-progress lines: `raw` (default, preserves released behavior) or `status` (tool label only)
- legacy `channels.telegram.streamMode` and boolean `streaming` values are detected; run `openclaw doctor --fix` to migrate them to `channels.telegram.streaming.mode`
Tool-progress preview updates are the short status lines shown while tools run, for example command execution, file reads, planning updates, or patch summaries. Telegram keeps these enabled by default to match released OpenClaw behavior from `v2026.4.22` and later. To keep the edited preview for answer text but hide tool-progress lines, set:
@@ -299,6 +300,41 @@ curl "https://api.telegram.org/bot<bot_token>/getUpdates"
}
```
To keep tool-progress visible but hide command/exec text, set:
```json
{
"channels": {
"telegram": {
"streaming": {
"mode": "partial",
"preview": {
"commandText": "status"
}
}
}
}
}
```
For progress-draft mode, put the same command-text policy under `streaming.progress`:
```json
{
"channels": {
"telegram": {
"streaming": {
"mode": "progress",
"progress": {
"toolProgress": true,
"commandText": "status"
}
}
}
}
}
```
Use `streaming.mode: "off"` only when you want final-only delivery: Telegram preview edits are disabled and generic tool/progress chatter is suppressed instead of being sent as standalone status messages. Approval prompts, media payloads, and errors still route through normal final delivery. Use `streaming.preview.toolProgress: false` when you only want to keep answer preview edits while hiding the tool-progress status lines.
<Note>

View File

@@ -201,10 +201,10 @@ Supported surfaces:
- Telegram has shipped with tool-progress preview updates enabled since `v2026.4.22`; keeping them enabled preserves that released behavior.
- **Mattermost** already folds tool activity into its single draft preview post (see above).
- Tool-progress edits follow the active preview streaming mode; they are skipped when preview streaming is `off` or when block streaming has taken over the message. On Telegram, `streaming.mode: "off"` is final-only: generic progress chatter is also suppressed instead of being delivered as standalone status messages, while approval prompts, media payloads, and errors still route normally.
- To keep preview streaming but hide tool-progress lines, set `streaming.preview.toolProgress` to `false` for that channel. To disable preview edits entirely, set `streaming.mode` to `off`.
- To keep preview streaming but hide tool-progress lines, set `streaming.preview.toolProgress` to `false` for that channel. To keep tool-progress lines visible while hiding command/exec text, set `streaming.preview.commandText` to `"status"` or `streaming.progress.commandText` to `"status"`; the default is `"raw"` to preserve released behavior. This policy is shared by draft/progress channels that use OpenClaw's compact progress renderer, including Discord, Matrix, Microsoft Teams, Mattermost, Slack draft previews, and Telegram. To disable preview edits entirely, set `streaming.mode` to `off`.
- Telegram selected quote replies are an exception: when `replyToMode` is not `"off"` and selected quote text is present, OpenClaw skips the answer preview stream for that turn so tool-progress preview lines cannot render. Current-message replies without selected quote text still keep preview streaming. See [Telegram channel docs](/channels/telegram) for details.
Example:
Keep progress lines visible but hide raw command/exec text:
```json
{
@@ -213,7 +213,26 @@ Example:
"streaming": {
"mode": "partial",
"preview": {
"toolProgress": false
"toolProgress": true,
"commandText": "status"
}
}
}
}
}
```
Use the same shape under another compact progress channel key, for example `channels.discord`, `channels.matrix`, `channels.msteams`, `channels.mattermost`, or Slack draft previews. For progress-draft mode, put the same policy under `streaming.progress`:
```json
{
"channels": {
"telegram": {
"streaming": {
"mode": "progress",
"progress": {
"toolProgress": true,
"commandText": "status"
}
}
}

View File

@@ -195,6 +195,9 @@ inside every shard.
`OPENCLAW_QA_CONVEX_SITE_URL` and the role secret. If
`OPENCLAW_QA_CONVEX_SITE_URL` and a Convex role secret are present in CI,
the Docker wrapper selects Convex automatically.
- The wrapper validates Telegram or Convex credential env on the host before
Docker build/install work. Set `OPENCLAW_NPM_TELEGRAM_SKIP_CREDENTIAL_PREFLIGHT=1`
only when deliberately debugging pre-credential setup.
- `OPENCLAW_NPM_TELEGRAM_CREDENTIAL_ROLE=ci|maintainer` overrides the shared
`OPENCLAW_QA_CREDENTIAL_ROLE` for this lane only.
- GitHub Actions exposes this lane as the manual maintainer workflow

View File

@@ -1707,6 +1707,11 @@ Chrome talk-back modes need `BlackHole 2ch` plus either:
audio path and must exit after starting or validating its daemon. This is only
valid for `bidi` because `agent` mode needs direct command-pair access for TTS.
When an agent calls the `google_meet` tool in agent mode, the meeting consultant
session forks the caller's current transcript before answering participant
speech. The Meet session still stays separate (`agent:<agentId>:subagent:google-meet:<sessionId>`)
so meeting follow-ups do not mutate the caller transcript directly.
For clean duplex audio, route Meet output and Meet microphone through separate
virtual devices or a Loopback-style virtual device graph. A single shared
BlackHole device can echo other participants back into the call.

View File

@@ -211,6 +211,7 @@ Validation` or from the `main`/release workflow ref so workflow logic and
against the published npm package using the shared leased Telegram credential
pool. Local maintainer one-offs may omit the Convex vars and pass the three
`OPENCLAW_QA_TELEGRAM_*` env credentials directly.
- To run the full post-publish beta smoke from a maintainer machine, use `pnpm release:beta-smoke -- --beta betaN`. The helper runs Parallels npm update/fresh-target validation, dispatches `NPM Telegram Beta E2E`, polls the exact workflow run, downloads the artifact, and prints the Telegram report.
- Maintainers can run the same post-publish check from GitHub Actions via the
manual `NPM Telegram Beta E2E` workflow. It is intentionally manual-only and
does not run on every merge.

View File

@@ -1,40 +1,41 @@
import { rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { definePluginEntry, type OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "openclaw/plugin-sdk/text-runtime";
import {
clearDeviceBootstrapTokens,
definePluginEntry,
issueDeviceBootstrapToken,
listDevicePairing,
PAIRING_SETUP_BOOTSTRAP_PROFILE,
renderQrPngDataUrl,
writeQrPngTempFile,
revokeDeviceBootstrapToken,
resolveGatewayBindUrl,
resolveGatewayPort,
resolvePreferredOpenClawTmpDir,
runPluginCommandWithTimeout,
resolveTailnetHostWithRunner,
type OpenClawPluginApi,
} from "./api.js";
import {
armPairNotifyOnce,
formatPendingRequests,
handleNotifyCommand,
registerPairingNotifierService,
} from "./notify.js";
import {
approvePendingPairingRequest,
selectPendingApprovalRequest,
} from "./pair-command-approve.js";
import {
buildMissingPairingScopeReply,
resolvePairingCommandAuthState,
} from "./pair-command-auth.js";
type DevicePairApiModule = typeof import("./api.js");
type NotifyModule = typeof import("./notify.js");
type PairCommandApproveModule = typeof import("./pair-command-approve.js");
type PairCommandAuthModule = typeof import("./pair-command-auth.js");
let devicePairApiModulePromise: Promise<DevicePairApiModule> | undefined;
let notifyModulePromise: Promise<NotifyModule> | undefined;
let pairCommandApproveModulePromise: Promise<PairCommandApproveModule> | undefined;
let pairCommandAuthModulePromise: Promise<PairCommandAuthModule> | undefined;
function loadDevicePairApiModule(): Promise<DevicePairApiModule> {
devicePairApiModulePromise ??= import("./api.js");
return devicePairApiModulePromise;
}
function loadNotifyModule(): Promise<NotifyModule> {
notifyModulePromise ??= import("./notify.js");
return notifyModulePromise;
}
function loadPairCommandApproveModule(): Promise<PairCommandApproveModule> {
pairCommandApproveModulePromise ??= import("./pair-command-approve.js");
return pairCommandApproveModulePromise;
}
function loadPairCommandAuthModule(): Promise<PairCommandAuthModule> {
pairCommandAuthModulePromise ??= import("./pair-command-auth.js");
return pairCommandAuthModulePromise;
}
function formatDurationMinutes(expiresAtMs: number): string {
const msRemaining = Math.max(0, expiresAtMs - Date.now());
@@ -254,6 +255,8 @@ function pickTailnetIPv4(): string | null {
}
async function resolveTailnetHost(): Promise<string | null> {
const { resolveTailnetHostWithRunner, runPluginCommandWithTimeout } =
await loadDevicePairApiModule();
return await resolveTailnetHostWithRunner((argv, opts) =>
runPluginCommandWithTimeout({
argv,
@@ -307,6 +310,7 @@ function resolveRequiredAuthLabel(
}
async function resolveGatewayUrl(api: OpenClawPluginApi): Promise<ResolveUrlResult> {
const { resolveGatewayBindUrl, resolveGatewayPort } = await loadDevicePairApiModule();
const cfg = api.config;
const pluginCfg = (api.pluginConfig ?? {}) as DevicePairPluginConfig;
const scheme = resolveScheme(cfg);
@@ -511,6 +515,8 @@ function issuesPairSetupCode(action: string): boolean {
}
async function issueSetupPayload(url: string): Promise<SetupPayload> {
const { issueDeviceBootstrapToken, PAIRING_SETUP_BOOTSTRAP_PROFILE } =
await loadDevicePairApiModule();
const issuedBootstrap = await issueDeviceBootstrapToken({
profile: PAIRING_SETUP_BOOTSTRAP_PROFILE,
});
@@ -558,7 +564,19 @@ export default definePluginEntry({
name: "Device Pair",
description: "QR/bootstrap pairing helpers for OpenClaw devices",
register(api: OpenClawPluginApi) {
registerPairingNotifierService(api);
let notifierService: ReturnType<NotifyModule["createPairingNotifierService"]> | undefined;
api.registerService({
id: "device-pair-notifier",
start: async (ctx) => {
const { createPairingNotifierService } = await loadNotifyModule();
notifierService = createPairingNotifierService(api);
await notifierService.start(ctx);
},
stop: async (ctx) => {
await notifierService?.stop?.(ctx);
notifierService = undefined;
},
});
api.registerCommand({
name: "pair",
@@ -571,6 +589,8 @@ export default definePluginEntry({
const gatewayClientScopes = Array.isArray(ctx.gatewayClientScopes)
? ctx.gatewayClientScopes
: undefined;
const { buildMissingPairingScopeReply, resolvePairingCommandAuthState } =
await loadPairCommandAuthModule();
const authState = resolvePairingCommandAuthState({
channel: ctx.channel,
gatewayClientScopes,
@@ -582,12 +602,17 @@ export default definePluginEntry({
);
if (action === "status" || action === "pending") {
const [{ listDevicePairing }, { formatPendingRequests }] = await Promise.all([
loadDevicePairApiModule(),
loadNotifyModule(),
]);
const list = await listDevicePairing();
return { text: formatPendingRequests(list.pending) };
}
if (action === "notify") {
const notifyAction = normalizeLowercaseStringOrEmpty(tokens[1]) || "status";
const { handleNotifyCommand } = await loadNotifyModule();
return await handleNotifyCommand({
api,
ctx,
@@ -599,6 +624,10 @@ export default definePluginEntry({
if (authState.isMissingInternalPairingPrivilege) {
return buildMissingPairingScopeReply();
}
const [
{ listDevicePairing },
{ approvePendingPairingRequest, selectPendingApprovalRequest },
] = await Promise.all([loadDevicePairApiModule(), loadPairCommandApproveModule()]);
const list = await listDevicePairing();
const selected = selectPendingApprovalRequest({
pending: list.pending,
@@ -621,6 +650,7 @@ export default definePluginEntry({
if (authState.isMissingInternalPairingPrivilege) {
return buildMissingPairingScopeReply();
}
const { clearDeviceBootstrapTokens } = await loadDevicePairApiModule();
const cleared = await clearDeviceBootstrapTokens();
return {
text:
@@ -651,6 +681,7 @@ export default definePluginEntry({
if (channel === "telegram" && target) {
try {
const { armPairNotifyOnce } = await loadNotifyModule();
autoNotifyArmed = await armPairNotifyOnce({ api, ctx });
} catch (err) {
api.logger.warn?.(
@@ -672,6 +703,8 @@ export default definePluginEntry({
if (target && canSendQrPngToChannel(channel)) {
let qrFilePath: string | undefined;
try {
const { resolvePreferredOpenClawTmpDir, writeQrPngTempFile } =
await loadDevicePairApiModule();
qrFilePath = (
await writeQrPngTempFile(setupCode, {
tmpRoot: resolvePreferredOpenClawTmpDir(),
@@ -697,6 +730,7 @@ export default definePluginEntry({
};
}
} catch (err) {
const { revokeDeviceBootstrapToken } = await loadDevicePairApiModule();
api.logger.warn?.(
`device-pair: QR image send failed channel=${channel}, falling back (${(err as Error)?.message ?? err})`,
);
@@ -716,8 +750,10 @@ export default definePluginEntry({
if (channel === "webchat") {
let qrDataUrl: string;
try {
const { renderQrPngDataUrl } = await loadDevicePairApiModule();
qrDataUrl = await renderQrPngDataUrl(setupCode);
} catch (err) {
const { revokeDeviceBootstrapToken } = await loadDevicePairApiModule();
api.logger.warn?.(
`device-pair: webchat QR render failed, falling back (${(err as Error)?.message ?? err})`,
);

View File

@@ -1,9 +1,10 @@
import { promises as fs } from "node:fs";
import path from "node:path";
import type { OpenClawPluginService } from "openclaw/plugin-sdk/core";
import { listDevicePairing } from "openclaw/plugin-sdk/device-bootstrap";
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
import type { OpenClawPluginApi } from "./api.js";
import { listDevicePairing } from "./api.js";
const NOTIFY_STATE_FILE = "device-pair-notify.json";
const NOTIFY_POLL_INTERVAL_MS = 10_000;
@@ -488,10 +489,10 @@ export async function handleNotifyCommand(params: {
return { text: "Usage: /pair notify on|off|once|status" };
}
export function registerPairingNotifierService(api: OpenClawPluginApi): void {
export function createPairingNotifierService(api: OpenClawPluginApi): OpenClawPluginService {
let notifyInterval: ReturnType<typeof setInterval> | null = null;
api.registerService({
return {
id: "device-pair-notifier",
start: async (ctx) => {
const statePath = resolveNotifyStatePath(ctx.stateDir);
@@ -502,7 +503,6 @@ export function registerPairingNotifierService(api: OpenClawPluginApi): void {
await tick().catch((err) => {
api.logger.warn(`device-pair: initial notify poll failed: ${formatErrorMessage(err)}`);
});
notifyInterval = setInterval(() => {
tick().catch((err) => {
api.logger.warn(`device-pair: notify poll failed: ${formatErrorMessage(err)}`);
@@ -516,5 +516,9 @@ export function registerPairingNotifierService(api: OpenClawPluginApi): void {
notifyInterval = null;
}
},
});
};
}
export function registerPairingNotifierService(api: OpenClawPluginApi): void {
api.registerService(createPairingNotifierService(api));
}

View File

@@ -379,7 +379,7 @@ describe("discordPlugin outbound", () => {
expect(runtimeProbeDiscord).not.toHaveBeenCalled();
});
it("uses direct Discord startup helpers before monitoring", async () => {
it("uses direct Discord startup helpers for async startup enrichment", async () => {
const runtimeProbeDiscord = vi.fn(async () => {
throw new Error("runtime Discord probe should not be used");
});
@@ -407,9 +407,11 @@ describe("discordPlugin outbound", () => {
const cfg = createCfg();
await startDiscordAccount(cfg);
expect(probeDiscordMock).toHaveBeenCalledWith("discord-token", 2500, {
includeApplication: true,
});
await vi.waitFor(() =>
expect(probeDiscordMock).toHaveBeenCalledWith("discord-token", 2500, {
includeApplication: true,
}),
);
expect(monitorDiscordProviderMock).toHaveBeenCalledWith(
expect.objectContaining({
token: "discord-token",
@@ -421,6 +423,98 @@ describe("discordPlugin outbound", () => {
expect(runtimeMonitorDiscordProvider).not.toHaveBeenCalled();
});
it("does not block Discord monitor startup on the startup probe", async () => {
let resolveProbe!: (value: {
ok: true;
bot: { username: string };
application: { intents: { messageContent: "limited" } };
elapsedMs: number;
}) => void;
probeDiscordMock.mockReturnValue(
new Promise((resolve) => {
resolveProbe = resolve;
}),
);
monitorDiscordProviderMock.mockResolvedValue(undefined);
const cfg = createCfg();
const statusPatches: Array<Record<string, unknown>> = [];
const ctx = createStartAccountContext({
account: resolveAccount(cfg),
cfg,
statusPatchSink: (next) => statusPatches.push({ ...next }),
});
await discordPlugin.gateway!.startAccount!(ctx);
expect(monitorDiscordProviderMock).toHaveBeenCalledWith(
expect.objectContaining({
token: "discord-token",
accountId: "default",
}),
);
await vi.waitFor(() =>
expect(probeDiscordMock).toHaveBeenCalledWith("discord-token", 2500, {
includeApplication: true,
}),
);
expect(statusPatches.some((patch) => "bot" in patch || "application" in patch)).toBe(false);
resolveProbe({
ok: true,
bot: { username: "AsyncBob" },
application: { intents: { messageContent: "limited" } },
elapsedMs: 1,
});
await vi.waitFor(() =>
expect(
statusPatches.some(
(patch) =>
(patch.bot as { username?: string } | undefined)?.username === "AsyncBob" &&
Boolean(patch.application),
),
).toBe(true),
);
});
it("clears stale Discord probe metadata when the async startup probe degrades", async () => {
probeDiscordMock.mockResolvedValue({
ok: false,
status: 401,
error: "getMe failed (401)",
elapsedMs: 1,
});
monitorDiscordProviderMock.mockResolvedValue(undefined);
const cfg = createCfg();
const statusPatches: Array<Record<string, unknown>> = [];
const ctx = createStartAccountContext({
account: resolveAccount(cfg),
cfg,
statusPatchSink: (next) => statusPatches.push({ ...next }),
});
ctx.setStatus({
accountId: "default",
bot: { username: "OldBot" },
application: { intents: { messageContent: "enabled" } },
});
await discordPlugin.gateway!.startAccount!(ctx);
await vi.waitFor(() =>
expect(
statusPatches.some(
(patch) =>
"bot" in patch &&
"application" in patch &&
patch.bot === undefined &&
patch.application === undefined,
),
).toBe(true),
);
});
it("stagger starts later accounts in multi-bot setups", async () => {
probeDiscordMock.mockResolvedValue({
ok: true,

View File

@@ -82,6 +82,61 @@ import { parseDiscordTarget } from "./target-parsing.js";
const REQUIRED_DISCORD_PERMISSIONS = ["ViewChannel", "SendMessages"] as const;
const DISCORD_ACCOUNT_STARTUP_STAGGER_MS = 10_000;
function startDiscordStartupProbe(params: {
accountId: string;
token: string;
abortSignal: AbortSignal;
setStatus: (patch: { accountId: string; bot?: unknown; application?: unknown }) => void;
log?: {
warn?: (msg: string) => void;
info?: (msg: string) => void;
debug?: (msg: string) => void;
};
}): void {
void (async () => {
try {
const probe = await (
await loadDiscordProbeRuntime()
).probeDiscord(params.token, 2500, {
includeApplication: true,
});
if (params.abortSignal.aborted) {
return;
}
params.setStatus({
accountId: params.accountId,
bot: probe.bot,
application: probe.application,
});
if (probe.ok) {
const username = probe.bot?.username?.trim();
if (username) {
params.log?.info?.(`[${params.accountId}] Discord bot probe resolved @${username}`);
}
} else if (getDiscordRuntime().logging.shouldLogVerbose()) {
params.log?.debug?.(
`[${params.accountId}] bot probe degraded: ${probe.error ?? `status ${probe.status ?? "unknown"}`}`,
);
}
const messageContent = probe.application?.intents?.messageContent;
if (messageContent === "disabled") {
params.log?.warn?.(
`[${params.accountId}] Discord Message Content Intent is disabled; bot may not respond to channel messages. Enable it in Discord Dev Portal (Bot → Privileged Gateway Intents) or require mentions.`,
);
} else if (messageContent === "limited") {
params.log?.info?.(
`[${params.accountId}] Discord Message Content Intent is limited; bots under 100 servers can use it without verification.`,
);
}
} catch (err) {
if (getDiscordRuntime().logging.shouldLogVerbose()) {
params.log?.debug?.(`[${params.accountId}] bot probe failed: ${String(err)}`);
}
}
})();
}
function shouldTreatDiscordDeliveredTextAsVisible(params: {
kind: "tool" | "block" | "final";
text?: string;
@@ -551,38 +606,14 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount, DiscordProbe>
}
}
const token = account.token.trim();
let discordBotLabel = "";
try {
const probe = await (
await loadDiscordProbeRuntime()
).probeDiscord(token, 2500, {
includeApplication: true,
});
const username = probe.ok ? probe.bot?.username?.trim() : null;
if (username) {
discordBotLabel = ` (@${username})`;
}
ctx.setStatus({
accountId: account.accountId,
bot: probe.bot,
application: probe.application,
});
const messageContent = probe.application?.intents?.messageContent;
if (messageContent === "disabled") {
ctx.log?.warn(
`[${account.accountId}] Discord Message Content Intent is disabled; bot may not respond to channel messages. Enable it in Discord Dev Portal (Bot → Privileged Gateway Intents) or require mentions.`,
);
} else if (messageContent === "limited") {
ctx.log?.info(
`[${account.accountId}] Discord Message Content Intent is limited; bots under 100 servers can use it without verification.`,
);
}
} catch (err) {
if (getDiscordRuntime().logging.shouldLogVerbose()) {
ctx.log?.debug?.(`[${account.accountId}] bot probe failed: ${String(err)}`);
}
}
ctx.log?.info(`[${account.accountId}] starting provider${discordBotLabel}`);
startDiscordStartupProbe({
accountId: account.accountId,
token,
abortSignal: ctx.abortSignal,
setStatus: ctx.setStatus,
log: ctx.log,
});
ctx.log?.info(`[${account.accountId}] starting provider`);
return (await loadDiscordProviderRuntime()).monitorDiscordProvider({
token,
accountId: account.accountId,

View File

@@ -65,6 +65,10 @@ export const discordChannelConfigUiHints = {
label: "Discord Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview message (default: true). Set false to hide interim tool updates while the draft preview stays active.",
},
"streaming.preview.commandText": {
label: "Discord Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.progress.label": {
label: "Discord Progress Label",
help: 'Initial progress draft title. Use "auto" for built-in single-word labels, a custom string, or false to hide the title.',
@@ -81,6 +85,10 @@ export const discordChannelConfigUiHints = {
label: "Discord Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Discord Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"retry.attempts": {
label: "Discord Retry Attempts",
help: "Max retry attempts for outbound Discord API calls (default: 3).",

View File

@@ -1567,6 +1567,37 @@ describe("processDiscordMessage draft streaming", () => {
);
});
it("can hide raw command progress text in Discord progress drafts by config", async () => {
const draftStream = createMockDraftStreamForTest();
dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {
await params?.replyOptions?.onToolStart?.({
name: "exec",
phase: "start",
args: { command: "pnpm test -- --watch=false" },
detailMode: "raw",
});
await params?.replyOptions?.onItemEvent?.({ progressText: "done" });
return createNoQueuedDispatchResult();
});
const ctx = await createAutomaticSourceDeliveryContext({
discordConfig: {
streaming: {
mode: "progress",
progress: {
label: "Shelling",
commandText: "status",
},
},
},
});
await runProcessDiscordMessage(ctx);
expect(draftStream.update).toHaveBeenCalledWith("Shelling\n🛠 Exec\n• done");
});
it("keeps Discord progress lines across assistant boundaries", async () => {
const draftStream = createMockDraftStreamForTest();

View File

@@ -13,6 +13,7 @@ import {
} from "openclaw/plugin-sdk/channel-reply-pipeline";
import {
formatChannelProgressDraftLine,
formatChannelProgressDraftLineForEntry,
resolveChannelStreamingBlockEnabled,
} from "openclaw/plugin-sdk/channel-streaming";
import { recordInboundSession } from "openclaw/plugin-sdk/conversation-runtime";
@@ -669,7 +670,8 @@ export async function processDiscordMessage(
await maybeBindStatusReactionsToToolReaction(payload);
await statusReactions.setTool(payload.name);
await draftPreview.pushToolProgress(
formatChannelProgressDraftLine(
formatChannelProgressDraftLineForEntry(
discordConfig,
{
event: "tool",
name: payload.name,
@@ -683,7 +685,7 @@ export async function processDiscordMessage(
},
onItemEvent: async (payload) => {
await draftPreview.pushToolProgress(
formatChannelProgressDraftLine({
formatChannelProgressDraftLineForEntry(discordConfig, {
event: "item",
itemKind: payload.kind,
title: payload.title,

View File

@@ -1,7 +1,7 @@
import { logTypingFailure } from "openclaw/plugin-sdk/channel-feedback";
import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline";
import {
formatChannelProgressDraftLine,
formatChannelProgressDraftLineForEntry,
isChannelProgressDraftWorkToolName,
} from "openclaw/plugin-sdk/channel-streaming";
import {
@@ -708,7 +708,8 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
if (!isChannelProgressDraftWorkToolName(payload.name)) {
return;
}
const statusLine = formatChannelProgressDraftLine(
const statusLine = formatChannelProgressDraftLineForEntry(
account.config,
{
event: "tool",
name: payload.name,

View File

@@ -1259,6 +1259,32 @@ describe("google-meet plugin", () => {
});
});
it("passes the caller session key through tool joins for agent context forking", async () => {
const { tools } = setup(
{},
{ toolContext: { sessionKey: "agent:main:discord:channel:general" } },
);
const gatewayParams: unknown[] = [];
googleMeetPluginTesting.setCallGatewayFromCliForTests(async (_method, _opts, params) => {
gatewayParams.push(params);
return { ok: true };
});
const tool = tools[0] as {
execute: (id: string, params: unknown) => Promise<unknown>;
};
await tool.execute("id", {
action: "join",
url: "https://meet.google.com/abc-defg-hij",
requesterSessionKey: "agent:main:wrong",
});
expect(gatewayParams[0]).toMatchObject({
url: "https://meet.google.com/abc-defg-hij",
requesterSessionKey: "agent:main:discord:channel:general",
});
});
it("explains that Twilio joins need dial-in details", async () => {
const { tools } = setup({ defaultTransport: "twilio" });
const tool = tools[0] as {

View File

@@ -741,6 +741,7 @@ export default definePluginEntry({
pin: normalizeOptionalString(params?.pin),
dtmfSequence: normalizeOptionalString(params?.dtmfSequence),
message: normalizeOptionalString(params?.message),
requesterSessionKey: normalizeOptionalString(params?.requesterSessionKey),
});
respond(true, result);
} catch (err) {
@@ -992,6 +993,7 @@ export default definePluginEntry({
pin: normalizeOptionalString(params?.pin),
dtmfSequence: normalizeOptionalString(params?.dtmfSequence),
message: normalizeOptionalString(params?.message),
requesterSessionKey: normalizeOptionalString(params?.requesterSessionKey),
});
respond(true, result);
} catch (err) {
@@ -1018,155 +1020,176 @@ export default definePluginEntry({
},
);
api.registerTool({
name: "google_meet",
label: "Google Meet",
description:
"Join and track Google Meet sessions through Chrome or Twilio. Call setup_status before join/create/test_listen/test_speech; if it reports a Chrome node offline, local audio missing, or missing Twilio dial plan, surface that blocker instead of retrying or switching transports. Twilio cannot dial a Meet URL directly: provide dialInNumber plus optional pin/dtmfSequence, or configure twilio.defaultDialInNumber. Offline nodes are diagnostics only, not usable candidates. If local Chrome talk-back audio is unsupported on this OS, use mode=transcribe, transport=twilio, or a macOS chrome-node for agent/bidi Chrome. If a Meet tab is already open after a timeout, call recover_current_tab before retrying join to report login, permission, or admission blockers without opening another tab.",
parameters: GoogleMeetToolSchema,
async execute(_toolCallId, params) {
const raw = asParamRecord(params);
try {
assertGoogleMeetAgentToolActionSupported({ config, raw });
switch (raw.action) {
case "join": {
return json(await callGoogleMeetGatewayFromTool({ config, action: "join", raw }));
}
case "create": {
return json(await callGoogleMeetGatewayFromTool({ config, action: "create", raw }));
}
case "test_speech": {
return json(
await callGoogleMeetGatewayFromTool({ config, action: "test_speech", raw }),
);
}
case "test_listen": {
return json(
await callGoogleMeetGatewayFromTool({ config, action: "test_listen", raw }),
);
}
case "status": {
return json(await callGoogleMeetGatewayFromTool({ config, action: "status", raw }));
}
case "recover_current_tab": {
return json(
await callGoogleMeetGatewayFromTool({
config,
action: "recover_current_tab",
raw,
}),
);
}
case "setup_status": {
return json(
await callGoogleMeetGatewayFromTool({ config, action: "setup_status", raw }),
);
}
case "resolve_space": {
const { token: _token, ...result } = await resolveSpaceFromParams(config, raw);
return json(result);
}
case "preflight": {
const { meeting, token, space } = await resolveSpaceFromParams(config, raw);
return json(
buildGoogleMeetPreflightReport({
input: meeting,
space,
previewAcknowledged: config.preview.enrollmentAcknowledged,
tokenSource: token.refreshed ? "refresh-token" : "cached-access-token",
}),
);
}
case "latest": {
const token = await resolveGoogleMeetTokenFromParams(config, raw);
const resolved = await resolveMeetingFromParams({
config,
raw,
accessToken: token.accessToken,
});
return json({
...(await fetchLatestGoogleMeetConferenceRecord({
accessToken: token.accessToken,
meeting: resolved.meeting,
})),
...(resolved.calendarEvent ? { calendarEvent: resolved.calendarEvent } : {}),
});
}
case "calendar_events": {
const token = await resolveGoogleMeetTokenFromParams(config, raw);
const window = raw.today === true ? buildGoogleMeetCalendarDayWindow() : {};
return json(
await listGoogleMeetCalendarEvents({
accessToken: token.accessToken,
calendarId: normalizeOptionalString(raw.calendarId),
eventQuery: normalizeOptionalString(raw.event),
...window,
}),
);
}
case "artifacts": {
const resolved = await resolveArtifactQueryFromParams(config, raw);
return json(
await fetchGoogleMeetArtifacts({
accessToken: resolved.token.accessToken,
meeting: resolved.meeting,
conferenceRecord: resolved.conferenceRecord,
pageSize: resolved.pageSize,
includeTranscriptEntries: resolved.includeTranscriptEntries,
includeDocumentBodies: resolved.includeDocumentBodies,
allConferenceRecords: resolved.allConferenceRecords,
}),
);
}
case "attendance": {
const resolved = await resolveArtifactQueryFromParams(config, raw);
return json(
await fetchGoogleMeetAttendance({
accessToken: resolved.token.accessToken,
meeting: resolved.meeting,
conferenceRecord: resolved.conferenceRecord,
pageSize: resolved.pageSize,
allConferenceRecords: resolved.allConferenceRecords,
mergeDuplicateParticipants: resolved.mergeDuplicateParticipants,
lateAfterMinutes: resolved.lateAfterMinutes,
earlyBeforeMinutes: resolved.earlyBeforeMinutes,
}),
);
}
case "export": {
return json(await exportGoogleMeetBundleFromParams(config, raw));
}
case "leave": {
const sessionId = normalizeOptionalString(raw.sessionId);
if (!sessionId) {
throw new Error("sessionId required");
api.registerTool(
(toolContext) => ({
name: "google_meet",
label: "Google Meet",
description:
"Join and track Google Meet sessions through Chrome or Twilio. Call setup_status before join/create/test_listen/test_speech; if it reports a Chrome node offline, local audio missing, or missing Twilio dial plan, surface that blocker instead of retrying or switching transports. Twilio cannot dial a Meet URL directly: provide dialInNumber plus optional pin/dtmfSequence, or configure twilio.defaultDialInNumber. Offline nodes are diagnostics only, not usable candidates. If local Chrome talk-back audio is unsupported on this OS, use mode=transcribe, transport=twilio, or a macOS chrome-node for agent/bidi Chrome. If a Meet tab is already open after a timeout, call recover_current_tab before retrying join to report login, permission, or admission blockers without opening another tab.",
parameters: GoogleMeetToolSchema,
async execute(_toolCallId, params) {
const raw = asParamRecord(params);
const requesterSessionKey = normalizeOptionalString(toolContext.sessionKey);
const rawWithRequester = requesterSessionKey ? { ...raw, requesterSessionKey } : raw;
try {
assertGoogleMeetAgentToolActionSupported({ config, raw });
switch (raw.action) {
case "join": {
return json(
await callGoogleMeetGatewayFromTool({
config,
action: "join",
raw: rawWithRequester,
}),
);
}
return json(await callGoogleMeetGatewayFromTool({ config, action: "leave", raw }));
}
case "end_active_conference": {
return json(
await callGoogleMeetGatewayFromTool({
config,
action: "end_active_conference",
raw,
}),
);
}
case "speak": {
const sessionId = normalizeOptionalString(raw.sessionId);
if (!sessionId) {
throw new Error("sessionId required");
case "create": {
return json(
await callGoogleMeetGatewayFromTool({
config,
action: "create",
raw: rawWithRequester,
}),
);
}
return json(await callGoogleMeetGatewayFromTool({ config, action: "speak", raw }));
case "test_speech": {
return json(
await callGoogleMeetGatewayFromTool({
config,
action: "test_speech",
raw: rawWithRequester,
}),
);
}
case "test_listen": {
return json(
await callGoogleMeetGatewayFromTool({ config, action: "test_listen", raw }),
);
}
case "status": {
return json(await callGoogleMeetGatewayFromTool({ config, action: "status", raw }));
}
case "recover_current_tab": {
return json(
await callGoogleMeetGatewayFromTool({
config,
action: "recover_current_tab",
raw,
}),
);
}
case "setup_status": {
return json(
await callGoogleMeetGatewayFromTool({ config, action: "setup_status", raw }),
);
}
case "resolve_space": {
const { token: _token, ...result } = await resolveSpaceFromParams(config, raw);
return json(result);
}
case "preflight": {
const { meeting, token, space } = await resolveSpaceFromParams(config, raw);
return json(
buildGoogleMeetPreflightReport({
input: meeting,
space,
previewAcknowledged: config.preview.enrollmentAcknowledged,
tokenSource: token.refreshed ? "refresh-token" : "cached-access-token",
}),
);
}
case "latest": {
const token = await resolveGoogleMeetTokenFromParams(config, raw);
const resolved = await resolveMeetingFromParams({
config,
raw,
accessToken: token.accessToken,
});
return json({
...(await fetchLatestGoogleMeetConferenceRecord({
accessToken: token.accessToken,
meeting: resolved.meeting,
})),
...(resolved.calendarEvent ? { calendarEvent: resolved.calendarEvent } : {}),
});
}
case "calendar_events": {
const token = await resolveGoogleMeetTokenFromParams(config, raw);
const window = raw.today === true ? buildGoogleMeetCalendarDayWindow() : {};
return json(
await listGoogleMeetCalendarEvents({
accessToken: token.accessToken,
calendarId: normalizeOptionalString(raw.calendarId),
eventQuery: normalizeOptionalString(raw.event),
...window,
}),
);
}
case "artifacts": {
const resolved = await resolveArtifactQueryFromParams(config, raw);
return json(
await fetchGoogleMeetArtifacts({
accessToken: resolved.token.accessToken,
meeting: resolved.meeting,
conferenceRecord: resolved.conferenceRecord,
pageSize: resolved.pageSize,
includeTranscriptEntries: resolved.includeTranscriptEntries,
includeDocumentBodies: resolved.includeDocumentBodies,
allConferenceRecords: resolved.allConferenceRecords,
}),
);
}
case "attendance": {
const resolved = await resolveArtifactQueryFromParams(config, raw);
return json(
await fetchGoogleMeetAttendance({
accessToken: resolved.token.accessToken,
meeting: resolved.meeting,
conferenceRecord: resolved.conferenceRecord,
pageSize: resolved.pageSize,
allConferenceRecords: resolved.allConferenceRecords,
mergeDuplicateParticipants: resolved.mergeDuplicateParticipants,
lateAfterMinutes: resolved.lateAfterMinutes,
earlyBeforeMinutes: resolved.earlyBeforeMinutes,
}),
);
}
case "export": {
return json(await exportGoogleMeetBundleFromParams(config, raw));
}
case "leave": {
const sessionId = normalizeOptionalString(raw.sessionId);
if (!sessionId) {
throw new Error("sessionId required");
}
return json(await callGoogleMeetGatewayFromTool({ config, action: "leave", raw }));
}
case "end_active_conference": {
return json(
await callGoogleMeetGatewayFromTool({
config,
action: "end_active_conference",
raw,
}),
);
}
case "speak": {
const sessionId = normalizeOptionalString(raw.sessionId);
if (!sessionId) {
throw new Error("sessionId required");
}
return json(await callGoogleMeetGatewayFromTool({ config, action: "speak", raw }));
}
default:
throw new Error("unknown google_meet action");
}
default:
throw new Error("unknown google_meet action");
} catch (err) {
return json(formatGatewayError(err));
}
} catch (err) {
return json(formatGatewayError(err));
}
},
});
},
}),
{ name: "google_meet" },
);
api.registerNodeHostCommand({
command: "googlemeet.chrome",

View File

@@ -10,6 +10,7 @@ import {
type RealtimeVoiceTool,
} from "openclaw/plugin-sdk/realtime-voice";
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
import type { GoogleMeetConfig, GoogleMeetToolPolicy } from "./config.js";
export const GOOGLE_MEET_AGENT_CONSULT_TOOL_NAME = REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME;
@@ -44,11 +45,13 @@ export async function consultOpenClawAgentForGoogleMeet(params: {
runtime: PluginRuntime;
logger: RuntimeLogger;
meetingSessionId: string;
requesterSessionKey?: string;
args: unknown;
transcript: Array<{ role: "user" | "assistant"; text: string }>;
}): Promise<{ text: string }> {
const agentId = normalizeAgentId(params.config.realtime.agentId);
const requesterSessionKey = `agent:${agentId}:main`;
const requesterSessionKey =
normalizeOptionalString(params.requesterSessionKey) ?? `agent:${agentId}:main`;
const sessionKey = `agent:${agentId}:subagent:google-meet:${params.meetingSessionId}`;
return await consultRealtimeVoiceAgent({
cfg: params.fullConfig,
@@ -60,6 +63,7 @@ export async function consultOpenClawAgentForGoogleMeet(params: {
lane: "google-meet",
runIdPrefix: `google-meet:${params.meetingSessionId}`,
spawnedBy: requesterSessionKey,
contextMode: "fork",
args: params.args,
transcript: params.transcript,
surface: "a private Google Meet",

View File

@@ -146,6 +146,7 @@ export async function createAndJoinMeetFromParams(params: {
pin: normalizeOptionalString(params.raw.pin),
dtmfSequence: normalizeOptionalString(params.raw.dtmfSequence),
message: normalizeOptionalString(params.raw.message),
requesterSessionKey: normalizeOptionalString(params.raw.requesterSessionKey),
});
return {
...created,

View File

@@ -76,6 +76,7 @@ export async function startNodeAgentAudioBridge(params: {
fullConfig: OpenClawConfig;
runtime: PluginRuntime;
meetingSessionId: string;
requesterSessionKey?: string;
nodeId: string;
bridgeId: string;
logger: RuntimeLogger;
@@ -225,6 +226,7 @@ export async function startNodeAgentAudioBridge(params: {
runtime: params.runtime,
logger: params.logger,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
args: {
question: currentQuestion,
responseStyle: "Brief, natural spoken answer for a live meeting.",
@@ -373,6 +375,7 @@ export async function startNodeRealtimeAudioBridge(params: {
fullConfig: OpenClawConfig;
runtime: PluginRuntime;
meetingSessionId: string;
requesterSessionKey?: string;
nodeId: string;
bridgeId: string;
logger: RuntimeLogger;
@@ -457,6 +460,7 @@ export async function startNodeRealtimeAudioBridge(params: {
runtime: params.runtime,
logger: params.logger,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
args: {
question: currentQuestion,
responseStyle: "Brief, natural spoken answer for a live meeting.",
@@ -634,6 +638,7 @@ export async function startNodeRealtimeAudioBridge(params: {
runtime: params.runtime,
logger: params.logger,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
args: event.args,
transcript,
})

View File

@@ -513,6 +513,7 @@ export async function startCommandAgentAudioBridge(params: {
fullConfig: OpenClawConfig;
runtime: PluginRuntime;
meetingSessionId: string;
requesterSessionKey?: string;
inputCommand: string[];
outputCommand: string[];
logger: RuntimeLogger;
@@ -711,6 +712,7 @@ export async function startCommandAgentAudioBridge(params: {
runtime: params.runtime,
logger: params.logger,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
args: {
question: currentQuestion,
responseStyle: "Brief, natural spoken answer for a live meeting.",
@@ -822,6 +824,7 @@ export async function startCommandRealtimeAudioBridge(params: {
fullConfig: OpenClawConfig;
runtime: PluginRuntime;
meetingSessionId: string;
requesterSessionKey?: string;
inputCommand: string[];
outputCommand: string[];
logger: RuntimeLogger;
@@ -1108,6 +1111,7 @@ export async function startCommandRealtimeAudioBridge(params: {
runtime: params.runtime,
logger: params.logger,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
args: {
question: currentQuestion,
responseStyle: "Brief, natural spoken answer for a live meeting.",
@@ -1208,6 +1212,7 @@ export async function startCommandRealtimeAudioBridge(params: {
runtime: params.runtime,
logger: params.logger,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
args: event.args,
transcript,
})

View File

@@ -426,6 +426,7 @@ export class GoogleMeetRuntime {
config: this.params.config,
fullConfig: this.params.fullConfig,
meetingSessionId: session.id,
requesterSessionKey: request.requesterSessionKey,
mode,
url,
logger: this.params.logger,
@@ -435,6 +436,7 @@ export class GoogleMeetRuntime {
config: this.params.config,
fullConfig: this.params.fullConfig,
meetingSessionId: session.id,
requesterSessionKey: request.requesterSessionKey,
mode,
url,
logger: this.params.logger,

View File

@@ -61,6 +61,7 @@ export function setupGoogleMeetPlugin(
options?: { timeoutMs?: number },
) => Promise<CommandResult>;
registerPlatform?: NodeJS.Platform;
toolContext?: Record<string, unknown>;
} = {},
) {
const methods = new Map<string, unknown>();
@@ -154,7 +155,13 @@ export function setupGoogleMeetPlugin(
} as unknown as OpenClawPluginApi["runtime"],
logger: noopLogger,
registerGatewayMethod: (method: string, handler: unknown) => methods.set(method, handler),
registerTool: (tool: unknown) => tools.push(tool),
registerTool: (tool: unknown) => {
tools.push(
typeof tool === "function"
? (tool as (ctx: Record<string, unknown>) => unknown)(options.toolContext ?? {})
: tool,
);
},
registerCli: (_registrar: unknown, opts: unknown) => cliRegistrations.push(opts),
registerNodeHostCommand: (command: unknown) => nodeHostCommands.push(command),
});

View File

@@ -92,6 +92,7 @@ export async function launchChromeMeet(params: {
config: GoogleMeetConfig;
fullConfig: OpenClawConfig;
meetingSessionId: string;
requesterSessionKey?: string;
mode: GoogleMeetMode;
url: string;
logger: RuntimeLogger;
@@ -162,6 +163,7 @@ export async function launchChromeMeet(params: {
fullConfig: params.fullConfig,
runtime: params.runtime,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
inputCommand: params.config.chrome.audioInputCommand,
outputCommand: params.config.chrome.audioOutputCommand,
logger: params.logger,
@@ -174,6 +176,7 @@ export async function launchChromeMeet(params: {
fullConfig: params.fullConfig,
runtime: params.runtime,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
inputCommand: params.config.chrome.audioInputCommand,
outputCommand: params.config.chrome.audioOutputCommand,
logger: params.logger,
@@ -950,6 +953,7 @@ export async function launchChromeMeetOnNode(params: {
config: GoogleMeetConfig;
fullConfig: OpenClawConfig;
meetingSessionId: string;
requesterSessionKey?: string;
mode: GoogleMeetMode;
url: string;
logger: RuntimeLogger;
@@ -1025,6 +1029,7 @@ export async function launchChromeMeetOnNode(params: {
fullConfig: params.fullConfig,
runtime: params.runtime,
meetingSessionId: params.meetingSessionId,
requesterSessionKey: params.requesterSessionKey,
nodeId,
bridgeId: result.bridgeId,
logger: params.logger,

View File

@@ -7,6 +7,7 @@ export type GoogleMeetJoinRequest = {
transport?: GoogleMeetTransport;
mode?: GoogleMeetModeInput;
message?: string;
requesterSessionKey?: string;
timeoutMs?: number;
dialInNumber?: string;
pin?: string;

View File

@@ -17,4 +17,8 @@ export const matrixChannelConfigUiHints = {
label: "Matrix Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Matrix Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
} satisfies Record<string, ChannelConfigUiHint>;

View File

@@ -1,6 +1,7 @@
import {
createChannelProgressDraftGate,
formatChannelProgressDraftLine,
formatChannelProgressDraftLineForEntry,
formatChannelProgressDraftText,
isChannelProgressDraftWorkToolName,
resolveChannelProgressDraftMaxLines,
@@ -1580,7 +1581,8 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
onToolStart: async (payload) => {
const toolName = payload.name?.trim();
await pushPreviewToolProgress(
formatChannelProgressDraftLine(
formatChannelProgressDraftLineForEntry(
progressConfigEntry,
{
event: "tool",
name: toolName,
@@ -1594,7 +1596,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
},
onItemEvent: async (payload) => {
await pushPreviewToolProgress(
formatChannelProgressDraftLine({
formatChannelProgressDraftLineForEntry(progressConfigEntry, {
event: "item",
itemKind: payload.kind,
title: payload.title,

View File

@@ -33,10 +33,18 @@ export const mattermostChannelConfigUiHints = {
label: "Mattermost Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Mattermost Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.preview.toolProgress": {
label: "Mattermost Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview post (default: true). Set false to hide interim tool updates while the draft preview stays active.",
},
"streaming.preview.commandText": {
label: "Mattermost Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.block.enabled": {
label: "Mattermost Block Streaming Enabled",
help: 'Enable chunked block-style Mattermost preview delivery when channels.mattermost.streaming.mode="block".',

View File

@@ -256,4 +256,15 @@ describe("buildMattermostToolStatusText", () => {
}),
).toBe("🛠️ Exec: run tests, `pnpm test -- --watch=false`");
});
it("can hide raw exec detail from status text", () => {
expect(
buildMattermostToolStatusText({
name: "exec",
args: { command: "pnpm test -- --watch=false" },
detailMode: "raw",
config: { streaming: { preview: { commandText: "status" } } },
}),
).toBe("🛠️ Exec");
});
});

View File

@@ -1,5 +1,5 @@
import { createFinalizableDraftLifecycle } from "openclaw/plugin-sdk/channel-lifecycle";
import { formatChannelProgressDraftLine } from "openclaw/plugin-sdk/channel-streaming";
import { formatChannelProgressDraftLineForEntry } from "openclaw/plugin-sdk/channel-streaming";
import {
createMattermostPost,
deleteMattermostPost,
@@ -37,9 +37,11 @@ export function buildMattermostToolStatusText(params: {
phase?: string;
args?: Record<string, unknown>;
detailMode?: "explain" | "raw";
config?: Parameters<typeof formatChannelProgressDraftLineForEntry>[0];
}): string {
return (
formatChannelProgressDraftLine(
formatChannelProgressDraftLineForEntry(
params.config,
{
event: "tool",
name: params.name,

View File

@@ -1876,7 +1876,12 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
if (!draftToolProgressEnabled) {
return;
}
draftStream.update(buildMattermostToolStatusText(payload));
draftStream.update(
buildMattermostToolStatusText({
...payload,
config: account.config,
}),
);
},
},
}),

View File

@@ -11,7 +11,7 @@ import {
type AnyAgentTool,
type OpenClawPluginToolContext,
} from "openclaw/plugin-sdk/plugin-entry";
import { Type } from "typebox";
import type { TSchema } from "typebox";
import { registerShortTermPromotionDreaming } from "./src/dreaming.js";
import { buildMemoryFlushPlan } from "./src/flush-plan.js";
import { registerBuiltInMemoryEmbeddingProviders } from "./src/memory/provider-adapters.js";
@@ -58,28 +58,29 @@ function hasMemoryToolContext(options: MemoryToolOptions): boolean {
return Boolean(resolveMemorySearchConfig(cfg, agentId));
}
const MemorySearchSchema = Type.Object({
query: Type.String(),
maxResults: Type.Optional(Type.Number()),
minScore: Type.Optional(Type.Number()),
corpus: Type.Optional(
Type.Union([
Type.Literal("memory"),
Type.Literal("wiki"),
Type.Literal("all"),
Type.Literal("sessions"),
]),
),
});
const MemorySearchSchema = {
type: "object",
properties: {
query: { type: "string" },
maxResults: { type: "number" },
minScore: { type: "number" },
corpus: { type: "string", enum: ["memory", "wiki", "all", "sessions"] },
},
required: ["query"],
additionalProperties: false,
} as const satisfies TSchema;
const MemoryGetSchema = Type.Object({
path: Type.String(),
from: Type.Optional(Type.Number()),
lines: Type.Optional(Type.Number()),
corpus: Type.Optional(
Type.Union([Type.Literal("memory"), Type.Literal("wiki"), Type.Literal("all")]),
),
});
const MemoryGetSchema = {
type: "object",
properties: {
path: { type: "string" },
from: { type: "number" },
lines: { type: "number" },
corpus: { type: "string", enum: ["memory", "wiki", "all"] },
},
required: ["path"],
additionalProperties: false,
} as const satisfies TSchema;
function createLazyMemoryTool(params: {
options: MemoryToolOptions;

View File

@@ -29,4 +29,8 @@ export const msTeamsChannelConfigUiHints = {
label: "MS Teams Progress Tool Lines",
help: "Show compact tool/progress lines in progress mode (default: true). Set false to keep only the title until final delivery.",
},
"streaming.progress.commandText": {
label: "MS Teams Progress Command Text",
help: 'Command/exec detail in progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
} satisfies Record<string, ChannelConfigUiHint>;

View File

@@ -1,5 +1,6 @@
import {
formatChannelProgressDraftLine,
formatChannelProgressDraftLineForEntry,
resolveChannelPreviewStreamMode,
resolveChannelStreamingBlockEnabled,
} from "openclaw/plugin-sdk/channel-streaming";
@@ -384,7 +385,8 @@ export function createMSTeamsReplyDispatcher(params: {
detailMode?: "explain" | "raw";
}) => {
await streamController.pushProgressLine(
formatChannelProgressDraftLine(
formatChannelProgressDraftLineForEntry(
msteamsCfg,
{
event: "tool",
name: payload.name,
@@ -407,7 +409,7 @@ export function createMSTeamsReplyDispatcher(params: {
status?: string;
}) => {
await streamController.pushProgressLine(
formatChannelProgressDraftLine({
formatChannelProgressDraftLineForEntry(msteamsCfg, {
event: "item",
itemKind: payload.kind,
title: payload.title,

View File

@@ -117,6 +117,10 @@ export const slackChannelConfigUiHints = {
label: "Slack Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview message (default: true). Set false to hide interim tool updates while the draft preview stays active.",
},
"streaming.preview.commandText": {
label: "Slack Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.progress.label": {
label: "Slack Progress Label",
help: 'Initial progress draft title. Use "auto" for built-in single-word labels, a custom string, or false to hide the title.',
@@ -137,6 +141,10 @@ export const slackChannelConfigUiHints = {
label: "Slack Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Slack Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"thread.historyScope": {
label: "Slack Thread History Scope",
help: 'Scope for Slack thread history context ("thread" isolates per thread; "channel" reuses channel history).',

View File

@@ -37,7 +37,16 @@ let capturedReplyOptions:
| {
disableBlockStreaming?: boolean;
suppressDefaultToolProgressMessages?: boolean;
onItemEvent?: (payload: { progressText: string }) => Promise<void> | void;
onItemEvent?: (payload: {
kind?: string;
progressText?: string;
summary?: string;
title?: string;
name?: string;
phase?: string;
status?: string;
meta?: string;
}) => Promise<void> | void;
onPartialReply?: (payload: { text: string }) => Promise<void> | void;
}
| undefined;
@@ -73,7 +82,18 @@ let mockedDispatchSequence: Array<{
}> = [];
let mockedProgressEvents: string[] = [];
let mockedReplyOptionEvents: Array<
{ kind: "item"; progressText: string } | { kind: "partial"; text: string }
| {
kind: "item";
itemKind?: string;
progressText?: string;
summary?: string;
title?: string;
name?: string;
phase?: string;
status?: string;
meta?: string;
}
| { kind: "partial"; text: string }
> = [];
const noop = () => {};
@@ -246,6 +266,41 @@ vi.mock("openclaw/plugin-sdk/channel-streaming", () => ({
}
: undefined;
},
buildChannelProgressDraftLineForEntry: (
entry: {
streaming?: {
progress?: { commandText?: "raw" | "status" };
preview?: { commandText?: "raw" | "status" };
};
},
params: {
itemKind?: string;
progressText?: string;
summary?: string;
title?: string;
name?: string;
},
) => {
if (
(entry.streaming?.progress?.commandText ?? entry.streaming?.preview?.commandText) ===
"status" &&
(params.itemKind === "command" || params.name === "exec")
) {
return {
kind: "item",
text: "🛠️ Exec",
label: "Exec",
};
}
const text = params.progressText ?? params.summary ?? params.title ?? params.name;
return text
? {
kind: "item",
text,
label: params.title ?? params.name ?? "Update",
}
: undefined;
},
createChannelProgressDraftGate: (params: { onStart: () => void | Promise<void> }) => {
let started = false;
let workEvents = 0;
@@ -290,6 +345,15 @@ vi.mock("openclaw/plugin-sdk/channel-streaming", () => ({
title?: string;
name?: string;
}) => params.progressText ?? params.summary ?? params.title ?? params.name,
formatChannelProgressDraftLineForEntry: (
_entry: unknown,
params: {
progressText?: string;
summary?: string;
title?: string;
name?: string;
},
) => params.progressText ?? params.summary ?? params.title ?? params.name,
resolveChannelProgressDraftMaxLines: (entry?: {
streaming?: { progress?: { maxLines?: number } };
}) => entry?.streaming?.progress?.maxLines ?? 8,
@@ -472,7 +536,16 @@ vi.mock("../reply.runtime.js", () => ({
replyOptions?: {
disableBlockStreaming?: boolean;
suppressDefaultToolProgressMessages?: boolean;
onItemEvent?: (payload: { progressText: string }) => Promise<void> | void;
onItemEvent?: (payload: {
kind?: string;
progressText?: string;
summary?: string;
title?: string;
name?: string;
phase?: string;
status?: string;
meta?: string;
}) => Promise<void> | void;
onPartialReply?: (payload: { text: string }) => Promise<void> | void;
};
dispatcher: {
@@ -492,7 +565,16 @@ vi.mock("../reply.runtime.js", () => ({
if (mockedReplyOptionEvents.length > 0) {
for (const entry of mockedReplyOptionEvents) {
if (entry.kind === "item") {
await params.replyOptions?.onItemEvent?.({ progressText: entry.progressText });
await params.replyOptions?.onItemEvent?.({
kind: entry.itemKind,
progressText: entry.progressText,
summary: entry.summary,
title: entry.title,
name: entry.name,
phase: entry.phase,
status: entry.status,
meta: entry.meta,
});
} else {
await params.replyOptions?.onPartialReply?.({ text: entry.text });
}
@@ -749,6 +831,34 @@ describe("dispatchPreparedSlackMessage preview fallback", () => {
);
});
it("can hide raw Slack command progress text by config", async () => {
const draftStream = createDraftStreamStub();
createSlackDraftStreamMock.mockReturnValueOnce(draftStream);
mockedSlackStreamingMode = "progress";
mockedSlackDraftMode = "status_final";
mockedDispatchSequence = [];
mockedReplyOptionEvents = [
{
kind: "item",
itemKind: "command",
name: "exec",
progressText: "exec pnpm test -- --watch=false",
},
{ kind: "item", progressText: "done" },
];
await dispatchPreparedSlackMessage(
createPreparedSlackMessage({
accountConfig: {
streaming: { mode: "progress", progress: { label: "Shelling", commandText: "status" } },
},
}),
);
expect(draftStream.update).toHaveBeenCalledWith("Shelling\n• 🛠️ Exec\n• done");
expect(draftStream.update.mock.calls.flat().join("\n")).not.toContain("pnpm test");
});
it("suppresses standalone Slack tool progress when progress lines are disabled", async () => {
mockedSlackStreamingMode = "progress";
mockedSlackDraftMode = "status_final";

View File

@@ -14,6 +14,7 @@ import {
} from "openclaw/plugin-sdk/channel-reply-pipeline";
import {
buildChannelProgressDraftLine,
buildChannelProgressDraftLineForEntry,
createChannelProgressDraftGate,
formatChannelProgressDraftText,
isChannelProgressDraftWorkToolName,
@@ -1108,7 +1109,8 @@ export async function dispatchPreparedSlackMessage(prepared: PreparedSlackMessag
await statusReactions.setTool(payload.name);
}
await pushPreviewToolProgress(
buildChannelProgressDraftLine(
buildChannelProgressDraftLineForEntry(
account.config,
{
event: "tool",
name: payload.name,
@@ -1122,7 +1124,7 @@ export async function dispatchPreparedSlackMessage(prepared: PreparedSlackMessag
},
onItemEvent: async (payload) => {
await pushPreviewToolProgress(
buildChannelProgressDraftLine({
buildChannelProgressDraftLineForEntry(account.config, {
event: "item",
itemKind: payload.kind,
title: payload.title,

View File

@@ -780,14 +780,14 @@ describe("dispatchTelegramMessage draft streaming", () => {
);
});
it("keeps the Telegram progress draft across post-tool assistant boundaries", async () => {
it("keeps non-command Telegram progress draft lines across post-tool assistant boundaries", async () => {
const draftStream = createSequencedDraftStream(2001);
createTelegramDraftStream.mockReturnValue(draftStream);
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(
async ({ dispatcherOptions, replyOptions }) => {
await replyOptions?.onReplyStart?.();
await replyOptions?.onAssistantMessageStart?.();
await replyOptions?.onItemEvent?.({ progressText: "exec ls ~/Desktop" });
await replyOptions?.onItemEvent?.({ kind: "search", progressText: "docs lookup" });
await replyOptions?.onItemEvent?.({ progressText: "tests passed" });
await replyOptions?.onAssistantMessageStart?.();
await dispatcherOptions.deliver({ text: "Final after tool" }, { kind: "final" });
@@ -802,7 +802,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
});
expect(draftStream.update).toHaveBeenCalledWith(
expect.stringMatching(/^Shelling\n• `exec ls ~\/Desktop`\n• `tests passed`$/),
expect.stringMatching(/^Shelling\n`🔎 Web Search: docs lookup`\n• `tests passed`$/),
);
expect(draftStream.forceNewMessage).not.toHaveBeenCalled();
expect(draftStream.materialize).not.toHaveBeenCalled();
@@ -815,19 +815,23 @@ describe("dispatchTelegramMessage draft streaming", () => {
expect(draftStream.clear).not.toHaveBeenCalled();
});
it("streams Telegram tool progress by default when preview streaming is active", async () => {
it("streams Telegram command progress text by default when preview streaming is active", async () => {
const draftStream = createDraftStream();
createTelegramDraftStream.mockReturnValue(draftStream);
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => {
await replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
await replyOptions?.onItemEvent?.({ progressText: "exec ls ~/Desktop" });
await replyOptions?.onItemEvent?.({
kind: "command",
name: "exec",
progressText: "exec ls ~/Desktop",
});
return { queuedFinal: false };
});
await dispatchWithContext({ context: createContext(), streamMode: "partial" });
expect(draftStream.update).toHaveBeenCalledWith(
expect.stringMatching(/\n`🛠️ Exec`\n• `exec ls ~\/Desktop`$/),
expect.stringMatching(/\n`🛠️ Exec`\n`🛠️ Exec: exec ls ~\/Desktop`$/),
);
expect(dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledWith(
expect.objectContaining({
@@ -838,6 +842,36 @@ describe("dispatchTelegramMessage draft streaming", () => {
);
});
it("can hide Telegram command progress text by config", async () => {
const draftStream = createDraftStream();
createTelegramDraftStream.mockReturnValue(draftStream);
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => {
await replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
await replyOptions?.onItemEvent?.({
kind: "command",
name: "exec",
progressText: "exec ls ~/Desktop",
});
return { queuedFinal: false };
});
await dispatchWithContext({
context: createContext(),
streamMode: "partial",
telegramCfg: { streaming: { mode: "partial", preview: { commandText: "status" } } },
});
expect(draftStream.update).toHaveBeenCalledWith(expect.stringMatching(/\n`🛠️ Exec`$/));
expect(draftStream.update.mock.calls.at(-1)?.[0]).not.toContain("exec ls");
expect(dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledWith(
expect.objectContaining({
replyOptions: expect.objectContaining({
suppressDefaultToolProgressMessages: true,
}),
}),
);
});
it("suppresses Telegram tool progress when explicitly disabled", async () => {
const draftStream = createDraftStream();
createTelegramDraftStream.mockReturnValue(draftStream);
@@ -882,12 +916,15 @@ describe("dispatchTelegramMessage draft streaming", () => {
);
});
it("keeps Telegram tool progress links inside code formatting", async () => {
it("keeps non-command Telegram tool progress links inside code formatting", async () => {
const draftStream = createDraftStream();
createTelegramDraftStream.mockReturnValue(draftStream);
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ replyOptions }) => {
await replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
await replyOptions?.onItemEvent?.({ progressText: "read [label](tg://user?id=123)" });
await replyOptions?.onItemEvent?.({
kind: "search",
progressText: "read [label](tg://user?id=123)",
});
return { queuedFinal: false };
});
@@ -897,7 +934,9 @@ describe("dispatchTelegramMessage draft streaming", () => {
});
const lastPreviewText = draftStream.update.mock.calls.at(-1)?.[0];
expect(lastPreviewText).toMatch(/\n`🛠️ Exec`\n• `read \[label\]\(tg:\/\/user\?id=123\)`$/);
expect(lastPreviewText).toMatch(
/\n`🛠️ Exec`\n`🔎 Web Search: read \[label\]\(tg:\/\/user\?id=123\)`$/,
);
expect(renderTelegramHtmlText(lastPreviewText ?? "")).not.toContain("<a ");
expect(dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledWith(
expect.objectContaining({
@@ -927,7 +966,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
const progressLine = lastPreviewText.split("\n").at(1) ?? "";
expect(lastPreviewText.length).toBeLessThan(340);
expect(progressLine).toMatch(/^• `'{10}/);
expect(progressLine).toMatch(/^• `.*…`$/);
expect(progressLine).toContain("…");
expect(renderTelegramHtmlText(lastPreviewText)).not.toContain("<a ");
});

View File

@@ -9,6 +9,7 @@ import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pi
import {
createChannelProgressDraftGate,
formatChannelProgressDraftLine,
formatChannelProgressDraftLineForEntry,
formatChannelProgressDraftText,
isChannelProgressDraftWorkToolName,
resolveChannelProgressDraftMaxLines,
@@ -1173,7 +1174,8 @@ export const dispatchTelegramMessage = async ({
await statusReactionController.setTool(toolName);
}
await pushPreviewToolProgress(
formatChannelProgressDraftLine(
formatChannelProgressDraftLineForEntry(
telegramCfg,
{
event: "tool",
name: toolName,
@@ -1187,7 +1189,7 @@ export const dispatchTelegramMessage = async ({
},
onItemEvent: async (payload) => {
await pushPreviewToolProgress(
formatChannelProgressDraftLine({
formatChannelProgressDraftLineForEntry(telegramCfg, {
event: "item",
itemKind: payload.kind,
title: payload.title,

View File

@@ -73,6 +73,10 @@ export const telegramChannelConfigUiHints = {
label: "Telegram Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview message (default: true when preview streaming is active). Set false to keep tool updates out of the edited Telegram preview.",
},
"streaming.preview.commandText": {
label: "Telegram Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.progress.label": {
label: "Telegram Progress Label",
help: 'Initial progress draft title. Use "auto" for built-in single-word labels, a custom string, or false to hide the title.',
@@ -89,6 +93,10 @@ export const telegramChannelConfigUiHints = {
label: "Telegram Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Telegram Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"retry.attempts": {
label: "Telegram Retry Attempts",
help: "Max retry attempts for outbound Telegram API calls (default: 3).",

View File

@@ -1477,6 +1477,7 @@
"qa:lab:watch": "vite build --watch --config extensions/qa-lab/web/vite.config.ts",
"qa:otel:smoke": "node --import tsx scripts/qa-otel-smoke.ts",
"release-metadata:check": "node scripts/check-release-metadata-only.mjs",
"release:beta-smoke": "node --import tsx scripts/release-beta-smoke.ts",
"release:check": "pnpm deps:root-ownership:check && pnpm plugins:inventory:check && pnpm check:base-config-schema && pnpm check:bundled-channel-config-metadata && pnpm config:docs:check && pnpm plugin-sdk:check-exports && pnpm plugin-sdk:api:check && node --import tsx scripts/release-check.ts",
"release:openclaw:npm:check": "node --import tsx scripts/openclaw-npm-release-check.ts",
"release:openclaw:npm:verify-published": "node --import tsx scripts/openclaw-npm-postpublish-verify.ts",

View File

@@ -88,17 +88,70 @@ if [ -z "$PACKAGE_LABEL" ]; then
fi
fi
credential_source="$(resolve_credential_source)"
credential_role="$(resolve_credential_role)"
if [ -z "$credential_role" ] && [ -n "${CI:-}" ] && [ "$credential_source" = "convex" ]; then
credential_role="ci"
fi
validate_credential_preflight() {
if [ "${OPENCLAW_NPM_TELEGRAM_SKIP_CREDENTIAL_PREFLIGHT:-0}" = "1" ]; then
return 0
fi
if [ "$credential_source" = "convex" ]; then
if [ -z "${OPENCLAW_QA_CONVEX_SITE_URL:-}" ]; then
echo "Missing required env for Convex credential mode: OPENCLAW_QA_CONVEX_SITE_URL" >&2
exit 1
fi
if [ "$credential_role" = "ci" ]; then
if [ -z "${OPENCLAW_QA_CONVEX_SECRET_CI:-}" ]; then
echo "Missing required env for Convex ci credential mode: OPENCLAW_QA_CONVEX_SECRET_CI" >&2
exit 1
fi
return 0
fi
if [ "$credential_role" = "maintainer" ]; then
if [ -z "${OPENCLAW_QA_CONVEX_SECRET_MAINTAINER:-}" ]; then
echo "Missing required env for Convex maintainer credential mode: OPENCLAW_QA_CONVEX_SECRET_MAINTAINER" >&2
exit 1
fi
return 0
fi
if [ -z "${OPENCLAW_QA_CONVEX_SECRET_CI:-}" ] && [ -z "${OPENCLAW_QA_CONVEX_SECRET_MAINTAINER:-}" ]; then
echo "Missing required env for Convex credential mode: OPENCLAW_QA_CONVEX_SECRET_CI or OPENCLAW_QA_CONVEX_SECRET_MAINTAINER" >&2
exit 1
fi
return 0
fi
local missing=()
for key in \
OPENCLAW_QA_TELEGRAM_GROUP_ID \
OPENCLAW_QA_TELEGRAM_DRIVER_BOT_TOKEN \
OPENCLAW_QA_TELEGRAM_SUT_BOT_TOKEN; do
if [ -z "${!key:-}" ]; then
missing+=("$key")
fi
done
if [ "${#missing[@]}" -gt 0 ]; then
{
echo "Missing required Telegram QA credential env before Docker work: ${missing[*]}"
echo "Use one of:"
echo " direct Telegram env: OPENCLAW_QA_TELEGRAM_GROUP_ID, OPENCLAW_QA_TELEGRAM_DRIVER_BOT_TOKEN, OPENCLAW_QA_TELEGRAM_SUT_BOT_TOKEN"
echo " Convex env: OPENCLAW_NPM_TELEGRAM_CREDENTIAL_SOURCE=convex plus OPENCLAW_QA_CONVEX_SITE_URL and a role secret"
} >&2
exit 1
fi
}
validate_credential_preflight
docker_e2e_build_or_reuse "$IMAGE_NAME" npm-telegram-live "$ROOT_DIR/scripts/e2e/Dockerfile" "$ROOT_DIR" "$DOCKER_TARGET"
mkdir -p "$ROOT_DIR/.artifacts/qa-e2e"
run_log="$(mktemp "${TMPDIR:-/tmp}/openclaw-npm-telegram-live.XXXXXX")"
npm_prefix_host="$(mktemp -d "$ROOT_DIR/.artifacts/qa-e2e/npm-telegram-live-prefix.XXXXXX")"
trap 'rm -f "$run_log"; rm -rf "$npm_prefix_host"' EXIT
credential_source="$(resolve_credential_source)"
credential_role="$(resolve_credential_role)"
if [ -z "$credential_role" ] && [ -n "${CI:-}" ] && [ "$credential_source" = "convex" ]; then
credential_role="ci"
fi
docker_env=(
-e COREPACK_ENABLE_DOWNLOAD_PROMPT=0

View File

@@ -65,10 +65,19 @@ interface NpmUpdateSummary {
packageSpec: string;
updateTarget: string;
updateExpected: string;
updateTargetBuildCommit: string;
updateTargetPackageVersion: string;
updateTargetTarball: string;
provider: Provider;
latestVersion: string;
currentHead: string;
runDir: string;
slowestTiming?: {
durationMs: number;
label: string;
phase: "fresh" | "fresh-target" | "update";
};
totalDurationMs: number;
fresh: Record<Platform, string>;
freshTarget: Record<Platform, string>;
freshTargetSpec: string;
@@ -184,6 +193,13 @@ function platformRecord<T>(value: T): Record<Platform, T> {
return { linux: value, macos: value, windows: value };
}
function formatDuration(durationMs: number): string {
const seconds = Math.round(durationMs / 1000);
const minutes = Math.floor(seconds / 60);
const remainder = seconds % 60;
return minutes > 0 ? `${minutes}m ${remainder}s` : `${remainder}s`;
}
class NpmUpdateSmoke {
private auth: ProviderAuth;
private windowsAuth: ProviderAuth;
@@ -197,8 +213,12 @@ class NpmUpdateSmoke {
private server: HostServer | null = null;
private artifact: PackageArtifact | null = null;
private freshTargetSpec = "";
private startedAt = Date.now();
private updateTargetBuildCommit = "";
private updateTargetEffective = "";
private updateExpectedNeedle = "";
private updateTargetPackageVersion = "";
private updateTargetTarball = "";
private linuxVm = linuxVmDefault;
private freshStatus = platformRecord("skip");
@@ -221,6 +241,7 @@ class NpmUpdateSmoke {
}
async run(): Promise<void> {
this.startedAt = Date.now();
this.runDir = await makeTempDir("openclaw-parallels-npm-update.");
this.tgzDir = await makeTempDir("openclaw-parallels-npm-update-tgz.");
try {
@@ -394,12 +415,76 @@ class NpmUpdateSmoke {
});
this.updateTargetEffective = this.server.urlFor(this.artifact.path);
this.updateExpectedNeedle = this.currentHeadShort;
this.updateTargetPackageVersion = this.artifact.version ?? "";
this.updateTargetBuildCommit =
this.artifact.buildCommitShort ?? this.artifact.buildCommit ?? "";
this.updateTargetTarball = this.updateTargetEffective;
return;
}
this.updateTargetEffective = this.options.updateTarget;
this.updateExpectedNeedle = this.isExplicitPackageTarget(this.updateTargetEffective)
? ""
: resolveOpenClawRegistryVersion(this.updateTargetEffective) || this.updateTargetEffective;
const metadata = this.resolveRegistryPackageMetadata(this.updateTargetEffective);
this.updateTargetPackageVersion = metadata.version;
this.updateTargetBuildCommit =
metadata.gitHead || this.resolvePackageBuildCommit(metadata.tarball);
this.updateTargetTarball = metadata.tarball;
}
private resolvePackageBuildCommit(tarball: string): string {
if (!tarball) {
return "";
}
const output = run(
"bash",
["-lc", `curl -fsSL ${shellQuote(tarball)} | tar -xzOf - package/dist/build-info.json`],
{
check: false,
quiet: true,
},
).stdout.trim();
if (!output) {
return "";
}
try {
const parsed = JSON.parse(output) as { commit?: string };
return parsed.commit ? parsed.commit.slice(0, 7) : "";
} catch {
return "";
}
}
private resolveRegistryPackageMetadata(target: string): {
gitHead: string;
tarball: string;
version: string;
} {
if (this.isExplicitPackageTarget(target)) {
return { gitHead: "", tarball: "", version: "" };
}
const spec = target.startsWith("openclaw@") ? target : `openclaw@${target}`;
const output = run("npm", ["view", spec, "version", "dist.tarball", "gitHead", "--json"], {
check: false,
quiet: true,
}).stdout.trim();
if (!output) {
return { gitHead: "", tarball: "", version: "" };
}
try {
const parsed = JSON.parse(output) as {
dist?: { tarball?: string };
gitHead?: string;
version?: string;
};
return {
gitHead: parsed.gitHead ?? "",
tarball: parsed.dist?.tarball ?? "",
version: parsed.version ?? "",
};
} catch {
return { gitHead: "", tarball: "", version: "" };
}
}
private async runSameGuestUpdates(): Promise<void> {
@@ -900,6 +985,7 @@ class NpmUpdateSmoke {
}
private async writeSummary(): Promise<string> {
const slowestTiming = this.timings.toSorted((a, b) => b.durationMs - a.durationMs)[0];
const summary: NpmUpdateSummary = {
currentHead: this.currentHeadShort,
fresh: this.freshStatus,
@@ -915,7 +1001,18 @@ class NpmUpdateSmoke {
windows: { status: this.updateStatus.windows, version: this.updateVersion.windows },
},
timings: this.timings,
slowestTiming: slowestTiming
? {
durationMs: slowestTiming.durationMs,
label: slowestTiming.label,
phase: slowestTiming.phase,
}
: undefined,
totalDurationMs: Date.now() - this.startedAt,
updateExpected: this.updateExpectedNeedle,
updateTargetBuildCommit: this.updateTargetBuildCommit,
updateTargetPackageVersion: this.updateTargetPackageVersion,
updateTargetTarball: this.updateTargetTarball,
updateTarget: this.updateTargetEffective,
};
const summaryPath = path.join(this.runDir, "summary.json");
@@ -924,10 +1021,14 @@ class NpmUpdateSmoke {
lines: [
`- package spec: ${summary.packageSpec}`,
`- update target: ${summary.updateTarget}`,
`- update target package: ${summary.updateTargetPackageVersion || "unknown"}${summary.updateTargetBuildCommit ? ` (${summary.updateTargetBuildCommit})` : ""}`,
`- update target tarball: ${summary.updateTargetTarball || "n/a"}`,
`- update expected: ${summary.updateExpected}`,
`- fresh: macOS=${summary.fresh.macos}, Windows=${summary.fresh.windows}, Linux=${summary.fresh.linux}`,
`- update: macOS=${summary.update.macos.status} (${summary.update.macos.version}), Windows=${summary.update.windows.status} (${summary.update.windows.version}), Linux=${summary.update.linux.status} (${summary.update.linux.version})`,
`- fresh target: ${summary.freshTargetSpec || "skip"} macOS=${summary.freshTarget.macos}, Windows=${summary.freshTarget.windows}, Linux=${summary.freshTarget.linux}`,
`- wall clock: ${formatDuration(summary.totalDurationMs)}`,
`- slowest phase: ${summary.slowestTiming ? `${summary.slowestTiming.phase}/${summary.slowestTiming.label} ${formatDuration(summary.slowestTiming.durationMs)}` : "n/a"}`,
`- logs: ${summary.runDir}`,
],
summaryPath,

View File

@@ -0,0 +1,371 @@
#!/usr/bin/env -S pnpm tsx
import { spawnSync } from "node:child_process";
import { existsSync, mkdirSync, readdirSync, readFileSync } from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";
interface Options {
beta: string;
model: string;
providerMode: string;
ref: string;
repo: string;
skipParallels: boolean;
skipTelegram: boolean;
}
function usage(): string {
return `Usage: pnpm release:beta-smoke -- --beta beta4 [options]
Options:
--beta <beta|betaN|version> Beta target. Default: beta
--model <provider/model> Parallels agent-turn model. Default: openai/gpt-5.4
--provider-mode <mode> Telegram workflow provider mode. Default: mock-openai
--ref <ref> GitHub workflow dispatch ref. Default: main
--repo <owner/repo> GitHub repo. Default: openclaw/openclaw
--skip-parallels Only run Telegram workflow
--skip-telegram Only run Parallels beta validation
-h, --help Show help
`;
}
function parseArgs(argv: string[]): Options {
const options: Options = {
beta: "beta",
model: "openai/gpt-5.4",
providerMode: "mock-openai",
ref: "main",
repo: "openclaw/openclaw",
skipParallels: false,
skipTelegram: false,
};
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
switch (arg) {
case "--":
break;
case "--beta":
options.beta = requireValue(argv, ++i, arg);
break;
case "--model":
options.model = requireValue(argv, ++i, arg);
break;
case "--provider-mode":
options.providerMode = requireValue(argv, ++i, arg);
break;
case "--ref":
options.ref = requireValue(argv, ++i, arg);
break;
case "--repo":
options.repo = requireValue(argv, ++i, arg);
break;
case "--skip-parallels":
options.skipParallels = true;
break;
case "--skip-telegram":
options.skipTelegram = true;
break;
case "-h":
case "--help":
process.stdout.write(usage());
process.exit(0);
default:
throw new Error(`unknown option: ${arg}`);
}
}
return options;
}
function requireValue(argv: string[], index: number, flag: string): string {
const value = argv[index];
if (!value || value.startsWith("-")) {
throw new Error(`${flag} requires a value`);
}
return value;
}
function run(command: string, args: string[], input?: { capture?: boolean }): string {
const result = spawnSync(command, args, {
encoding: "utf8",
stdio: input?.capture ? ["ignore", "pipe", "pipe"] : "inherit",
});
if (result.status !== 0) {
const stderr = result.stderr ? `\n${result.stderr}` : "";
throw new Error(
`${command} ${args.join(" ")} failed with ${result.status ?? "signal"}${stderr}`,
);
}
return result.stdout ?? "";
}
function shellQuote(value: string): string {
return `'${value.replace(/'/g, "'\\''")}'`;
}
const TELEGRAM_BETA_WORKFLOW_FILE = "npm-telegram-beta-e2e.yml";
function resolveBetaVersion(beta: string): string {
const value = beta.trim().replace(/^openclaw@/, "");
if (/^\d{4}\.\d+\.\d+-beta\.\d+$/u.test(value)) {
return value;
}
if (value === "beta") {
return run("npm", ["view", "openclaw@beta", "version"], { capture: true }).trim();
}
const betaMatch = /^(?:beta)?(\d+)$/u.exec(value);
if (!betaMatch) {
return run("npm", ["view", `openclaw@${value}`, "version"], { capture: true }).trim();
}
const suffix = `-beta.${betaMatch[1]}`;
const versions = JSON.parse(
run("npm", ["view", "openclaw", "versions", "--json"], { capture: true }),
) as string[];
const match = versions
.filter((version) => version.endsWith(suffix))
.toSorted((a, b) => a.localeCompare(b, undefined, { numeric: true }))
.at(-1);
if (!match) {
throw new Error(`no openclaw registry version found for ${beta}`);
}
return match;
}
function timeoutCommand(): string {
return run("bash", ["-lc", "command -v gtimeout || command -v timeout"], {
capture: true,
}).trim();
}
function runParallels(beta: string, model: string): void {
const timeoutBin = timeoutCommand();
const forwarded = [
"pnpm",
"test:parallels:npm-update",
"--",
"--beta-validation",
beta,
"--model",
model,
"--json",
];
const command = [
'set -a; source "$HOME/.profile" >/dev/null 2>&1 || true; set +a;',
"exec",
shellQuote(timeoutBin),
"--foreground",
"150m",
...forwarded.map(shellQuote),
].join(" ");
run("bash", ["-lc", command]);
}
function ghJson(repo: string, pathSuffix: string): unknown {
return JSON.parse(run("gh", ["api", `repos/${repo}/${pathSuffix}`], { capture: true }));
}
export function parseWorkflowRunIdFromOutput(output: string): string | undefined {
return /\/actions\/runs\/(\d+)/u.exec(output)?.[1];
}
type WorkflowRunListEntry = {
createdAt?: string;
databaseId?: number | string;
};
function normalizeRunId(value: unknown): string | undefined {
if (typeof value === "number" && Number.isFinite(value)) {
return String(value);
}
if (typeof value === "string" && value.trim()) {
return value.trim();
}
return undefined;
}
export function selectNewestDispatchedRunId(params: {
beforeIds: ReadonlySet<string>;
runs: readonly WorkflowRunListEntry[];
}): string | undefined {
return params.runs
.filter((entry) => {
const id = normalizeRunId(entry.databaseId);
return id !== undefined && !params.beforeIds.has(id);
})
.toSorted((a, b) => (b.createdAt ?? "").localeCompare(a.createdAt ?? ""))
.map((entry) => normalizeRunId(entry.databaseId))
.find((id): id is string => id !== undefined);
}
function listWorkflowDispatchRuns(repo: string, workflow: string): WorkflowRunListEntry[] {
return JSON.parse(
run(
"gh",
[
"run",
"list",
"--repo",
repo,
"--workflow",
workflow,
"--event",
"workflow_dispatch",
"--limit",
"50",
"--json",
"databaseId,createdAt",
],
{ capture: true },
),
) as WorkflowRunListEntry[];
}
async function findDispatchedWorkflowRunId(params: {
beforeIds: ReadonlySet<string>;
repo: string;
workflow: string;
}): Promise<string> {
for (let attempt = 0; attempt < 60; attempt++) {
const runId = selectNewestDispatchedRunId({
beforeIds: params.beforeIds,
runs: listWorkflowDispatchRuns(params.repo, params.workflow),
});
if (runId) {
return runId;
}
await new Promise((resolve) => setTimeout(resolve, 5_000));
}
throw new Error(`could not find dispatched run for ${params.workflow}`);
}
async function dispatchTelegram(options: Options, packageSpec: string): Promise<string> {
const beforeIds = new Set(
listWorkflowDispatchRuns(options.repo, TELEGRAM_BETA_WORKFLOW_FILE)
.map((entry) => normalizeRunId(entry.databaseId))
.filter((id): id is string => id !== undefined),
);
const output = run(
"gh",
[
"workflow",
"run",
TELEGRAM_BETA_WORKFLOW_FILE,
"--repo",
options.repo,
"--ref",
options.ref,
"-f",
`package_spec=${packageSpec}`,
"-f",
`package_label=${packageSpec}`,
"-f",
`provider_mode=${options.providerMode}`,
],
{ capture: true },
);
const runId = parseWorkflowRunIdFromOutput(output);
if (runId) {
return runId;
}
return await findDispatchedWorkflowRunId({
beforeIds,
repo: options.repo,
workflow: TELEGRAM_BETA_WORKFLOW_FILE,
});
}
async function pollRun(repo: string, runId: string): Promise<void> {
for (;;) {
const info = ghJson(repo, `actions/runs/${runId}`) as {
conclusion: string | null;
html_url: string;
status: string;
updated_at: string;
};
console.log(
`Telegram workflow ${runId}: ${info.status}${info.conclusion ? `/${info.conclusion}` : ""} updated=${info.updated_at}`,
);
if (info.status === "completed") {
if (info.conclusion !== "success") {
throw new Error(
`Telegram workflow failed: ${info.conclusion ?? "unknown"} ${info.html_url}`,
);
}
console.log(info.html_url);
return;
}
await new Promise((resolve) => setTimeout(resolve, 30_000));
}
}
function downloadTelegramArtifact(repo: string, runId: string): string {
const artifacts = (
ghJson(repo, `actions/runs/${runId}/artifacts`) as {
artifacts: Array<{ expired: boolean; name: string }>;
}
).artifacts;
const artifact = artifacts.find(
(entry) => !entry.expired && entry.name.startsWith(`npm-telegram-beta-e2e-${runId}-`),
);
if (!artifact) {
throw new Error(`no npm Telegram artifact found for run ${runId}`);
}
const outputDir = path.join(".artifacts", "qa-e2e", artifact.name);
mkdirSync(outputDir, { recursive: true });
run("gh", [
"run",
"download",
runId,
"--repo",
repo,
"--name",
artifact.name,
"--dir",
outputDir,
]);
return outputDir;
}
function findFile(root: string, basename: string): string {
for (const entry of readdirSync(root, { withFileTypes: true })) {
const filePath = path.join(root, entry.name);
if (entry.isFile() && entry.name === basename) {
return filePath;
}
if (entry.isDirectory()) {
const nested = findFile(filePath, basename);
if (nested) {
return nested;
}
}
}
return "";
}
async function main(): Promise<void> {
const options = parseArgs(process.argv.slice(2));
const version = resolveBetaVersion(options.beta);
const packageSpec = `openclaw@${version}`;
console.log(`Resolved beta target: ${packageSpec}`);
if (!options.skipParallels) {
runParallels(options.beta, options.model);
}
if (!options.skipTelegram) {
const runId = await dispatchTelegram(options, packageSpec);
await pollRun(options.repo, runId);
const artifactDir = downloadTelegramArtifact(options.repo, runId);
const report = findFile(artifactDir, "telegram-qa-report.md");
if (report && existsSync(report)) {
console.log(`\nTelegram report: ${report}\n`);
console.log(readFileSync(report, "utf8"));
}
}
}
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
await main().catch((error: unknown) => {
console.error(error instanceof Error ? error.message : String(error));
process.exit(1);
});
}

View File

@@ -889,4 +889,14 @@ describe("resolveCliNoOutputTimeoutMs", () => {
});
expect(timeoutMs).toBe(42_000);
});
it("lets explicit cron timeouts lift the default resume no-output ceiling", () => {
const timeoutMs = resolveCliNoOutputTimeoutMs({
backend: { command: "codex" },
timeoutMs: 600_000,
useResume: true,
trigger: "cron",
});
expect(timeoutMs).toBe(480_000);
});
});

View File

@@ -383,6 +383,7 @@ export async function executePreparedCliRun(
backend,
timeoutMs: params.timeoutMs,
useResume,
trigger: params.trigger,
});
const hasJsonlOutput = backend.output === "jsonl";
if (shouldUseClaudeLiveSession(context)) {

View File

@@ -6,20 +6,27 @@ import {
CLI_RESUME_WATCHDOG_DEFAULTS,
CLI_WATCHDOG_MIN_TIMEOUT_MS,
} from "../cli-watchdog-defaults.js";
import type { EmbeddedRunTrigger } from "../pi-embedded-runner/run/params.js";
function pickWatchdogProfile(
backend: CliBackendConfig,
useResume: boolean,
trigger?: EmbeddedRunTrigger,
): {
noOutputTimeoutMs?: number;
noOutputTimeoutRatio: number;
minMs: number;
maxMs: number;
} {
const defaults = useResume ? CLI_RESUME_WATCHDOG_DEFAULTS : CLI_FRESH_WATCHDOG_DEFAULTS;
const configured = useResume
? backend.reliability?.watchdog?.resume
: backend.reliability?.watchdog?.fresh;
const defaults =
trigger === "cron" && useResume && !configured
? CLI_FRESH_WATCHDOG_DEFAULTS
: useResume
? CLI_RESUME_WATCHDOG_DEFAULTS
: CLI_FRESH_WATCHDOG_DEFAULTS;
const ratio = (() => {
const value = configured?.noOutputTimeoutRatio;
@@ -59,8 +66,9 @@ export function resolveCliNoOutputTimeoutMs(params: {
backend: CliBackendConfig;
timeoutMs: number;
useResume: boolean;
trigger?: EmbeddedRunTrigger;
}): number {
const profile = pickWatchdogProfile(params.backend, params.useResume);
const profile = pickWatchdogProfile(params.backend, params.useResume, params.trigger);
// Keep watchdog below global timeout in normal cases.
const cap = Math.max(CLI_WATCHDOG_MIN_TIMEOUT_MS, params.timeoutMs - 1_000);
if (profile.noOutputTimeoutMs !== undefined) {

View File

@@ -34,6 +34,10 @@ describe("resolveLlmIdleTimeoutMs", () => {
expect(resolveLlmIdleTimeoutMs({ runTimeoutMs: 30_000 })).toBe(30_000);
});
it("honors explicit cron run timeouts as the idle watchdog ceiling", () => {
expect(resolveLlmIdleTimeoutMs({ trigger: "cron", runTimeoutMs: 600_000 })).toBe(600_000);
});
it("disables the idle watchdog when an explicit run timeout disables timeouts", () => {
expect(resolveLlmIdleTimeoutMs({ runTimeoutMs: 2_147_000_000 })).toBe(0);
});

View File

@@ -138,6 +138,9 @@ export function resolveLlmIdleTimeoutMs(params?: {
}
if (typeof runTimeoutMs === "number" && Number.isFinite(runTimeoutMs) && runTimeoutMs > 0) {
if (params?.trigger === "cron") {
return clampTimeoutMs(runTimeoutMs);
}
return clampImplicitTimeoutMs(runTimeoutMs);
}

View File

@@ -930,6 +930,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -965,6 +969,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -2368,6 +2376,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -2403,6 +2415,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -3621,6 +3637,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Discord Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview message (default: true). Set false to hide interim tool updates while the draft preview stays active.",
},
"streaming.preview.commandText": {
label: "Discord Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.progress.label": {
label: "Discord Progress Label",
help: 'Initial progress draft title. Use "auto" for built-in single-word labels, a custom string, or false to hide the title.',
@@ -3637,6 +3657,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Discord Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Discord Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"retry.attempts": {
label: "Discord Retry Attempts",
help: "Max retry attempts for outbound Discord API calls (default: 3).",
@@ -8040,6 +8064,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Matrix Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Matrix Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
},
},
{
@@ -8882,10 +8910,18 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Mattermost Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Mattermost Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.preview.toolProgress": {
label: "Mattermost Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview post (default: true). Set false to hide interim tool updates while the draft preview stays active.",
},
"streaming.preview.commandText": {
label: "Mattermost Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.block.enabled": {
label: "Mattermost Block Streaming Enabled",
help: 'Enable chunked block-style Mattermost preview delivery when channels.mattermost.streaming.mode="block".',
@@ -9119,6 +9155,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -9154,6 +9194,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -9526,6 +9570,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "MS Teams Progress Tool Lines",
help: "Show compact tool/progress lines in progress mode (default: true). Set false to keep only the title until final delivery.",
},
"streaming.progress.commandText": {
label: "MS Teams Progress Command Text",
help: 'Command/exec detail in progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
},
},
{
@@ -12349,6 +12397,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -12384,6 +12436,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -13315,6 +13371,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -13350,6 +13410,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -13906,6 +13970,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Slack Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview message (default: true). Set false to hide interim tool updates while the draft preview stays active.",
},
"streaming.preview.commandText": {
label: "Slack Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.progress.label": {
label: "Slack Progress Label",
help: 'Initial progress draft title. Use "auto" for built-in single-word labels, a custom string, or false to hide the title.',
@@ -13926,6 +13994,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Slack Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Slack Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"thread.historyScope": {
label: "Slack Thread History Scope",
help: 'Scope for Slack thread history context ("thread" isolates per thread; "channel" reuses channel history).',
@@ -14690,6 +14762,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -14725,6 +14801,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -15794,6 +15874,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -15829,6 +15913,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
toolProgress: {
type: "boolean",
},
commandText: {
type: "string",
enum: ["raw", "status"],
},
},
additionalProperties: false,
},
@@ -16257,6 +16345,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Telegram Draft Tool Progress",
help: "Show tool/progress activity in the live draft preview message (default: true when preview streaming is active). Set false to keep tool updates out of the edited Telegram preview.",
},
"streaming.preview.commandText": {
label: "Telegram Draft Command Text",
help: 'Command/exec detail in preview tool-progress lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"streaming.progress.label": {
label: "Telegram Progress Label",
help: 'Initial progress draft title. Use "auto" for built-in single-word labels, a custom string, or false to hide the title.',
@@ -16273,6 +16365,10 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
label: "Telegram Progress Tool Lines",
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
},
"streaming.progress.commandText": {
label: "Telegram Progress Command Text",
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',
},
"retry.attempts": {
label: "Telegram Retry Attempts",
help: "Max retry attempts for outbound Telegram API calls (default: 3).",

View File

@@ -10,6 +10,7 @@ export type DmPolicy = "pairing" | "allowlist" | "open" | "disabled";
export type ContextVisibilityMode = "all" | "allowlist" | "allowlist_quote";
export type TextChunkMode = "length" | "newline";
export type StreamingMode = "off" | "partial" | "block" | "progress";
export type ChannelStreamingCommandTextMode = "raw" | "status";
export type OutboundRetryConfig = {
/** Max retry attempts for outbound requests (default: 3). */
@@ -45,6 +46,8 @@ export type ChannelStreamingProgressConfig = {
render?: "text" | "rich";
/** Include compact tool/task progress in the draft. Default: true. */
toolProgress?: boolean;
/** Command/exec progress detail in the draft. "raw" preserves released behavior; "status" shows only the tool label. Default: "raw". */
commandText?: ChannelStreamingCommandTextMode;
};
export type ChannelStreamingPreviewConfig = {
@@ -56,6 +59,8 @@ export type ChannelStreamingPreviewConfig = {
* Default: true.
*/
toolProgress?: boolean;
/** Command/exec progress detail in the preview. "raw" preserves released behavior; "status" shows only the tool label. Default: "raw". */
commandText?: ChannelStreamingCommandTextMode;
};
export type ChannelStreamingBlockConfig = {

View File

@@ -84,6 +84,7 @@ const ChannelStreamingPreviewSchema = z
.object({
chunk: BlockStreamingChunkSchema.optional(),
toolProgress: z.boolean().optional(),
commandText: z.enum(["raw", "status"]).optional(),
})
.strict();
const ChannelStreamingProgressSchema = z
@@ -93,6 +94,7 @@ const ChannelStreamingProgressSchema = z
maxLines: z.number().int().positive().optional(),
render: z.enum(["text", "rich"]).optional(),
toolProgress: z.boolean().optional(),
commandText: z.enum(["raw", "status"]).optional(),
})
.strict();
const ChannelPreviewStreamingConfigSchema = z

View File

@@ -1201,7 +1201,7 @@ describe("agent event handler", () => {
);
});
it("strips tool output when verbose is on", () => {
it("keeps tool output for Control UI recipients when verbose is on", () => {
const { broadcastToConnIds, toolEventRecipients, handler } = createHarness({
resolveSessionKeyForRun: () => "session-1",
});
@@ -1225,8 +1225,8 @@ describe("agent event handler", () => {
expect(broadcastToConnIds).toHaveBeenCalledTimes(1);
const payload = broadcastToConnIds.mock.calls[0]?.[1] as { data?: Record<string, unknown> };
expect(payload.data?.result).toBeUndefined();
expect(payload.data?.partialResult).toBeUndefined();
expect(payload.data?.result).toEqual({ content: [{ type: "text", text: "secret" }] });
expect(payload.data?.partialResult).toEqual({ content: [{ type: "text", text: "partial" }] });
resetAgentRunContextForTest();
});

View File

@@ -613,8 +613,9 @@ export function createAgentEventHandler({
const isToolEvent = evt.stream === "tool";
const isItemEvent = evt.stream === "item";
const toolVerbose = isToolEvent ? resolveToolVerboseLevel(evt.runId, sessionKey) : "off";
// Build tool payload: strip result/partialResult unless verbose=full
const toolPayload =
// Channel/node subscribers respect verbose; authenticated Control UI
// recipients need tool result payloads to render live tool cards.
const channelToolPayload =
isToolEvent && toolVerbose !== "full"
? (() => {
const data = evt.data ? { ...evt.data } : {};
@@ -655,7 +656,7 @@ export function createAgentEventHandler({
if (isControlUiVisible && recipients && recipients.size > 0) {
broadcastToConnIds(
"agent",
sessionKey ? { ...toolPayload, ...buildSessionEventSnapshot(sessionKey) } : toolPayload,
sessionKey ? { ...agentPayload, ...buildSessionEventSnapshot(sessionKey) } : agentPayload,
recipients,
);
}
@@ -669,7 +670,7 @@ export function createAgentEventHandler({
if (sessionSubscribers.size > 0) {
broadcastToConnIds(
"session.tool",
{ ...toolPayload, ...buildSessionEventSnapshot(sessionKey) },
{ ...agentPayload, ...buildSessionEventSnapshot(sessionKey) },
sessionSubscribers,
{ dropIfSlow: true },
);
@@ -692,7 +693,9 @@ export function createAgentEventHandler({
nodeSendToSession(
sessionKey,
"agent",
isToolEvent ? { ...toolPayload, ...buildSessionEventSnapshot(sessionKey) } : agentPayload,
isToolEvent
? { ...channelToolPayload, ...buildSessionEventSnapshot(sessionKey) }
: agentPayload,
);
}
if (

View File

@@ -92,6 +92,49 @@ describe("openclaw channel mcp server", () => {
describe("gateway-backed flows", () => {
describe("gateway integration", () => {
test("returns conversation and message payloads in primary MCP content", async () => {
const sessionKey = "agent:main:telegram:direct:123";
const mcp = await connectMcpWithoutGateway({ claudeChannelMode: "off" });
try {
const gatewayRequest = vi.fn(async (method: string) => {
if (method === "sessions.list") {
return {
sessions: [
{
key: sessionKey,
deliveryContext: { channel: "telegram", to: "123" },
lastMessagePreview: "hello",
},
],
};
}
if (method === "sessions.get") {
return {
messages: [{ id: "msg-1", role: "assistant", content: "hello from transcript" }],
};
}
throw new Error(`unexpected gateway method ${method}`);
});
attachReadyGateway(mcp.bridge, gatewayRequest);
const conversations = (await mcp.client.callTool({
name: "conversations_list",
arguments: {},
})) as { content?: Array<{ type: string; text?: string }> };
expect(conversations.content?.[0]?.text).toContain(`"sessionKey": "${sessionKey}"`);
expect(conversations.content?.[0]?.text).toContain(`"lastMessagePreview": "hello"`);
const messages = (await mcp.client.callTool({
name: "messages_read",
arguments: { session_key: sessionKey },
})) as { content?: Array<{ type: string; text?: string }> };
expect(messages.content?.[0]?.text).toContain(`"id": "msg-1"`);
expect(messages.content?.[0]?.text).toContain("hello from transcript");
} finally {
await mcp.close();
}
});
test("lists conversations and reads messages", async () => {
const sessionKey = "agent:main:main";
const gatewayRequest = vi.fn(async (method: string) => {

View File

@@ -176,7 +176,9 @@ describe("loadWebMedia", () => {
throw new Error("should not optimize png");
}),
resizeToJpeg: vi.fn(async () => {
throw new Error("should not resize jpeg");
throw new Error(
"Optional dependency sharp is required for image attachment processing | Cannot find package 'sharp' imported from image-ops.js",
);
}),
}));
try {
@@ -210,6 +212,17 @@ describe("loadWebMedia", () => {
});
});
it("does not send original HEIC media when optional sharp conversion is unavailable", async () => {
await withUnavailableImageOptimizer(async () => {
const heicFile = path.join(fixtureRoot, "photo.heic");
await fs.writeFile(heicFile, Buffer.from("heic-source"));
const { loadWebMedia: loadWebMediaWithMissingOptimizer } = await import("./web-media.js");
await expect(
loadWebMediaWithMissingOptimizer(heicFile, createLocalWebMediaOptions()),
).rejects.toThrow(/Optional dependency sharp is required/);
});
});
it("resolves relative local media paths against the provided workspace directory", async () => {
const result = await loadWebMedia("chart.png", {
maxBytes: 1024 * 1024,

View File

@@ -413,7 +413,11 @@ async function loadWebMediaInternal(
try {
optimized = await optimizeImageWithFallback({ buffer, cap, meta });
} catch (err) {
if (isOptionalImageOptimizerUnavailable(err) && buffer.length <= cap) {
if (
isOptionalImageOptimizerUnavailable(err) &&
!isHeicSource(meta ?? {}) &&
buffer.length <= cap
) {
if (shouldLogVerbose()) {
logVerbose(
`Image optimizer unavailable; sending original ${formatMb(buffer.length)}MB media without optimization`,

View File

@@ -421,6 +421,9 @@ describe("loadBundledEntryExportSync", () => {
});
it("can disable source-tree fallback for dist bundled entry checks", () => {
stubPluginModuleLoaderJitiFactory(
vi.fn(() => vi.fn(() => ({ sentinel: 42 }))) as unknown as PluginModuleLoaderFactory,
);
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-channel-entry-contract-"));
tempDirs.push(tempRoot);

View File

@@ -4,6 +4,7 @@ import {
createChannelProgressDraftGate,
DEFAULT_PROGRESS_DRAFT_LABELS,
formatChannelProgressDraftLine,
formatChannelProgressDraftLineForEntry,
formatChannelProgressDraftText,
getChannelStreamingConfigObject,
isChannelProgressDraftWorkToolName,
@@ -15,6 +16,7 @@ import {
resolveChannelStreamingBlockEnabled,
resolveChannelStreamingChunkMode,
resolveChannelStreamingNativeTransport,
resolveChannelStreamingPreviewCommandText,
resolveChannelStreamingPreviewChunk,
resolveChannelStreamingSuppressDefaultToolProgressMessages,
resolveChannelStreamingPreviewToolProgress,
@@ -37,6 +39,7 @@ describe("channel-streaming", () => {
preview: {
chunk: { minChars: 10, maxChars: 20, breakPreference: "sentence" },
toolProgress: false,
commandText: "status",
},
},
chunkMode: "length",
@@ -61,6 +64,7 @@ describe("channel-streaming", () => {
breakPreference: "sentence",
});
expect(resolveChannelStreamingPreviewToolProgress(entry)).toBe(false);
expect(resolveChannelStreamingPreviewCommandText(entry)).toBe("status");
});
it("keeps progress-only tool progress config out of normal preview modes", () => {
@@ -293,6 +297,46 @@ describe("channel-streaming", () => {
{ detailMode: "raw" },
),
).toBe("🛠️ Exec: run tests, `pnpm test -- --watch=false`");
expect(
formatChannelProgressDraftLine({
event: "item",
itemKind: "command",
name: "exec",
progressText: "raw command output",
}),
).toBe("🛠️ Exec: raw command output");
expect(
formatChannelProgressDraftLine(
{
event: "item",
itemKind: "command",
name: "exec",
progressText: "raw command output",
},
{ commandText: "status" },
),
).toBe("🛠️ Exec");
expect(
formatChannelProgressDraftLine(
{
event: "tool",
name: "exec",
args: { command: "pnpm test" },
},
{ detailMode: "raw", commandText: "status" },
),
).toBe("🛠️ Exec");
expect(
formatChannelProgressDraftLineForEntry(
{ streaming: { preview: { commandText: "status" } } },
{
event: "item",
itemKind: "command",
name: "exec",
progressText: "raw command output",
},
),
).toBe("🛠️ Exec");
});
it("starts progress drafts after five seconds or a second work event", async () => {

View File

@@ -5,6 +5,7 @@ import type {
BlockStreamingCoalesceConfig,
ChannelDeliveryStreamingConfig,
ChannelPreviewStreamingConfig,
ChannelStreamingCommandTextMode,
ChannelStreamingProgressConfig,
ChannelStreamingConfig,
SlackChannelStreamingConfig,
@@ -17,6 +18,7 @@ export type {
ChannelDeliveryStreamingConfig,
ChannelPreviewStreamingConfig,
ChannelStreamingBlockConfig,
ChannelStreamingCommandTextMode,
ChannelStreamingConfig,
ChannelStreamingProgressConfig,
ChannelStreamingPreviewConfig,
@@ -86,6 +88,10 @@ function asProgressConfig(value: unknown): ChannelStreamingProgressConfig | unde
return asObjectRecord(value) as ChannelStreamingProgressConfig | undefined;
}
function asCommandTextMode(value: unknown): ChannelStreamingCommandTextMode | undefined {
return value === "raw" || value === "status" ? value : undefined;
}
export const DEFAULT_PROGRESS_DRAFT_LABELS = [
"Thinking...",
"Shelling...",
@@ -127,9 +133,10 @@ export function isChannelProgressDraftWorkToolName(name: string | null | undefin
return Boolean(normalized && !NON_WORK_PROGRESS_TOOL_NAMES.has(normalized));
}
type ChannelProgressLineOptions = {
export type ChannelProgressLineOptions = {
markdown?: boolean;
detailMode?: "explain" | "raw";
commandText?: ChannelStreamingCommandTextMode;
};
export type ChannelProgressDraftRenderMode = "text" | "rich";
@@ -258,6 +265,16 @@ function itemKindToToolName(kind: string | undefined): string | undefined {
}
}
function isCommandToolName(name: string | undefined): boolean {
const normalized = normalizeOptionalLowercaseString(name);
return normalized === "exec" || normalized === "shell" || normalized === "bash";
}
function isCommandProgressItem(input: Extract<ChannelProgressDraftLineInput, { event: "item" }>) {
const itemKind = normalizeOptionalLowercaseString(input.itemKind);
return itemKind === "command" || isCommandToolName(input.name);
}
function patchMetas(input: Extract<ChannelProgressDraftLineInput, { event: "patch" }>): string[] {
const fileMetas = [...(input.added ?? []), ...(input.modified ?? []), ...(input.deleted ?? [])];
return compactStrings([input.summary, ...fileMetas, input.title]);
@@ -267,6 +284,42 @@ function shouldPrefixProgressLine(line: string): boolean {
return !EMOJI_PREFIX_RE.test(line);
}
export function formatChannelProgressDraftLine(
input: ChannelProgressDraftLineInput,
options?: ChannelProgressLineOptions,
): string | undefined {
return buildChannelProgressDraftLine(input, options)?.text;
}
export function resolveChannelProgressDraftLineOptions(
entry: StreamingCompatEntry | null | undefined,
options?: ChannelProgressLineOptions,
): ChannelProgressLineOptions {
return {
...options,
commandText: options?.commandText ?? resolveChannelStreamingPreviewCommandText(entry),
};
}
export function buildChannelProgressDraftLineForEntry(
entry: StreamingCompatEntry | null | undefined,
input: ChannelProgressDraftLineInput,
options?: ChannelProgressLineOptions,
): ChannelProgressDraftLine | undefined {
return buildChannelProgressDraftLine(
input,
resolveChannelProgressDraftLineOptions(entry, options),
);
}
export function formatChannelProgressDraftLineForEntry(
entry: StreamingCompatEntry | null | undefined,
input: ChannelProgressDraftLineInput,
options?: ChannelProgressLineOptions,
): string | undefined {
return buildChannelProgressDraftLineForEntry(entry, input, options)?.text;
}
export function buildChannelProgressDraftLine(
input: ChannelProgressDraftLineInput,
options?: ChannelProgressLineOptions,
@@ -277,7 +330,9 @@ export function buildChannelProgressDraftLine(
input.event,
input.name,
[
inferToolMeta(input.name, input.args, options?.detailMode),
options?.commandText === "status" && isCommandToolName(input.name)
? undefined
: inferToolMeta(input.name, input.args, options?.detailMode),
input.phase && !input.name ? input.phase : undefined,
],
options,
@@ -285,7 +340,12 @@ export function buildChannelProgressDraftLine(
}
case "item": {
const name = input.name ?? itemKindToToolName(input.itemKind);
const meta = input.meta ?? input.progressText ?? input.summary;
const meta =
input.meta ??
input.summary ??
(options?.commandText === "status" && isCommandProgressItem(input)
? undefined
: input.progressText);
if (name) {
return buildNamedProgressLine(input.event, name, [meta], options, {
status: input.status,
@@ -339,9 +399,7 @@ export function buildChannelProgressDraftLine(
input.name ?? "exec",
[status, input.title],
options,
{
status,
},
{ status },
);
}
case "patch": {
@@ -359,13 +417,6 @@ export function buildChannelProgressDraftLine(
return undefined;
}
export function formatChannelProgressDraftLine(
input: ChannelProgressDraftLineInput,
options?: ChannelProgressLineOptions,
): string | undefined {
return buildChannelProgressDraftLine(input, options)?.text;
}
export function createChannelProgressDraftGate(params: {
onStart: () => void | Promise<void>;
initialDelayMs?: number;
@@ -498,6 +549,18 @@ export function resolveChannelStreamingPreviewToolProgress(
return asBoolean(config?.preview?.toolProgress) ?? defaultValue;
}
export function resolveChannelStreamingPreviewCommandText(
entry: StreamingCompatEntry | null | undefined,
defaultValue: ChannelStreamingCommandTextMode = "raw",
): ChannelStreamingCommandTextMode {
const config = getChannelStreamingConfigObject(entry);
return (
asCommandTextMode(config?.progress?.commandText) ??
asCommandTextMode(config?.preview?.commandText) ??
defaultValue
);
}
export function resolveChannelStreamingSuppressDefaultToolProgressMessages(
entry: StreamingCompatEntry | null | undefined,
options?: {

View File

@@ -140,7 +140,7 @@ function createCircularPluginFixture(prefix: string): TrustedBundledPluginFixtur
);
fs.writeFileSync(
path.join(pluginRoot, "helper.js"),
['import { marker } from "../facade.mjs";', "export const circularMarker = marker;", ""].join(
['import { marker } from "./facade.mjs";', "export const circularMarker = marker;", ""].join(
"\n",
),
"utf8",

View File

@@ -99,7 +99,6 @@ import {
restoreMemoryPluginState,
} from "./memory-state.js";
import { unwrapDefaultModuleExport } from "./module-export.js";
import { tryNativeRequireJavaScriptModule } from "./native-module-require.js";
import {
fingerprintPluginDiscoveryContext,
resolvePluginDiscoveryContext,
@@ -107,7 +106,7 @@ import {
import { withProfile } from "./plugin-load-profile.js";
import {
createPluginModuleLoaderCache,
getCachedPluginSourceModuleLoader,
getCachedPluginModuleLoader,
type PluginModuleLoaderCache,
} from "./plugin-module-loader-cache.js";
import type { PluginOrigin } from "./plugin-origin.types.js";
@@ -480,8 +479,8 @@ function runPluginRegisterSync(
function createPluginModuleLoader(options: Pick<PluginLoadOptions, "pluginSdkResolution">) {
const moduleLoaders: PluginModuleLoaderCache = createPluginModuleLoaderCache();
const loadSourceModule = (modulePath: string) => {
return getCachedPluginSourceModuleLoader({
const createLoaderForModule = (modulePath: string) => {
return getCachedPluginModuleLoader({
cache: moduleLoaders,
modulePath,
importerUrl: import.meta.url,
@@ -495,18 +494,8 @@ function createPluginModuleLoader(options: Pick<PluginLoadOptions, "pluginSdkRes
pluginSdkResolution: options.pluginSdkResolution,
});
};
return (modulePath: string): unknown => {
if (shouldPreferNativeModuleLoad(modulePath)) {
const native = tryNativeRequireJavaScriptModule(modulePath, { allowWindows: true });
if (native.ok) {
return native.moduleExport;
}
}
// Source .ts runtime shims import sibling ".js" specifiers that only exist
// after build. Jiti remains the dev/source fallback because it rewrites those
// imports against the source graph and applies SDK aliases.
return loadSourceModule(modulePath)(toSafeImportPath(modulePath));
};
return (modulePath: string): unknown =>
createLoaderForModule(modulePath)(toSafeImportPath(modulePath));
}
function resolveCanonicalDistRuntimeSource(source: string): string {

View File

@@ -432,6 +432,40 @@ describe("loadPluginManifestRegistry", () => {
expect(channelConfigWarnings).toHaveLength(1);
});
it("suppresses missing channel config diagnostics for inactive external channel plugins", () => {
const dir = makeTempDir();
writeManifest(dir, {
id: "external-chat",
channels: ["external-chat"],
configSchema: { type: "object" },
});
const candidate = createPluginCandidate({
idHint: "external-chat",
rootDir: dir,
origin: "global",
});
const disabledRegistry = loadPluginManifestRegistry({
config: { plugins: { entries: { "external-chat": { enabled: false } } } },
candidates: [candidate],
});
expect(
disabledRegistry.diagnostics.some((diagnostic) =>
diagnostic.message.includes("without channelConfigs metadata"),
),
).toBe(false);
const allowlistRegistry = loadPluginManifestRegistry({
config: { plugins: { allow: ["other-plugin"] } },
candidates: [candidate],
});
expect(
allowlistRegistry.diagnostics.some((diagnostic) =>
diagnostic.message.includes("without channelConfigs metadata"),
),
).toBe(false);
});
it("suppresses duplicate warnings for explicit installed globals overriding bundled plugins", () => {
const bundledDir = makeTempDir();
const globalDir = makeTempDir();

View File

@@ -568,10 +568,20 @@ function pushProviderAuthEnvVarsCompatDiagnostic(params: {
function pushNonBundledChannelConfigDescriptorDiagnostic(params: {
record: PluginManifestRecord;
diagnostics: PluginDiagnostic[];
normalized?: ReturnType<typeof normalizePluginsConfigWithResolver>;
}): void {
if (params.record.origin === "bundled" || params.record.format === "bundle") {
return;
}
const configuredEntry = params.normalized?.entries[params.record.id];
if (
params.normalized?.enabled === false ||
configuredEntry?.enabled === false ||
params.normalized?.deny.includes(params.record.id) ||
(params.normalized?.allow.length && !params.normalized.allow.includes(params.record.id))
) {
return;
}
const declaredChannels = params.record.channels
.map((channelId) => channelId.trim())
.filter((channelId) => channelId.length > 0);
@@ -597,6 +607,7 @@ function pushNonBundledChannelConfigDescriptorDiagnostic(params: {
function pushManifestCompatibilityDiagnostics(params: {
record: PluginManifestRecord;
diagnostics: PluginDiagnostic[];
normalized?: ReturnType<typeof normalizePluginsConfigWithResolver>;
}): void {
pushProviderAuthEnvVarsCompatDiagnostic(params);
pushNonBundledChannelConfigDescriptorDiagnostic(params);
@@ -856,7 +867,7 @@ export function loadPluginManifestRegistry(
if (PLUGIN_ORIGIN_RANK[candidate.origin] < PLUGIN_ORIGIN_RANK[existing.candidate.origin]) {
records[existing.recordIndex] = record;
seenIds.set(manifest.id, { candidate, recordIndex: existing.recordIndex });
pushManifestCompatibilityDiagnostics({ record, diagnostics });
pushManifestCompatibilityDiagnostics({ record, diagnostics, normalized });
}
continue;
}
@@ -881,7 +892,7 @@ export function loadPluginManifestRegistry(
if (candidateWins) {
records[existing.recordIndex] = record;
seenIds.set(manifest.id, { candidate, recordIndex: existing.recordIndex });
pushManifestCompatibilityDiagnostics({ record, diagnostics });
pushManifestCompatibilityDiagnostics({ record, diagnostics, normalized });
}
if (
isIntentionalInstalledBundledDuplicate({
@@ -909,7 +920,7 @@ export function loadPluginManifestRegistry(
seenIds.set(manifest.id, { candidate, recordIndex: records.length });
records.push(record);
pushManifestCompatibilityDiagnostics({ record, diagnostics });
pushManifestCompatibilityDiagnostics({ record, diagnostics, normalized });
}
const registry = { plugins: records, diagnostics: dedupePluginDiagnostics(diagnostics) };

View File

@@ -1,3 +1,4 @@
import fs from "node:fs";
import { createRequire } from "node:module";
import type { createJiti } from "jiti";
import { toSafeImportPath } from "../shared/import-specifier.js";
@@ -47,6 +48,8 @@ export type PluginModuleLoaderStatsSnapshot = {
const DEFAULT_PLUGIN_MODULE_LOADER_CACHE_ENTRIES = 128;
const MAX_TRACKED_SOURCE_TRANSFORM_TARGETS = 24;
const JITI_FACTORY_OVERRIDE_KEY = Symbol.for("openclaw.pluginModuleLoaderJitiFactoryOverride");
const PLUGIN_SDK_IMPORT_SPECIFIER_PATTERN =
/(?:\bfrom\s*["']|\bimport\s*\(\s*["']|\brequire\s*\(\s*["'])(?:openclaw|@openclaw)\/plugin-sdk(?:\/[^"']*)?["']/u;
const requireForJiti = createRequire(import.meta.url);
let createJitiLoaderFactory: PluginModuleLoaderFactory | undefined;
const pluginModuleLoaderStats = {
@@ -213,6 +216,29 @@ function createLazySourceTransformLoader(params: {
};
}
function shouldForceSourceTransformForPluginSdkAlias(params: {
target: string;
aliasMap: Record<string, string>;
}): boolean {
if (
!params.aliasMap["openclaw/plugin-sdk"] &&
!params.aliasMap["@openclaw/plugin-sdk"] &&
!Object.keys(params.aliasMap).some(
(key) => key.startsWith("openclaw/plugin-sdk/") || key.startsWith("@openclaw/plugin-sdk/"),
)
) {
return false;
}
if (!/\.[cm]?js$/iu.test(params.target)) {
return false;
}
try {
return PLUGIN_SDK_IMPORT_SPECIFIER_PATTERN.test(fs.readFileSync(params.target, "utf-8"));
} catch {
return false;
}
}
function createPluginModuleLoader(params: {
loaderFilename: string;
aliasMap: Record<string, string>;
@@ -242,8 +268,20 @@ function createPluginModuleLoader(params: {
// for TS / TSX sources and for the small set of require(esm) /
// async-module fallbacks `tryNativeRequireJavaScriptModule` declines to
// handle.
const getLoadWithAliasTransform = createLazySourceTransformLoader({
...params,
tryNative: false,
});
return ((target: string, ...rest: unknown[]) => {
pluginModuleLoaderStats.calls += 1;
if (shouldForceSourceTransformForPluginSdkAlias({ target, aliasMap: params.aliasMap })) {
pluginModuleLoaderStats.sourceTransformForced += 1;
recordSourceTransformTarget(target);
return (getLoadWithAliasTransform() as (t: string, ...a: unknown[]) => unknown)(
target,
...rest,
);
}
const native = tryNativeRequireJavaScriptModule(target, { allowWindows: true });
if (native.ok) {
pluginModuleLoaderStats.nativeHits += 1;

View File

@@ -10,7 +10,8 @@ function writeRuntimeModuleWrapper(sourcePath: string, targetPath: string): void
const relative = `./${path.relative(path.dirname(targetPath), sourcePath).split(path.sep).join("/")}`;
const content = [
`export * from ${JSON.stringify(relative)};`,
`export { default } from ${JSON.stringify(relative)};`,
`import * as moduleExports from ${JSON.stringify(relative)};`,
`export default moduleExports.default ?? moduleExports;`,
"",
].join("\n");
try {

View File

@@ -1,5 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
__setRealtimeVoiceAgentConsultDepsForTest,
consultRealtimeVoiceAgent,
resolveRealtimeVoiceAgentConsultTools,
resolveRealtimeVoiceAgentConsultToolsAllow,
@@ -7,7 +8,17 @@ import {
import { REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME } from "./agent-consult-tool.js";
function createAgentRuntime(payloads: unknown[] = [{ text: "Speak this." }]) {
const sessionStore: Record<string, { sessionId?: string; updatedAt?: number }> = {};
const sessionStore: Record<
string,
{
sessionId?: string;
updatedAt?: number;
sessionFile?: string;
spawnedBy?: string;
forkedFromParent?: boolean;
totalTokens?: number;
}
> = {};
const runEmbeddedPiAgent = vi.fn(async () => ({
payloads,
meta: {},
@@ -31,7 +42,10 @@ function createAgentRuntime(payloads: unknown[] = [{ text: "Speak this." }]) {
loadSessionStore: vi.fn(() => sessionStore),
saveSessionStore: vi.fn(async () => {}),
updateSessionStore,
resolveSessionFilePath: vi.fn(() => "/tmp/session.json"),
resolveSessionFilePath: vi.fn(
(_sessionId: string, entry?: { sessionFile?: string }) =>
entry?.sessionFile ?? "/tmp/session.json",
),
},
runEmbeddedPiAgent,
},
@@ -41,6 +55,10 @@ function createAgentRuntime(payloads: unknown[] = [{ text: "Speak this." }]) {
}
describe("realtime voice agent consult runtime", () => {
afterEach(() => {
__setRealtimeVoiceAgentConsultDepsForTest(null);
});
it("exposes the shared consult tool based on policy", () => {
expect(resolveRealtimeVoiceAgentConsultTools("safe-read-only")).toEqual([
expect.objectContaining({ name: REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME }),
@@ -151,4 +169,67 @@ describe("realtime voice agent consult runtime", () => {
"[realtime-voice] agent consult produced no answer: agent returned no speakable text",
);
});
it("forks requester context when fork mode has a parent session", async () => {
const { runtime, runEmbeddedPiAgent, sessionStore } = createAgentRuntime();
sessionStore["agent:main:main"] = {
sessionId: "parent-session",
sessionFile: "/tmp/parent.jsonl",
totalTokens: 100,
updatedAt: 1,
};
const resolveParentForkDecision = vi.fn(async () => ({
status: "fork" as const,
maxTokens: 100_000,
parentTokens: 100,
}));
const forkSessionFromParent = vi.fn(async () => ({
sessionId: "forked-session",
sessionFile: "/tmp/forked.jsonl",
}));
__setRealtimeVoiceAgentConsultDepsForTest({
resolveParentForkDecision,
forkSessionFromParent,
});
await consultRealtimeVoiceAgent({
cfg: {} as never,
agentRuntime: runtime as never,
logger: { warn: vi.fn() },
agentId: "main",
sessionKey: "agent:main:subagent:google-meet:meet-1",
spawnedBy: "agent:main:main",
contextMode: "fork",
messageProvider: "google-meet",
lane: "google-meet",
runIdPrefix: "google-meet:meet-1",
args: { question: "What should I say?" },
transcript: [],
surface: "a private Google Meet",
userLabel: "Participant",
});
expect(resolveParentForkDecision).toHaveBeenCalledWith({
parentEntry: sessionStore["agent:main:main"],
storePath: "/tmp/sessions.json",
});
expect(forkSessionFromParent).toHaveBeenCalledWith({
parentEntry: sessionStore["agent:main:main"],
agentId: "main",
sessionsDir: "/tmp",
});
expect(sessionStore["agent:main:subagent:google-meet:meet-1"]).toMatchObject({
sessionId: "forked-session",
sessionFile: "/tmp/forked.jsonl",
spawnedBy: "agent:main:main",
forkedFromParent: true,
});
expect(runEmbeddedPiAgent).toHaveBeenCalledWith(
expect.objectContaining({
sessionId: "forked-session",
sessionFile: "/tmp/forked.jsonl",
spawnedBy: "agent:main:main",
}),
);
});
});

View File

@@ -1,8 +1,14 @@
import { randomUUID } from "node:crypto";
import path from "node:path";
import type { RunEmbeddedPiAgentParams } from "../agents/pi-embedded-runner/run/params.js";
import {
forkSessionFromParent,
resolveParentForkDecision,
} from "../auto-reply/reply/session-fork.js";
import type { SessionEntry } from "../config/sessions/types.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import type { RuntimeLogger, PluginRuntimeCore } from "../plugins/runtime/types-core.js";
import { parseAgentSessionKey } from "../routing/session-key.js";
import {
buildRealtimeVoiceAgentConsultPrompt,
collectRealtimeVoiceAgentConsultVisibleText,
@@ -11,11 +17,34 @@ import {
export type RealtimeVoiceAgentConsultRuntime = PluginRuntimeCore["agent"];
export type RealtimeVoiceAgentConsultResult = { text: string };
export type RealtimeVoiceAgentConsultContextMode = "isolated" | "fork";
export {
resolveRealtimeVoiceAgentConsultTools,
resolveRealtimeVoiceAgentConsultToolsAllow,
} from "./agent-consult-tool.js";
type RealtimeVoiceAgentConsultDeps = {
randomUUID: typeof randomUUID;
resolveParentForkDecision: typeof resolveParentForkDecision;
forkSessionFromParent: typeof forkSessionFromParent;
};
const defaultRealtimeVoiceAgentConsultDeps: RealtimeVoiceAgentConsultDeps = {
randomUUID,
resolveParentForkDecision,
forkSessionFromParent,
};
let realtimeVoiceAgentConsultDeps = defaultRealtimeVoiceAgentConsultDeps;
export function __setRealtimeVoiceAgentConsultDepsForTest(
deps: Partial<RealtimeVoiceAgentConsultDeps> | null,
): void {
realtimeVoiceAgentConsultDeps = deps
? { ...defaultRealtimeVoiceAgentConsultDeps, ...deps }
: defaultRealtimeVoiceAgentConsultDeps;
}
function resolveRealtimeVoiceAgentSandboxSessionKey(agentId: string, sessionKey: string): string {
const trimmed = sessionKey.trim();
if (trimmed.toLowerCase().startsWith("agent:")) {
@@ -24,6 +53,73 @@ function resolveRealtimeVoiceAgentSandboxSessionKey(agentId: string, sessionKey:
return `agent:${agentId}:${trimmed}`;
}
async function resolveRealtimeVoiceAgentConsultSessionEntry(params: {
agentId: string;
sessionKey: string;
spawnedBy?: string | null;
contextMode?: RealtimeVoiceAgentConsultContextMode;
storePath: string;
agentRuntime: RealtimeVoiceAgentConsultRuntime;
logger: Pick<RuntimeLogger, "warn">;
}): Promise<SessionEntry> {
const now = Date.now();
return await params.agentRuntime.session.updateSessionStore(params.storePath, async (store) => {
const existing = store[params.sessionKey] as SessionEntry | undefined;
if (existing?.sessionId?.trim()) {
const next: SessionEntry = { ...existing, updatedAt: now };
store[params.sessionKey] = next;
return next;
}
const requesterSessionKey = params.spawnedBy?.trim();
const requesterAgentId = parseAgentSessionKey(requesterSessionKey)?.agentId;
const shouldFork =
params.contextMode === "fork" &&
requesterSessionKey &&
(!requesterAgentId || requesterAgentId === params.agentId);
if (shouldFork) {
const parentEntry = store[requesterSessionKey] as SessionEntry | undefined;
if (parentEntry?.sessionId?.trim()) {
const decision = await realtimeVoiceAgentConsultDeps.resolveParentForkDecision({
parentEntry,
storePath: params.storePath,
});
if (decision.status === "fork") {
const fork = await realtimeVoiceAgentConsultDeps.forkSessionFromParent({
parentEntry,
agentId: params.agentId,
sessionsDir: path.dirname(params.storePath),
});
if (fork) {
const next: SessionEntry = {
...existing,
sessionId: fork.sessionId,
sessionFile: fork.sessionFile,
spawnedBy: requesterSessionKey,
forkedFromParent: true,
updatedAt: now,
};
store[params.sessionKey] = next;
return next;
}
} else {
params.logger.warn(`[realtime-voice] ${decision.message}`);
}
}
}
const next: SessionEntry = {
...existing,
sessionId: realtimeVoiceAgentConsultDeps.randomUUID(),
...(requesterSessionKey ? { spawnedBy: requesterSessionKey } : {}),
updatedAt: now,
};
store[params.sessionKey] = next;
return next;
});
}
export async function consultRealtimeVoiceAgent(params: {
cfg: OpenClawConfig;
agentRuntime: RealtimeVoiceAgentConsultRuntime;
@@ -40,6 +136,7 @@ export async function consultRealtimeVoiceAgent(params: {
questionSourceLabel?: string;
agentId?: string;
spawnedBy?: string | null;
contextMode?: RealtimeVoiceAgentConsultContextMode;
provider?: RunEmbeddedPiAgentParams["provider"];
model?: RunEmbeddedPiAgentParams["model"];
thinkLevel?: RunEmbeddedPiAgentParams["thinkLevel"];
@@ -56,13 +153,14 @@ export async function consultRealtimeVoiceAgent(params: {
const storePath = params.agentRuntime.session.resolveStorePath(params.cfg.session?.store, {
agentId,
});
const now = Date.now();
const sessionEntry = await params.agentRuntime.session.updateSessionStore(storePath, (store) => {
const existing = store[params.sessionKey] as SessionEntry | undefined;
const sessionId = existing?.sessionId?.trim() || randomUUID();
const next: SessionEntry = { ...existing, sessionId, updatedAt: now };
store[params.sessionKey] = next;
return next;
const sessionEntry = await resolveRealtimeVoiceAgentConsultSessionEntry({
agentId,
sessionKey: params.sessionKey,
spawnedBy: params.spawnedBy,
contextMode: params.contextMode,
storePath,
agentRuntime: params.agentRuntime,
logger: params.logger,
});
const sessionId = sessionEntry.sessionId;

View File

@@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest";
import {
parseWorkflowRunIdFromOutput,
selectNewestDispatchedRunId,
} from "../../scripts/release-beta-smoke.ts";
describe("release-beta-smoke", () => {
it("parses workflow run urls when gh includes them in dispatch output", () => {
expect(
parseWorkflowRunIdFromOutput(
"Dispatched: https://github.com/openclaw/openclaw/actions/runs/1234567890",
),
).toBe("1234567890");
});
it("selects the newest workflow_dispatch run not present before dispatch", () => {
const beforeIds = new Set(["100", "101"]);
expect(
selectNewestDispatchedRunId({
beforeIds,
runs: [
{ databaseId: 100, createdAt: "2026-05-04T10:00:00Z" },
{ databaseId: 102, createdAt: "2026-05-04T10:01:00Z" },
{ databaseId: 103, createdAt: "2026-05-04T10:02:00Z" },
],
}),
).toBe("103");
});
});

View File

@@ -29,6 +29,12 @@
margin: 0;
}
.chat-text :where(table) {
display: block;
max-width: 100%;
overflow-x: auto;
}
.chat-text :where(p + p, p + ul, p + ol, p + pre, p + blockquote) {
margin-top: 0.75em;
}

View File

@@ -2763,7 +2763,6 @@ td.data-table-key-col {
white-space: pre-wrap;
overflow: hidden;
display: -webkit-box;
line-clamp: 3;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}