mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
* refactor: expand acp core package * chore: drop acp core package symlink * fix: keep acp core dependency graph stable * fix: add acp core tsconfig subpaths * fix: sync acp core boundary path artifacts * fix: use kysely for cron run-log queries * fix: resolve acp core subpaths in loaders
25 lines
1.4 KiB
JavaScript
25 lines
1.4 KiB
JavaScript
import { toAcpRuntimeError } from "./errors.mjs";
|
|
//#region src/runtime/error-text.ts
|
|
function resolveAcpRuntimeErrorNextStep(error) {
|
|
if (error.code === "ACP_BACKEND_MISSING" || error.code === "ACP_BACKEND_UNAVAILABLE") return "Run `/acp doctor`, install/enable the backend plugin, then retry.";
|
|
if (error.code === "ACP_DISPATCH_DISABLED") return "Enable `acp.dispatch.enabled=true` to allow thread-message ACP turns.";
|
|
if (error.code === "ACP_SESSION_INIT_FAILED") return "If this session is stale, recreate it with `/acp spawn` and rebind the thread.";
|
|
if (error.code === "ACP_INVALID_RUNTIME_OPTION") return "Use `/acp status` to inspect options and pass valid values.";
|
|
if (error.code === "ACP_BACKEND_UNSUPPORTED_CONTROL") return "This backend does not support that control; use a supported command.";
|
|
if (error.code === "ACP_TURN_FAILED") return "Retry, or use `/acp cancel` and send the message again.";
|
|
}
|
|
function formatAcpRuntimeErrorText(error) {
|
|
const next = resolveAcpRuntimeErrorNextStep(error);
|
|
if (!next) return `ACP error (${error.code}): ${error.message}`;
|
|
return `ACP error (${error.code}): ${error.message}\nnext: ${next}`;
|
|
}
|
|
function toAcpRuntimeErrorText(params) {
|
|
return formatAcpRuntimeErrorText(toAcpRuntimeError({
|
|
error: params.error,
|
|
fallbackCode: params.fallbackCode,
|
|
fallbackMessage: params.fallbackMessage
|
|
}));
|
|
}
|
|
//#endregion
|
|
export { formatAcpRuntimeErrorText, toAcpRuntimeErrorText };
|