mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
refactor(types): remove redundant local aliases (#100061)
* refactor(models): remove redundant generation model ref alias * refactor(types): remove redundant local aliases * refactor(types): preserve shipped model ref type
This commit is contained in:
parent
cf14b27d81
commit
dc3b5df684
20 changed files with 24 additions and 55 deletions
|
|
@ -9,7 +9,6 @@ import { stream, type Model, type SimpleStreamOptions } from "openclaw/plugin-sd
|
|||
const MANTLE_ANTHROPIC_BETA = "fine-grained-tool-streaming-2025-05-14";
|
||||
type AnthropicOptions = ConstructorParameters<typeof Anthropic>[0];
|
||||
type MantleAnthropicStream = typeof stream;
|
||||
type AnthropicStreamClient = Anthropic;
|
||||
|
||||
/** Resolve the Anthropic-compatible Mantle base URL from a provider base URL. */
|
||||
export function resolveMantleAnthropicBaseUrl(baseUrl: string): string {
|
||||
|
|
@ -138,7 +137,7 @@ export function createMantleAnthropicStreamFn(deps?: {
|
|||
const base = buildMantleAnthropicBaseOptions(model, options, apiKey);
|
||||
// Plugin package deps can give this plugin a distinct physical SDK copy.
|
||||
// The client API is the same, but the SDK class private field makes types nominal.
|
||||
const streamClient = client as unknown as AnthropicStreamClient;
|
||||
const streamClient = client as unknown as Anthropic;
|
||||
const reasoning = resolveMantleReasoning(model, options);
|
||||
if (!reasoning) {
|
||||
return streamFn(model as Model<"anthropic-messages">, context, {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ export type Activity = NonNullable<GatewayPresenceUpdateData["activities"]>[numb
|
|||
export type UpdatePresenceData = Omit<GatewayPresenceUpdateData, "status"> & {
|
||||
status: "online" | "idle" | "dnd" | "invisible" | "offline";
|
||||
};
|
||||
type UpdateVoiceStateData = GatewayVoiceStateUpdateData;
|
||||
type RequestGuildMembersData = {
|
||||
guild_id: string;
|
||||
query?: string;
|
||||
|
|
@ -441,7 +440,7 @@ export class GatewayPlugin extends Plugin {
|
|||
this.send({ op: GatewayOpcodes.PresenceUpdate, d: data } as GatewaySendPayload);
|
||||
}
|
||||
|
||||
updateVoiceState(data: UpdateVoiceStateData): void {
|
||||
updateVoiceState(data: GatewayVoiceStateUpdateData): void {
|
||||
this.send({ op: GatewayOpcodes.VoiceStateUpdate, d: data } as GatewaySendPayload, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@ import {
|
|||
type StreamingMode,
|
||||
} from "openclaw/plugin-sdk/channel-outbound";
|
||||
|
||||
type DiscordPreviewStreamMode = StreamingMode;
|
||||
|
||||
export function resolveDiscordPreviewStreamMode(
|
||||
params: {
|
||||
streamMode?: unknown;
|
||||
streaming?: unknown;
|
||||
} = {},
|
||||
): DiscordPreviewStreamMode {
|
||||
): StreamingMode {
|
||||
if (params.streaming === undefined && params.streamMode === undefined) {
|
||||
return "progress";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
// Discord plugin module implements proxy request client behavior.
|
||||
import { RequestClient, type RequestClientOptions } from "./internal/discord.js";
|
||||
|
||||
type ProxyRequestClientOptions = RequestClientOptions;
|
||||
|
||||
export const DISCORD_REST_TIMEOUT_MS = 15_000;
|
||||
|
||||
export function createDiscordRequestClient(
|
||||
token: string,
|
||||
options?: ProxyRequestClientOptions,
|
||||
options?: RequestClientOptions,
|
||||
): RequestClient {
|
||||
if (!options?.fetch) {
|
||||
return new RequestClient(token, options);
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ import {
|
|||
|
||||
export type SendDiscordTarget = DiscordTarget;
|
||||
|
||||
type SendDiscordTargetParseOptions = DiscordTargetParseOptions;
|
||||
|
||||
export const parseDiscordSendTarget = (
|
||||
raw: string,
|
||||
options: SendDiscordTargetParseOptions = {},
|
||||
options: DiscordTargetParseOptions = {},
|
||||
): SendDiscordTarget | undefined => parseDiscordTarget(raw, options);
|
||||
|
|
|
|||
|
|
@ -538,13 +538,11 @@ async function repairMatrixDirectRoom(params: {
|
|||
});
|
||||
}
|
||||
|
||||
type MatrixCliProfileSetResult = MatrixProfileUpdateResult;
|
||||
|
||||
async function setMatrixProfile(params: {
|
||||
account?: string;
|
||||
name?: string;
|
||||
avatarUrl?: string;
|
||||
}): Promise<MatrixCliProfileSetResult> {
|
||||
}): Promise<MatrixProfileUpdateResult> {
|
||||
return await applyMatrixProfileUpdate({
|
||||
account: params.account,
|
||||
displayName: params.name,
|
||||
|
|
|
|||
|
|
@ -28,11 +28,9 @@ type QaRuntimeGatewayClient = {
|
|||
) => Promise<unknown>;
|
||||
};
|
||||
|
||||
type QaRuntimeTransport = QaTransportAdapter;
|
||||
|
||||
export type QaSuiteRuntimeEnv = {
|
||||
gateway: QaRuntimeGatewayClient;
|
||||
transport: QaRuntimeTransport;
|
||||
transport: QaTransportAdapter;
|
||||
repoRoot: string;
|
||||
providerMode: QaProviderMode;
|
||||
primaryModel: string;
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@ import {
|
|||
type StreamingMode,
|
||||
} from "openclaw/plugin-sdk/channel-outbound";
|
||||
|
||||
type TelegramPreviewStreamMode = StreamingMode;
|
||||
|
||||
export function resolveTelegramPreviewStreamMode(
|
||||
params: {
|
||||
streamMode?: unknown;
|
||||
streaming?: unknown;
|
||||
} = {},
|
||||
): TelegramPreviewStreamMode {
|
||||
): StreamingMode {
|
||||
return resolveChannelPreviewStreamMode(params, "partial");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,11 @@ import {
|
|||
} from "openclaw/plugin-sdk/status-helpers";
|
||||
import { resolveMergedWhatsAppAccountConfig } from "./account-config.js";
|
||||
|
||||
type ResolvedWhatsAppReactionLevel = ResolvedReactionLevel;
|
||||
|
||||
/** Resolve the effective reaction level and its implications for WhatsApp. */
|
||||
export function resolveWhatsAppReactionLevel(params: {
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string;
|
||||
}): ResolvedWhatsAppReactionLevel {
|
||||
}): ResolvedReactionLevel {
|
||||
const account = resolveMergedWhatsAppAccountConfig({
|
||||
cfg: params.cfg,
|
||||
accountId: params.accountId,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ import {
|
|||
export type ParsedGenerationModelRef = ProviderModelRef;
|
||||
|
||||
/** Parses strict generation model refs and rejects missing provider or model segments. */
|
||||
export function parseGenerationModelRef(raw: string | undefined): ParsedGenerationModelRef | null {
|
||||
export function parseGenerationModelRef(raw: string | undefined): ProviderModelRef | null {
|
||||
return raw === undefined ? null : parseProviderModelRef(raw);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,14 +111,13 @@ export function normalizeModelRef(
|
|||
return { provider: normalizedProvider, model: normalizedModel };
|
||||
}
|
||||
|
||||
type ParseModelRefOptions = ModelRefNormalizeOptions;
|
||||
const OPENROUTER_AUTO_COMPAT_ALIAS = "openrouter:auto";
|
||||
|
||||
/** Parse `provider/model` or bare model text using a default provider. */
|
||||
export function parseModelRef(
|
||||
raw: string,
|
||||
defaultProvider: string,
|
||||
options?: ParseModelRefOptions,
|
||||
options?: ModelRefNormalizeOptions,
|
||||
): ModelRef | null {
|
||||
const trimmed = raw.trim();
|
||||
if (!trimmed) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ type AgentStatusLike = {
|
|||
|
||||
type SummaryLike = Pick<StatusSummary, "tasks" | "taskAudit" | "heartbeat" | "sessions">;
|
||||
type MemoryLike = MemoryStatusSnapshot | null;
|
||||
type MemoryPluginLike = MemoryPluginStatus;
|
||||
type SessionsRecentLike = SessionStatus;
|
||||
type EventLoopHealthLike = NonNullable<HealthSummary["eventLoop"]>;
|
||||
|
||||
|
|
@ -151,7 +150,7 @@ export function buildStatusLastHeartbeatValue(params: {
|
|||
export function buildStatusMemoryValue(
|
||||
params: {
|
||||
memory: MemoryLike;
|
||||
memoryPlugin: MemoryPluginLike;
|
||||
memoryPlugin: MemoryPluginStatus;
|
||||
ok: (value: string) => string;
|
||||
warn: (value: string) => string;
|
||||
muted: (value: string) => string;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ type LocalGatewayRequestContextParams = {
|
|||
getRuntimeConfig: () => OpenClawConfig;
|
||||
};
|
||||
|
||||
type LocalGatewayScopeParams = LocalGatewayRequestContextParams;
|
||||
|
||||
function cronUnavailable(): never {
|
||||
throw new Error("Cron is unavailable in local embedded agent gateway context.");
|
||||
}
|
||||
|
|
@ -156,7 +154,10 @@ export function createLocalGatewayRequestContext(
|
|||
}
|
||||
|
||||
/** Runs code inside a local gateway request scope unless an outer scope already exists. */
|
||||
export function withLocalGatewayRequestScope<T>(params: LocalGatewayScopeParams, run: () => T): T {
|
||||
export function withLocalGatewayRequestScope<T>(
|
||||
params: LocalGatewayRequestContextParams,
|
||||
run: () => T,
|
||||
): T {
|
||||
const existing = getPluginRuntimeGatewayRequestScope();
|
||||
if (existing?.context) {
|
||||
return run();
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ const AGENT_RUN_TIMEOUT_RETRY_GRACE_MS = 15_000;
|
|||
|
||||
const agentRunCache = new Map<string, AgentRunSnapshot>();
|
||||
const agentRunStarts = new Map<string, number>();
|
||||
const pendingAgentRunErrors = new Map<string, PendingAgentRunError>();
|
||||
const pendingAgentRunErrors = new Map<string, PendingAgentRunTerminal>();
|
||||
const pendingAgentRunTimeouts = new Map<string, PendingAgentRunTerminal>();
|
||||
const agentRunWaiterCounts = new Map<string, number>();
|
||||
let agentRunListenerStarted = false;
|
||||
|
|
@ -43,8 +43,6 @@ type PendingAgentRunTerminal = {
|
|||
timer: NodeJS.Timeout;
|
||||
};
|
||||
|
||||
type PendingAgentRunError = PendingAgentRunTerminal;
|
||||
|
||||
function pruneAgentRunCache(now = Date.now()) {
|
||||
for (const [runId, entry] of agentRunCache) {
|
||||
if (now - entry.ts > AGENT_RUN_CACHE_TTL_MS) {
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ type WebchatAudioEmbeddingOptions = {
|
|||
onLocalAudioAccessDenied?: (err: LocalMediaAccessError) => void;
|
||||
};
|
||||
|
||||
type WebchatAssistantMediaOptions = WebchatAudioEmbeddingOptions;
|
||||
|
||||
type LocalAudioContentBlock = {
|
||||
path: string;
|
||||
block: Record<string, unknown>;
|
||||
|
|
@ -253,7 +251,7 @@ export async function buildWebchatAudioContentBlocksFromReplyPayloads(
|
|||
|
||||
export async function buildWebchatAssistantMessageFromReplyPayloads(
|
||||
payloads: ReplyPayload[],
|
||||
options?: WebchatAssistantMediaOptions,
|
||||
options?: WebchatAudioEmbeddingOptions,
|
||||
): Promise<{ content: Array<Record<string, unknown>>; transcriptText: string } | null> {
|
||||
const content: Array<Record<string, unknown>> = [];
|
||||
const transcriptTextParts: string[] = [];
|
||||
|
|
|
|||
|
|
@ -946,9 +946,8 @@ function shellWrapperPayloadForParsing(
|
|||
return { command: payload, spanBase };
|
||||
}
|
||||
|
||||
type InlineEvalHit = InterpreterInlineEvalHit;
|
||||
function recordInlineEvalRisk(
|
||||
inlineEval: InlineEvalHit,
|
||||
inlineEval: InterpreterInlineEvalHit,
|
||||
text: string,
|
||||
span: SourceSpan,
|
||||
output: MutableExplanation,
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ type ClaudeWebOrganizationsResponse = Array<{
|
|||
name?: string;
|
||||
}>;
|
||||
|
||||
type ClaudeWebUsageResponse = ClaudeUsageResponse;
|
||||
|
||||
function buildClaudeUsageWindows(data: ClaudeUsageResponse): UsageWindow[] {
|
||||
const windows: UsageWindow[] = [];
|
||||
|
||||
|
|
@ -116,7 +114,7 @@ async function fetchClaudeWebUsage(
|
|||
if (!parsedUsage.ok) {
|
||||
return null;
|
||||
}
|
||||
const data = parsedUsage.data as ClaudeWebUsageResponse;
|
||||
const data = parsedUsage.data as ClaudeUsageResponse;
|
||||
const windows = buildClaudeUsageWindows(data);
|
||||
|
||||
if (windows.length === 0) {
|
||||
|
|
|
|||
|
|
@ -55,8 +55,6 @@ type PatchSessionEntryParams = SessionStoreReadParams & {
|
|||
update: SessionStoreEntryPatch;
|
||||
};
|
||||
|
||||
type ReadSessionUpdatedAtParams = SessionStoreReadParams;
|
||||
|
||||
type ReadAmbientTranscriptWatermarkParams = SessionStoreReadParams & {
|
||||
key: string;
|
||||
};
|
||||
|
|
@ -149,7 +147,7 @@ export async function patchSessionEntry(
|
|||
}
|
||||
|
||||
/** Reads the last activity timestamp for one session entry. */
|
||||
export function readSessionUpdatedAt(params: ReadSessionUpdatedAtParams): number | undefined {
|
||||
export function readSessionUpdatedAt(params: SessionStoreReadParams): number | undefined {
|
||||
return readAccessorSessionUpdatedAt(toSessionAccessScope(params));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ import {
|
|||
type SkillIndexEntry,
|
||||
} from "./skill-index.js";
|
||||
|
||||
type SkillStatusConfigCheck = RequirementConfigCheck;
|
||||
|
||||
type SkillInstallOption = {
|
||||
id: string;
|
||||
kind: SkillInstallSpec["kind"];
|
||||
|
|
@ -72,7 +70,7 @@ export type SkillStatusEntry = {
|
|||
commandVisible: boolean;
|
||||
requirements: Requirements;
|
||||
missing: Requirements;
|
||||
configChecks: SkillStatusConfigCheck[];
|
||||
configChecks: RequirementConfigCheck[];
|
||||
install: SkillInstallOption[];
|
||||
clawhub?: ClawHubSkillStatusLink;
|
||||
skillCard?: LocalSkillCardStatus;
|
||||
|
|
|
|||
|
|
@ -91,10 +91,7 @@ function ensureSingleTaskFlow(params: {
|
|||
}
|
||||
}
|
||||
|
||||
type TaskRunCreateParams = DetachedTaskCreateParams;
|
||||
type RunningTaskRunCreateParams = DetachedRunningTaskCreateParams;
|
||||
|
||||
export function createQueuedTaskRun(params: TaskRunCreateParams): TaskRecord | null {
|
||||
export function createQueuedTaskRun(params: DetachedTaskCreateParams): TaskRecord | null {
|
||||
const task = createTaskRecord({
|
||||
...params,
|
||||
status: "queued",
|
||||
|
|
@ -112,7 +109,7 @@ export function getFlowTaskSummary(flowId: string): TaskRegistrySummary {
|
|||
return summarizeTaskRecords(listTasksForFlowId(flowId));
|
||||
}
|
||||
|
||||
export function createRunningTaskRun(params: RunningTaskRunCreateParams): TaskRecord | null {
|
||||
export function createRunningTaskRun(params: DetachedRunningTaskCreateParams): TaskRecord | null {
|
||||
const task = createTaskRecord({
|
||||
...params,
|
||||
status: "running",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue