chore: migrate to oxlint and oxfmt

Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 14:31:43 +00:00
parent 912ebffc63
commit c379191f80
1480 changed files with 28608 additions and 43547 deletions

View File

@@ -2,43 +2,19 @@ import type { ModelAliasIndex } from "../../agents/model-selection.js";
import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js";
import type { ClawdbotConfig } from "../../config/config.js";
import type { SessionEntry } from "../../config/sessions.js";
import {
listChatCommands,
shouldHandleTextCommands,
} from "../commands-registry.js";
import { listChatCommands, shouldHandleTextCommands } from "../commands-registry.js";
import type { MsgContext, TemplateContext } from "../templating.js";
import type {
ElevatedLevel,
ReasoningLevel,
ThinkLevel,
VerboseLevel,
} from "../thinking.js";
import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../thinking.js";
import type { GetReplyOptions, ReplyPayload } from "../types.js";
import { resolveBlockStreamingChunking } from "./block-streaming.js";
import { buildCommandContext } from "./commands.js";
import {
type InlineDirectives,
parseInlineDirectives,
} from "./directive-handling.js";
import { type InlineDirectives, parseInlineDirectives } from "./directive-handling.js";
import { applyInlineDirectiveOverrides } from "./get-reply-directives-apply.js";
import { clearInlineDirectives } from "./get-reply-directives-utils.js";
import {
defaultGroupActivation,
resolveGroupRequireMention,
} from "./groups.js";
import {
CURRENT_MESSAGE_MARKER,
stripMentions,
stripStructuralPrefixes,
} from "./mentions.js";
import {
createModelSelectionState,
resolveContextTokens,
} from "./model-selection.js";
import {
formatElevatedUnavailableMessage,
resolveElevatedPermissions,
} from "./reply-elevated.js";
import { defaultGroupActivation, resolveGroupRequireMention } from "./groups.js";
import { CURRENT_MESSAGE_MARKER, stripMentions, stripStructuralPrefixes } from "./mentions.js";
import { createModelSelectionState, resolveContextTokens } from "./model-selection.js";
import { formatElevatedUnavailableMessage, resolveElevatedPermissions } from "./reply-elevated.js";
import { stripInlineStatus } from "./reply-inline.js";
import type { TypingController } from "./typing.js";
@@ -95,12 +71,8 @@ export async function resolveReplyDirectives(params: {
sessionStore?: Record<string, SessionEntry>;
sessionKey: string;
storePath?: string;
sessionScope: Parameters<
typeof applyInlineDirectiveOverrides
>[0]["sessionScope"];
groupResolution: Parameters<
typeof resolveGroupRequireMention
>[0]["groupResolution"];
sessionScope: Parameters<typeof applyInlineDirectiveOverrides>[0]["sessionScope"];
groupResolution: Parameters<typeof resolveGroupRequireMention>[0]["groupResolution"];
isGroup: boolean;
triggerBodyNormalized: string;
commandAuthorized: boolean;
@@ -175,19 +147,14 @@ export async function resolveReplyDirectives(params: {
allowStatusDirective,
});
const hasInlineStatus =
parsedDirectives.hasStatusDirective &&
parsedDirectives.cleaned.trim().length > 0;
parsedDirectives.hasStatusDirective && parsedDirectives.cleaned.trim().length > 0;
if (hasInlineStatus) {
parsedDirectives = {
...parsedDirectives,
hasStatusDirective: false,
};
}
if (
isGroup &&
ctx.WasMentioned !== true &&
parsedDirectives.hasElevatedDirective
) {
if (isGroup && ctx.WasMentioned !== true && parsedDirectives.hasElevatedDirective) {
if (parsedDirectives.elevatedLevel !== "off") {
parsedDirectives = {
...parsedDirectives,
@@ -206,18 +173,14 @@ export async function resolveReplyDirectives(params: {
parsedDirectives.hasQueueDirective;
if (hasInlineDirective) {
const stripped = stripStructuralPrefixes(parsedDirectives.cleaned);
const noMentions = isGroup
? stripMentions(stripped, ctx, cfg, agentId)
: stripped;
const noMentions = isGroup ? stripMentions(stripped, ctx, cfg, agentId) : stripped;
if (noMentions.trim().length > 0) {
const directiveOnlyCheck = parseInlineDirectives(noMentions, {
modelAliases: configuredAliases,
});
if (directiveOnlyCheck.cleaned.trim().length > 0) {
const allowInlineStatus =
parsedDirectives.hasStatusDirective &&
allowTextCommands &&
command.isAuthorizedSender;
parsedDirectives.hasStatusDirective && allowTextCommands && command.isAuthorizedSender;
parsedDirectives = allowInlineStatus
? {
...clearInlineDirectives(parsedDirectives.cleaned),
@@ -257,13 +220,8 @@ export async function resolveReplyDirectives(params: {
}).cleaned;
}
const head = existingBody.slice(
0,
markerIndex + CURRENT_MESSAGE_MARKER.length,
);
const tail = existingBody.slice(
markerIndex + CURRENT_MESSAGE_MARKER.length,
);
const head = existingBody.slice(0, markerIndex + CURRENT_MESSAGE_MARKER.length);
const tail = existingBody.slice(markerIndex + CURRENT_MESSAGE_MARKER.length);
const cleanedTail = parseInlineDirectives(tail, {
modelAliases: configuredAliases,
allowStatusDirective,
@@ -279,9 +237,7 @@ export async function resolveReplyDirectives(params: {
sessionCtx.BodyStripped = cleanedBody;
const messageProviderKey =
sessionCtx.Provider?.trim().toLowerCase() ??
ctx.Provider?.trim().toLowerCase() ??
"";
sessionCtx.Provider?.trim().toLowerCase() ?? ctx.Provider?.trim().toLowerCase() ?? "";
const elevated = resolveElevatedPermissions({
cfg,
agentId,
@@ -291,10 +247,7 @@ export async function resolveReplyDirectives(params: {
const elevatedEnabled = elevated.enabled;
const elevatedAllowed = elevated.allowed;
const elevatedFailures = elevated.failures;
if (
directives.hasElevatedDirective &&
(!elevatedEnabled || !elevatedAllowed)
) {
if (directives.hasElevatedDirective && (!elevatedEnabled || !elevatedAllowed)) {
typing.cleanup();
const runtimeSandboxed = resolveSandboxRuntimeStatus({
cfg,
@@ -346,17 +299,11 @@ export async function resolveReplyDirectives(params: {
? "on"
: "off";
const resolvedBlockStreamingBreak: "text_end" | "message_end" =
agentCfg?.blockStreamingBreak === "message_end"
? "message_end"
: "text_end";
agentCfg?.blockStreamingBreak === "message_end" ? "message_end" : "text_end";
const blockStreamingEnabled =
resolvedBlockStreaming === "on" && opts?.disableBlockStreaming !== true;
const blockReplyChunking = blockStreamingEnabled
? resolveBlockStreamingChunking(
cfg,
sessionCtx.Provider,
sessionCtx.AccountId,
)
? resolveBlockStreamingChunking(cfg, sessionCtx.Provider, sessionCtx.AccountId)
: undefined;
const modelState = await createModelSelectionState({
@@ -382,20 +329,13 @@ export async function resolveReplyDirectives(params: {
const initialModelLabel = `${provider}/${model}`;
const formatModelSwitchEvent = (label: string, alias?: string) =>
alias
? `Model switched to ${alias} (${label}).`
: `Model switched to ${label}.`;
alias ? `Model switched to ${alias} (${label}).` : `Model switched to ${label}.`;
const isModelListAlias =
directives.hasModelDirective &&
["status", "list"].includes(
directives.rawModelDirective?.trim().toLowerCase() ?? "",
);
const effectiveModelDirective = isModelListAlias
? undefined
: directives.rawModelDirective;
["status", "list"].includes(directives.rawModelDirective?.trim().toLowerCase() ?? "");
const effectiveModelDirective = isModelListAlias ? undefined : directives.rawModelDirective;
const inlineStatusRequested =
hasInlineStatus && allowTextCommands && command.isAuthorizedSender;
const inlineStatusRequested = hasInlineStatus && allowTextCommands && command.isAuthorizedSender;
const applyResult = await applyInlineDirectiveOverrides({
ctx,
@@ -437,8 +377,7 @@ export async function resolveReplyDirectives(params: {
provider = applyResult.provider;
model = applyResult.model;
contextTokens = applyResult.contextTokens;
const { directiveAck, perMessageQueueMode, perMessageQueueOptions } =
applyResult;
const { directiveAck, perMessageQueueMode, perMessageQueueOptions } = applyResult;
return {
kind: "continue",