docs: document auto-reply dispatch helpers · openclaw/openclaw@9391741
steipete
·
2026-06-04
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Runtime facade for fast abort handling used by reply dispatch. */ |
1 | 2 | export { formatAbortReplyText, tryFastAbortFromMessage } from "./abort.js"; |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import { getRuntimeAuthForModel } from "../../plugins/runtime/runtime-model-auth
|
11 | 11 | const DEFAULT_MAX_LABEL_LENGTH = 128; |
12 | 12 | const TIMEOUT_MS = 15_000; |
13 | 13 | |
| 14 | +/** Inputs for generating a short conversation label from the active model. */ |
14 | 15 | export type ConversationLabelParams = { |
15 | 16 | userMessage: string; |
16 | 17 | prompt: string; |
@@ -38,6 +39,7 @@ function extractSimpleCompletionError(result: {
|
38 | 39 | return result.errorMessage?.trim() || "unknown error"; |
39 | 40 | } |
40 | 41 | |
| 42 | +/** Generates a bounded human-readable label for a session, or null on failure. */ |
41 | 43 | export async function generateConversationLabel( |
42 | 44 | params: ConversationLabelParams, |
43 | 45 | ): Promise<string | null> { |
@@ -70,6 +72,7 @@ export async function generateConversationLabel(
|
70 | 72 | const controller = new AbortController(); |
71 | 73 | const timeout = setTimeout(() => controller.abort(), TIMEOUT_MS); |
72 | 74 | try { |
| 75 | +// Label generation should never block normal reply handling for long. |
73 | 76 | const result = await completeSimple( |
74 | 77 | completionModel, |
75 | 78 | { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Runtime facade for persisting inline directive state after parsing. */ |
1 | 2 | export { persistInlineDirectives } from "./directive-handling.persist.js"; |
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Runtime media-understanding dependencies used by ACP reply dispatch. */ |
1 | 2 | export { applyMediaUnderstanding } from "../../media-understanding/apply.js"; |
2 | 3 | export { MediaAttachmentCache } from "../../media-understanding/attachments.js"; |
3 | 4 | export { normalizeAttachments } from "../../media-understanding/attachments.normalize.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Runtime facade for reading persisted ACP session metadata. */ |
1 | 2 | export { readAcpSessionEntry } from "../../acp/runtime/session-meta.js"; |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import type { GetReplyOptions } from "../get-reply-options.types.js";
|
3 | 3 | import type { ReplyPayload } from "../reply-payload.js"; |
4 | 4 | import type { MsgContext } from "../templating.js"; |
5 | 5 | |
| 6 | +/** Reply resolver signature used by dispatchers and tests for dependency injection. */ |
6 | 7 | export type GetReplyFromConfig = ( |
7 | 8 | ctx: MsgContext, |
8 | 9 | opts?: GetReplyOptions, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce"; |
2 | 2 | |
| 3 | +/** Extracts a simple group/channel id from stable group-like source ids. */ |
3 | 4 | export function extractSimpleExplicitGroupId(raw: string | undefined | null): string | undefined { |
4 | 5 | const trimmed = normalizeOptionalString(raw) ?? ""; |
5 | 6 | if (!trimmed) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import {
|
3 | 3 | normalizeOptionalString, |
4 | 4 | } from "@openclaw/normalization-core/string-coerce"; |
5 | 5 | |
| 6 | +/** Parsed `/plugins` command variants accepted by auto-reply command handling. */ |
6 | 7 | export type PluginsCommand = |
7 | 8 | | { action: "list" } |
8 | 9 | | { action: "inspect"; name?: string } |
@@ -11,6 +12,7 @@ export type PluginsCommand =
|
11 | 12 | | { action: "disable"; name: string } |
12 | 13 | | { action: "error"; message: string }; |
13 | 14 | |
| 15 | +/** Parses a `/plugin` or `/plugins` command into a closed command action. */ |
14 | 16 | export function parsePluginsCommand(raw: string): PluginsCommand | null { |
15 | 17 | const match = raw.match(/^\/plugins?(?:\s+(.*))?$/i); |
16 | 18 | if (!match) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import type {
|
11 | 11 | type DispatchReplyContext = MsgContext | FinalizedMsgContext; |
12 | 12 | type DispatchReplyOptions = Omit<GetReplyOptions, "onBlockReply">; |
13 | 13 | |
| 14 | +/** Buffered block dispatcher entry point used by provider reply flows. */ |
14 | 15 | export type DispatchReplyWithBufferedBlockDispatcher = (params: { |
15 | 16 | ctx: DispatchReplyContext; |
16 | 17 | cfg: OpenClawConfig; |
@@ -19,6 +20,7 @@ export type DispatchReplyWithBufferedBlockDispatcher = (params: {
|
19 | 20 | replyResolver?: GetReplyFromConfig; |
20 | 21 | }) => Promise<DispatchFromConfigResult>; |
21 | 22 | |
| 23 | +/** Plain dispatcher entry point used when block buffering is not needed. */ |
22 | 24 | export type DispatchReplyWithDispatcher = (params: { |
23 | 25 | ctx: DispatchReplyContext; |
24 | 26 | cfg: OpenClawConfig; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce"; |
2 | 2 | import { formatErrorMessage } from "../../infra/errors.js"; |
3 | 3 | |
| 4 | +/** Provider request error classes that get a specialized user-facing reply. */ |
4 | 5 | export type ProviderRequestErrorCode = "provider_conversation_state_error"; |
5 | 6 | |
| 7 | +/** Structured provider error classification for reply failure handling. */ |
6 | 8 | export type ProviderRequestErrorClassification = { |
7 | 9 | code: ProviderRequestErrorCode; |
8 | 10 | userMessage: string; |
9 | 11 | technicalMessage: string; |
10 | 12 | }; |
11 | 13 | |
| 14 | +/** User-facing copy for provider-side broken conversation state. */ |
12 | 15 | export const PROVIDER_CONVERSATION_STATE_ERROR_USER_MESSAGE = |
13 | 16 | "⚠️ The model provider rejected the conversation state. Please try again, or use /new to start a fresh session."; |
14 | 17 | |
| 18 | +/** Classifies provider request failures that are actionable for users. */ |
15 | 19 | export function classifyProviderRequestError( |
16 | 20 | err: unknown, |
17 | 21 | ): ProviderRequestErrorClassification | undefined { |
@@ -26,6 +30,7 @@ export function classifyProviderRequestError(
|
26 | 30 | return undefined; |
27 | 31 | } |
28 | 32 | |
| 33 | +/** Detects provider errors that indicate invalid conversation/tool turn state. */ |
29 | 34 | export function isProviderConversationStateErrorMessage(message: string): boolean { |
30 | 35 | const lower = normalizeLowercaseStringOrEmpty(message); |
31 | 36 | return ( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。