2026-01-14 01:08:15 +00:00
|
|
|
import type { ThinkingLevel } from "@mariozechner/pi-agent-core";
|
|
|
|
|
import type { ReasoningLevel, ThinkLevel } from "../../auto-reply/thinking.js";
|
|
|
|
|
|
|
|
|
|
export function mapThinkingLevel(level?: ThinkLevel): ThinkingLevel {
|
2026-01-30 03:15:10 +01:00
|
|
|
// pi-agent-core supports "xhigh"; OpenClaw enables it for specific models.
|
2026-01-31 16:19:20 +09:00
|
|
|
if (!level) {
|
|
|
|
|
return "off";
|
|
|
|
|
}
|
2026-03-02 11:52:02 +08:00
|
|
|
// "adaptive" maps to "medium" at the pi-agent-core layer. The Pi SDK
|
|
|
|
|
// provider then translates this to `thinking.type: "adaptive"` with
|
|
|
|
|
// `output_config.effort: "medium"` for models that support it (Opus 4.6,
|
|
|
|
|
// Sonnet 4.6).
|
|
|
|
|
if (level === "adaptive") {
|
|
|
|
|
return "medium";
|
|
|
|
|
}
|
2026-01-14 01:08:15 +00:00
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function describeUnknownError(error: unknown): string {
|
2026-01-31 16:19:20 +09:00
|
|
|
if (error instanceof Error) {
|
|
|
|
|
return error.message;
|
|
|
|
|
}
|
|
|
|
|
if (typeof error === "string") {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
2026-01-14 01:08:15 +00:00
|
|
|
try {
|
|
|
|
|
const serialized = JSON.stringify(error);
|
|
|
|
|
return serialized ?? "Unknown error";
|
|
|
|
|
} catch {
|
|
|
|
|
return "Unknown error";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type { ReasoningLevel, ThinkLevel };
|