docs: document channel helper APIs

This commit is contained in:
Peter Steinberger
2026-06-03 21:20:57 -04:00
parent 4cb34f3999
commit 0416117168
3 changed files with 5 additions and 0 deletions
+2
View File
@@ -1,5 +1,6 @@
import { resolveTimerTimeoutMs } from "../shared/number-coercion.js";
/** Throttled draft-stream sender used by channels that edit in-progress replies. */
export type DraftStreamLoop = {
update: (text: string) => void;
flush: () => Promise<void>;
@@ -9,6 +10,7 @@ export type DraftStreamLoop = {
waitForInFlight: () => Promise<void>;
};
/** Creates a single-flight draft stream loop that preserves the newest pending text. */
export function createDraftStreamLoop(params: {
throttleMs: number;
isStopped: () => boolean;
+1
View File
@@ -3,6 +3,7 @@ import { normalizeAccountId } from "../../routing/session-key.js";
const MB = 1024 * 1024;
/** Resolves channel media limit bytes from account-specific config or agent defaults. */
export function resolveChannelMediaMaxBytes(params: {
cfg: OpenClawConfig;
// Channel-specific config lives under different keys; keep this helper generic
+2
View File
@@ -4,6 +4,7 @@ type RunStateStatusPatch = {
lastRunActivityAt?: number | null;
};
/** Status sink used by channel run-state updates. */
export type RunStateStatusSink = (patch: RunStateStatusPatch) => void;
type RunStateMachineParams = {
@@ -15,6 +16,7 @@ type RunStateMachineParams = {
const DEFAULT_RUN_ACTIVITY_HEARTBEAT_MS = 60_000;
/** Creates a channel run-state tracker with heartbeat updates while runs are active. */
export function createRunStateMachine(params: RunStateMachineParams) {
const heartbeatMs = params.heartbeatMs ?? DEFAULT_RUN_ACTIVITY_HEARTBEAT_MS;
const now = params.now ?? Date.now;