perf(reply): split runner auth profile seam

This commit is contained in:
Vincent Koc 2026-03-22 18:28:55 -07:00
parent ecdf5d457a
commit d1404014d9
3 changed files with 30 additions and 24 deletions

View 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,
});
}

View File

@ -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,
};
}

View File

@ -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,