chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -14,8 +14,7 @@ type InlineDirectiveParseOptions = {
|
||||
};
|
||||
|
||||
const AUDIO_TAG_RE = /\[\[\s*audio_as_voice\s*\]\]/gi;
|
||||
const REPLY_TAG_RE =
|
||||
/\[\[\s*(?:reply_to_current|reply_to\s*:\s*([^\]\n]+))\s*\]\]/gi;
|
||||
const REPLY_TAG_RE = /\[\[\s*(?:reply_to_current|reply_to\s*:\s*([^\]\n]+))\s*\]\]/gi;
|
||||
|
||||
function normalizeDirectiveWhitespace(text: string): string {
|
||||
return text
|
||||
@@ -28,11 +27,7 @@ export function parseInlineDirectives(
|
||||
text?: string,
|
||||
options: InlineDirectiveParseOptions = {},
|
||||
): InlineDirectiveParseResult {
|
||||
const {
|
||||
currentMessageId,
|
||||
stripAudioTag = true,
|
||||
stripReplyTags = true,
|
||||
} = options;
|
||||
const { currentMessageId, stripAudioTag = true, stripReplyTags = true } = options;
|
||||
if (!text) {
|
||||
return {
|
||||
text: "",
|
||||
@@ -56,25 +51,21 @@ export function parseInlineDirectives(
|
||||
return stripAudioTag ? " " : match;
|
||||
});
|
||||
|
||||
cleaned = cleaned.replace(
|
||||
REPLY_TAG_RE,
|
||||
(match, idRaw: string | undefined) => {
|
||||
hasReplyTag = true;
|
||||
if (idRaw === undefined) {
|
||||
sawCurrent = true;
|
||||
} else {
|
||||
const id = idRaw.trim();
|
||||
if (id) lastExplicitId = id;
|
||||
}
|
||||
return stripReplyTags ? " " : match;
|
||||
},
|
||||
);
|
||||
cleaned = cleaned.replace(REPLY_TAG_RE, (match, idRaw: string | undefined) => {
|
||||
hasReplyTag = true;
|
||||
if (idRaw === undefined) {
|
||||
sawCurrent = true;
|
||||
} else {
|
||||
const id = idRaw.trim();
|
||||
if (id) lastExplicitId = id;
|
||||
}
|
||||
return stripReplyTags ? " " : match;
|
||||
});
|
||||
|
||||
cleaned = normalizeDirectiveWhitespace(cleaned);
|
||||
|
||||
const replyToId =
|
||||
lastExplicitId ??
|
||||
(sawCurrent ? currentMessageId?.trim() || undefined : undefined);
|
||||
lastExplicitId ?? (sawCurrent ? currentMessageId?.trim() || undefined : undefined);
|
||||
|
||||
return {
|
||||
text: cleaned,
|
||||
|
||||
@@ -24,31 +24,21 @@ type GatewayClientInfoLike = {
|
||||
id?: string | null;
|
||||
};
|
||||
|
||||
export function isGatewayCliClient(
|
||||
client?: GatewayClientInfoLike | null,
|
||||
): boolean {
|
||||
export function isGatewayCliClient(client?: GatewayClientInfoLike | null): boolean {
|
||||
return normalizeGatewayClientMode(client?.mode) === GATEWAY_CLIENT_MODES.CLI;
|
||||
}
|
||||
|
||||
export function isInternalMessageChannel(
|
||||
raw?: string | null,
|
||||
): raw is InternalMessageChannel {
|
||||
export function isInternalMessageChannel(raw?: string | null): raw is InternalMessageChannel {
|
||||
return normalizeMessageChannel(raw) === INTERNAL_MESSAGE_CHANNEL;
|
||||
}
|
||||
|
||||
export function isWebchatClient(
|
||||
client?: GatewayClientInfoLike | null,
|
||||
): boolean {
|
||||
export function isWebchatClient(client?: GatewayClientInfoLike | null): boolean {
|
||||
const mode = normalizeGatewayClientMode(client?.mode);
|
||||
if (mode === GATEWAY_CLIENT_MODES.WEBCHAT) return true;
|
||||
return (
|
||||
normalizeGatewayClientName(client?.id) === GATEWAY_CLIENT_NAMES.WEBCHAT_UI
|
||||
);
|
||||
return normalizeGatewayClientName(client?.id) === GATEWAY_CLIENT_NAMES.WEBCHAT_UI;
|
||||
}
|
||||
|
||||
export function normalizeMessageChannel(
|
||||
raw?: string | null,
|
||||
): string | undefined {
|
||||
export function normalizeMessageChannel(raw?: string | null): string | undefined {
|
||||
const normalized = raw?.trim().toLowerCase();
|
||||
if (!normalized) return undefined;
|
||||
if (normalized === INTERNAL_MESSAGE_CHANNEL) return INTERNAL_MESSAGE_CHANNEL;
|
||||
@@ -57,12 +47,9 @@ export function normalizeMessageChannel(
|
||||
|
||||
export const DELIVERABLE_MESSAGE_CHANNELS = CHANNEL_IDS;
|
||||
|
||||
export type DeliverableMessageChannel =
|
||||
(typeof DELIVERABLE_MESSAGE_CHANNELS)[number];
|
||||
export type DeliverableMessageChannel = (typeof DELIVERABLE_MESSAGE_CHANNELS)[number];
|
||||
|
||||
export type GatewayMessageChannel =
|
||||
| DeliverableMessageChannel
|
||||
| InternalMessageChannel;
|
||||
export type GatewayMessageChannel = DeliverableMessageChannel | InternalMessageChannel;
|
||||
|
||||
export const GATEWAY_MESSAGE_CHANNELS = [
|
||||
...DELIVERABLE_MESSAGE_CHANNELS,
|
||||
@@ -74,22 +61,14 @@ export const GATEWAY_AGENT_CHANNEL_ALIASES = listChatChannelAliases();
|
||||
export type GatewayAgentChannelHint = GatewayMessageChannel | "last";
|
||||
|
||||
export const GATEWAY_AGENT_CHANNEL_VALUES = Array.from(
|
||||
new Set([
|
||||
...GATEWAY_MESSAGE_CHANNELS,
|
||||
"last",
|
||||
...GATEWAY_AGENT_CHANNEL_ALIASES,
|
||||
]),
|
||||
new Set([...GATEWAY_MESSAGE_CHANNELS, "last", ...GATEWAY_AGENT_CHANNEL_ALIASES]),
|
||||
);
|
||||
|
||||
export function isGatewayMessageChannel(
|
||||
value: string,
|
||||
): value is GatewayMessageChannel {
|
||||
export function isGatewayMessageChannel(value: string): value is GatewayMessageChannel {
|
||||
return (GATEWAY_MESSAGE_CHANNELS as readonly string[]).includes(value);
|
||||
}
|
||||
|
||||
export function isDeliverableMessageChannel(
|
||||
value: string,
|
||||
): value is DeliverableMessageChannel {
|
||||
export function isDeliverableMessageChannel(value: string): value is DeliverableMessageChannel {
|
||||
return (DELIVERABLE_MESSAGE_CHANNELS as readonly string[]).includes(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
* (e.g. <think> and <final>) in the text stream, rather than using native
|
||||
* API fields for reasoning/thinking.
|
||||
*/
|
||||
export function isReasoningTagProvider(
|
||||
provider: string | undefined | null,
|
||||
): boolean {
|
||||
export function isReasoningTagProvider(provider: string | undefined | null): boolean {
|
||||
if (!provider) return false;
|
||||
const normalized = provider.trim().toLowerCase();
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ export function formatTokenCount(value?: number): string {
|
||||
if (value === undefined || !Number.isFinite(value)) return "0";
|
||||
const safe = Math.max(0, value);
|
||||
if (safe >= 1_000_000) return `${(safe / 1_000_000).toFixed(1)}m`;
|
||||
if (safe >= 1_000)
|
||||
return `${(safe / 1_000).toFixed(safe >= 10_000 ? 0 : 1)}k`;
|
||||
if (safe >= 1_000) return `${(safe / 1_000).toFixed(safe >= 10_000 ? 0 : 1)}k`;
|
||||
return String(Math.round(safe));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user