diff --git a/extensions/telegram/src/action-runtime.ts b/extensions/telegram/src/action-runtime.ts index 5f2a656318c..e8587a758a1 100644 --- a/extensions/telegram/src/action-runtime.ts +++ b/extensions/telegram/src/action-runtime.ts @@ -19,10 +19,7 @@ import { import type { MessagePresentation } from "openclaw/plugin-sdk/interactive-runtime"; import { createTelegramActionGate, resolveTelegramPollActionGateState } from "./accounts.js"; import { resolveTelegramInlineButtons } from "./button-types.js"; -import { - notifyTelegramInboundTurnOutboundSuccess, - type TelegramInboundTurnDeliveryKind, -} from "./inbound-turn-delivery.js"; +import { notifyTelegramInboundTurnOutboundSuccess } from "./inbound-turn-delivery.js"; import { resolveTelegramInlineButtonsScope, resolveTelegramTargetChatType, @@ -243,7 +240,7 @@ export async function handleTelegramAction( mediaLocalRoots?: readonly string[]; mediaReadFile?: (filePath: string) => Promise; sessionKey?: string | null; - inboundTurnKind?: TelegramInboundTurnDeliveryKind | string; + inboundTurnKind?: string; }, ): Promise> { const { action, accountId } = { diff --git a/extensions/telegram/src/inbound-turn-delivery.ts b/extensions/telegram/src/inbound-turn-delivery.ts index f0600b380b1..59163d4a4de 100644 --- a/extensions/telegram/src/inbound-turn-delivery.ts +++ b/extensions/telegram/src/inbound-turn-delivery.ts @@ -41,7 +41,7 @@ function telegramDeliveryTargetsMatch(expected: string, actual: string): boolean export function resolveTelegramInboundTurnDeliveryCorrelationKey( sessionKey: string | undefined, - inboundTurnKind?: TelegramInboundTurnDeliveryKind | string, + inboundTurnKind?: string, ): string | undefined { const key = sessionKey?.trim(); if (!key) { @@ -53,7 +53,7 @@ export function resolveTelegramInboundTurnDeliveryCorrelationKey( export function beginTelegramInboundTurnDeliveryCorrelation( sessionKey: string | undefined, turn: ActiveTurn, - options?: { inboundTurnKind?: TelegramInboundTurnDeliveryKind | string }, + options?: { inboundTurnKind?: string }, ): TelegramInboundTurnDeliveryEnd { const key = resolveTelegramInboundTurnDeliveryCorrelationKey( sessionKey, @@ -74,7 +74,7 @@ export function notifyTelegramInboundTurnOutboundSuccess(params: { sessionKey: string | undefined; to: string; accountId?: string | null; - inboundTurnKind?: TelegramInboundTurnDeliveryKind | string; + inboundTurnKind?: string; }): void { const key = resolveTelegramInboundTurnDeliveryCorrelationKey( params.sessionKey, diff --git a/extensions/telegram/src/polling-session.ts b/extensions/telegram/src/polling-session.ts index 240ca97d035..d1267972abd 100644 --- a/extensions/telegram/src/polling-session.ts +++ b/extensions/telegram/src/polling-session.ts @@ -81,7 +81,7 @@ const resolvePollingStallThresholdMs = (value: number | undefined): number => { type TelegramPollingSessionOpts = { token: string; - config: Parameters[0]["config"]; + config: NonNullable[0]["config"]>; accountId: string; runtime: Parameters[0]["runtime"]; proxyFetch: Parameters[0]["proxyFetch"]; @@ -491,7 +491,7 @@ export class TelegramPollingSession { try { const drain = await this.#drainSpooledUpdates({ bot, spoolDir }); consecutiveDrainFailures = 0; - for (const handlerKey of [...stalledBacklogKeys]) { + for (const handlerKey of stalledBacklogKeys) { if ( !activeSpooledUpdateHandlersByLane.has(handlerKey) || !drain.blockedByLane.has(handlerKey) diff --git a/src/agents/model-runtime-policy.test.ts b/src/agents/model-runtime-policy.test.ts index 106f512bb71..2c7e2697397 100644 --- a/src/agents/model-runtime-policy.test.ts +++ b/src/agents/model-runtime-policy.test.ts @@ -1,7 +1,24 @@ import { describe, expect, it } from "vitest"; +import type { ModelDefinitionConfig } from "../config/types.models.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { resolveModelRuntimePolicy } from "./model-runtime-policy.js"; +const createModelConfig = (agentRuntimeId: string): ModelDefinitionConfig => ({ + id: "qwen-local", + name: "Qwen Local", + reasoning: false, + input: ["text"], + cost: { + input: 0, + output: 0, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 32_768, + maxTokens: 4096, + agentRuntime: { id: agentRuntimeId }, +}); + describe("resolveModelRuntimePolicy", () => { it("honors provider wildcard agent model runtime policy entries", () => { const config = { @@ -62,7 +79,8 @@ describe("resolveModelRuntimePolicy", () => { models: { providers: { vllm: { - models: [{ id: "qwen-local", agentRuntime: { id: "codex" } }], + baseUrl: "http://127.0.0.1:11434/v1", + models: [createModelConfig("codex")], }, }, }, @@ -92,6 +110,7 @@ describe("resolveModelRuntimePolicy", () => { models: { providers: { vllm: { + baseUrl: "http://127.0.0.1:11434/v1", agentRuntime: { id: "codex" }, models: [], }, diff --git a/src/auto-reply/reply/followup-runner.ts b/src/auto-reply/reply/followup-runner.ts index dcb6e911e16..288b13c9507 100644 --- a/src/auto-reply/reply/followup-runner.ts +++ b/src/auto-reply/reply/followup-runner.ts @@ -487,11 +487,13 @@ export function createFollowupRunner(params: { modelId: modelUsed, }); } finally { - for (const end of endDeliveryCorrelations.reverse()) { + for (const end of endDeliveryCorrelations.toReversed()) { try { end(); } catch (err) { - defaultRuntime.error?.(`followup queue: delivery correlation cleanup failed: ${err}`); + defaultRuntime.error?.( + `followup queue: delivery correlation cleanup failed: ${formatErrorMessage(err)}`, + ); } } completeFollowupRunLifecycle(queued); diff --git a/src/auto-reply/reply/queue.test-helpers.ts b/src/auto-reply/reply/queue.test-helpers.ts index 0b17cce4499..5660187b4c6 100644 --- a/src/auto-reply/reply/queue.test-helpers.ts +++ b/src/auto-reply/reply/queue.test-helpers.ts @@ -20,6 +20,7 @@ export function createQueueTestRun(params: { originatingTo?: string; originatingAccountId?: string; originatingThreadId?: string | number; + currentTurnKind?: FollowupRun["currentTurnKind"]; }): FollowupRun { return { prompt: params.prompt, @@ -29,6 +30,7 @@ export function createQueueTestRun(params: { originatingTo: params.originatingTo, originatingAccountId: params.originatingAccountId, originatingThreadId: params.originatingThreadId, + currentTurnKind: params.currentTurnKind, run: { agentId: "agent", agentDir: "/tmp", diff --git a/src/auto-reply/reply/queue/drain.ts b/src/auto-reply/reply/queue/drain.ts index e41fbbd9224..d2251c4ebce 100644 --- a/src/auto-reply/reply/queue/drain.ts +++ b/src/auto-reply/reply/queue/drain.ts @@ -267,7 +267,7 @@ async function dropAbortedFollowups( ): Promise { let dropped = 0; for (let index = items.length - 1; index >= 0; index -= 1) { - const item = items[index]!; + const item = items[index]; if (isFollowupRunAborted(item)) { await runFollowup(item); completeFollowupRunLifecycle(item); diff --git a/src/gateway/mcp-http.test.ts b/src/gateway/mcp-http.test.ts index 20ab87c7c73..a972a0ecb56 100644 --- a/src/gateway/mcp-http.test.ts +++ b/src/gateway/mcp-http.test.ts @@ -22,6 +22,7 @@ type ScopedToolsCall = { sessionKey?: string; accountId?: string; messageProvider?: string; + inboundTurnKind?: string; senderIsOwner?: boolean; surface?: string; excludeToolNames?: Iterable;