mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
docs: document channel helper APIs
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user