## Problem `dispatchTask()` shells out to `openclaw gateway call sessions.patch` which times out when the gateway is busy, causing: 1. Notifications never fire (they're at the end of dispatchTask) 2. Worker state may not be recorded 3. Workers run silently ## Solution (3 changes) ### 1. Make `ensureSession` fire-and-forget Session key is deterministic, so we don't need to wait for confirmation. Health check catches orphaned state later. ### 2. Use runtime API for notifications instead of CLI Pass `runtime` through opts and use direct API calls: - `runtime.channel.telegram.sendMessageTelegram()` - `runtime.channel.whatsapp.sendMessageWhatsApp()` - etc. ### 3. Move notification before session dispatch Fire workerStart/workerComplete notifications early (after label transition) before the session calls that can timeout. ## Files Changed - lib/dispatch.ts — fire-and-forget ensureSession, early notification, accept runtime - lib/notify.ts — use runtime API for direct channel sends - lib/services/pipeline.ts — early notification, accept runtime - lib/services/tick.ts — pass runtime through to dispatchTask - lib/tool-helpers.ts — accept runtime in tickAndNotify - lib/tools/work-start.ts — pass api.runtime to dispatchTask - lib/tools/work-finish.ts — pass api.runtime to executeCompletion/tickAndNotify
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* Eliminates repeated boilerplate across tools: workspace validation,
|
||||
* project resolution, provider creation.
|
||||
*/
|
||||
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
||||
import type { OpenClawPluginApi, PluginRuntime } from "openclaw/plugin-sdk";
|
||||
import type { ToolContext } from "./types.js";
|
||||
import { readProjects, getProject, type Project, type ProjectsData } from "./projects.js";
|
||||
import { createProvider, type ProviderWithType } from "./providers/index.js";
|
||||
@@ -60,6 +60,8 @@ export async function tickAndNotify(opts: {
|
||||
pluginConfig?: Record<string, unknown>;
|
||||
sessionKey?: string;
|
||||
targetRole?: "dev" | "qa";
|
||||
/** Plugin runtime for direct API access (avoids CLI subprocess timeouts) */
|
||||
runtime?: PluginRuntime;
|
||||
}): Promise<TickAction[]> {
|
||||
try {
|
||||
const result = await projectTick({
|
||||
@@ -69,6 +71,7 @@ export async function tickAndNotify(opts: {
|
||||
pluginConfig: opts.pluginConfig,
|
||||
sessionKey: opts.sessionKey,
|
||||
targetRole: opts.targetRole,
|
||||
runtime: opts.runtime,
|
||||
});
|
||||
return result.pickups;
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user