mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-24 08:21:39 +00:00
perf(reply): split runner auth profile seam
This commit is contained in:
24
src/auto-reply/reply/agent-runner-auth-profile.ts
Normal file
24
src/auto-reply/reply/agent-runner-auth-profile.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { FollowupRun } from "./queue.js";
|
||||
|
||||
export function resolveProviderScopedAuthProfile(params: {
|
||||
provider: string;
|
||||
primaryProvider: string;
|
||||
authProfileId?: string;
|
||||
authProfileIdSource?: "auto" | "user";
|
||||
}): { authProfileId?: string; authProfileIdSource?: "auto" | "user" } {
|
||||
const authProfileId =
|
||||
params.provider === params.primaryProvider ? params.authProfileId : undefined;
|
||||
return {
|
||||
authProfileId,
|
||||
authProfileIdSource: authProfileId ? params.authProfileIdSource : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveRunAuthProfile(run: FollowupRun["run"], provider: string) {
|
||||
return resolveProviderScopedAuthProfile({
|
||||
provider,
|
||||
primaryProvider: run.provider,
|
||||
authProfileId: run.authProfileId,
|
||||
authProfileIdSource: run.authProfileIdSource,
|
||||
});
|
||||
}
|
||||
@@ -8,6 +8,11 @@ import { isReasoningTagProvider } from "../../utils/provider-utils.js";
|
||||
import { estimateUsageCost, formatTokenCount, formatUsd } from "../../utils/usage-format.js";
|
||||
import type { TemplateContext } from "../templating.js";
|
||||
import type { ReplyPayload } from "../types.js";
|
||||
import {
|
||||
resolveProviderScopedAuthProfile,
|
||||
resolveRunAuthProfile,
|
||||
} from "./agent-runner-auth-profile.js";
|
||||
export { resolveProviderScopedAuthProfile, resolveRunAuthProfile };
|
||||
import { resolveOriginMessageProvider, resolveOriginMessageTo } from "./origin-routing.js";
|
||||
import type { FollowupRun } from "./queue.js";
|
||||
|
||||
@@ -237,15 +242,6 @@ export function buildTemplateSenderContext(sessionCtx: TemplateContext) {
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveRunAuthProfile(run: FollowupRun["run"], provider: string) {
|
||||
return resolveProviderScopedAuthProfile({
|
||||
provider,
|
||||
primaryProvider: run.provider,
|
||||
authProfileId: run.authProfileId,
|
||||
authProfileIdSource: run.authProfileIdSource,
|
||||
});
|
||||
}
|
||||
|
||||
export function buildEmbeddedRunContexts(params: {
|
||||
run: FollowupRun["run"];
|
||||
sessionCtx: TemplateContext;
|
||||
@@ -287,17 +283,3 @@ export function buildEmbeddedRunExecutionParams(params: {
|
||||
runBaseParams,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveProviderScopedAuthProfile(params: {
|
||||
provider: string;
|
||||
primaryProvider: string;
|
||||
authProfileId?: string;
|
||||
authProfileIdSource?: "auto" | "user";
|
||||
}): { authProfileId?: string; authProfileIdSource?: "auto" | "user" } {
|
||||
const authProfileId =
|
||||
params.provider === params.primaryProvider ? params.authProfileId : undefined;
|
||||
return {
|
||||
authProfileId,
|
||||
authProfileIdSource: authProfileId ? params.authProfileIdSource : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import { stripHeartbeatToken } from "../heartbeat.js";
|
||||
import type { OriginatingChannelType } from "../templating.js";
|
||||
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js";
|
||||
import type { GetReplyOptions, ReplyPayload } from "../types.js";
|
||||
import { resolveRunAuthProfile } from "./agent-runner-utils.js";
|
||||
import { resolveRunAuthProfile } from "./agent-runner-auth-profile.js";
|
||||
import {
|
||||
resolveOriginAccountId,
|
||||
resolveOriginMessageProvider,
|
||||
|
||||
Reference in New Issue
Block a user