mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
refactor(agents): drop duplicate internal aliases
This commit is contained in:
@@ -15,7 +15,7 @@ const mocks = vi.hoisted(() => ({
|
||||
readMiniMaxCliCredentialsCached: vi.fn<(options?: unknown) => OAuthCredential | null>(() => null),
|
||||
}));
|
||||
|
||||
let readManagedExternalCliCredential: typeof import("./auth-profiles/external-cli-sync.js").readManagedExternalCliCredential;
|
||||
let readExternalCliBootstrapCredential: typeof import("./auth-profiles/external-cli-sync.js").readExternalCliBootstrapCredential;
|
||||
let resolveExternalCliAuthProfiles: typeof import("./auth-profiles/external-cli-sync.js").resolveExternalCliAuthProfiles;
|
||||
let hasUsableOAuthCredential: typeof import("./auth-profiles/external-cli-sync.js").hasUsableOAuthCredential;
|
||||
let isSafeToUseExternalCliCredential: typeof import("./auth-profiles/external-cli-sync.js").isSafeToUseExternalCliCredential;
|
||||
@@ -121,7 +121,7 @@ describe("external cli oauth resolution", () => {
|
||||
({
|
||||
hasUsableOAuthCredential,
|
||||
isSafeToUseExternalCliCredential,
|
||||
readManagedExternalCliCredential,
|
||||
readExternalCliBootstrapCredential,
|
||||
resolveExternalCliAuthProfiles,
|
||||
shouldBootstrapFromExternalCliCredential,
|
||||
shouldReplaceStoredOAuthCredential,
|
||||
@@ -299,7 +299,7 @@ describe("external cli oauth resolution", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const credential = readManagedExternalCliCredential({
|
||||
const credential = readExternalCliBootstrapCredential({
|
||||
profileId: OPENAI_CODEX_DEFAULT_PROFILE_ID,
|
||||
credential: makeOAuthCredential({ provider: "openai" }),
|
||||
});
|
||||
@@ -365,7 +365,7 @@ describe("external cli oauth resolution", () => {
|
||||
makeOAuthCredential({ provider: "openai" }),
|
||||
);
|
||||
|
||||
const credential = readManagedExternalCliCredential({
|
||||
const credential = readExternalCliBootstrapCredential({
|
||||
profileId: OPENAI_CODEX_DEFAULT_PROFILE_ID,
|
||||
credential: makeOAuthCredential({ provider: "anthropic" }),
|
||||
});
|
||||
|
||||
@@ -8,11 +8,11 @@ import { resolveEffectiveOAuthCredential } from "./effective-oauth.js";
|
||||
import type { OAuthCredential } from "./types.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
readManagedExternalCliCredential: vi.fn<() => OAuthCredential | null>(() => null),
|
||||
readExternalCliBootstrapCredential: vi.fn<() => OAuthCredential | null>(() => null),
|
||||
}));
|
||||
|
||||
vi.mock("./external-cli-sync.js", () => ({
|
||||
readManagedExternalCliCredential: mocks.readManagedExternalCliCredential,
|
||||
readExternalCliBootstrapCredential: mocks.readExternalCliBootstrapCredential,
|
||||
}));
|
||||
|
||||
function makeCredential(overrides: Partial<OAuthCredential> = {}): OAuthCredential {
|
||||
@@ -28,7 +28,7 @@ function makeCredential(overrides: Partial<OAuthCredential> = {}): OAuthCredenti
|
||||
|
||||
describe("resolveEffectiveOAuthCredential", () => {
|
||||
beforeEach(() => {
|
||||
mocks.readManagedExternalCliCredential.mockReset().mockReturnValue(null);
|
||||
mocks.readExternalCliBootstrapCredential.mockReset().mockReturnValue(null);
|
||||
});
|
||||
|
||||
it("uses external cli oauth only when local credentials are unusable and safe to bootstrap", () => {
|
||||
@@ -37,7 +37,7 @@ describe("resolveEffectiveOAuthCredential", () => {
|
||||
refresh: "fresh-cli-refresh-token",
|
||||
expires: Date.now() + 30 * 60_000,
|
||||
});
|
||||
mocks.readManagedExternalCliCredential.mockReturnValue(imported);
|
||||
mocks.readExternalCliBootstrapCredential.mockReturnValue(imported);
|
||||
|
||||
expect(
|
||||
resolveEffectiveOAuthCredential({
|
||||
@@ -58,7 +58,7 @@ describe("resolveEffectiveOAuthCredential", () => {
|
||||
refresh: "healthy-local-refresh-token",
|
||||
expires: Date.now() + 30 * 60_000,
|
||||
});
|
||||
mocks.readManagedExternalCliCredential.mockReturnValue(imported);
|
||||
mocks.readExternalCliBootstrapCredential.mockReturnValue(imported);
|
||||
|
||||
expect(
|
||||
resolveEffectiveOAuthCredential({
|
||||
@@ -75,7 +75,7 @@ describe("resolveEffectiveOAuthCredential", () => {
|
||||
expires: Date.now() + 30 * 60_000,
|
||||
accountId: "acct-external",
|
||||
});
|
||||
mocks.readManagedExternalCliCredential.mockReturnValue(imported);
|
||||
mocks.readExternalCliBootstrapCredential.mockReturnValue(imported);
|
||||
|
||||
expect(
|
||||
resolveEffectiveOAuthCredential({
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Delegates to the managed OAuth selector while allowing external CLI
|
||||
* bootstrap credentials to fill unusable local profile state.
|
||||
*/
|
||||
import { readManagedExternalCliCredential } from "./external-cli-sync.js";
|
||||
import { readExternalCliBootstrapCredential } from "./external-cli-sync.js";
|
||||
import { resolveEffectiveOAuthCredential as resolveManagedOAuthCredential } from "./oauth-manager.js";
|
||||
import type { OAuthCredential } from "./types.js";
|
||||
|
||||
@@ -17,7 +17,7 @@ export function resolveEffectiveOAuthCredential(params: {
|
||||
profileId: params.profileId,
|
||||
credential: params.credential,
|
||||
readBootstrapCredential: ({ profileId, credential }) =>
|
||||
readManagedExternalCliCredential({
|
||||
readExternalCliBootstrapCredential({
|
||||
profileId,
|
||||
credential,
|
||||
allowKeychainPrompt: params.allowKeychainPrompt ?? false,
|
||||
|
||||
@@ -223,8 +223,6 @@ export function readExternalCliBootstrapCredential(params: {
|
||||
);
|
||||
}
|
||||
|
||||
export const readManagedExternalCliCredential = readExternalCliBootstrapCredential;
|
||||
|
||||
/** Read a CLI credential as a fallback for refresh/runtime auth recovery. */
|
||||
export function readExternalCliFallbackCredential(params: {
|
||||
profileId: string;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* Tests runtime external OAuth overlays.
|
||||
* Covers provider plugin profiles, external CLI scoped discovery, persistence
|
||||
* rules, and compatibility aliases.
|
||||
* rules, and external CLI bootstrap policy.
|
||||
*/
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ProviderExternalAuthProfile } from "../../plugins/types.js";
|
||||
import { testing, overlayExternalAuthProfiles } from "./external-auth.js";
|
||||
import { readManagedExternalCliCredential } from "./external-cli-sync.js";
|
||||
import { readExternalCliBootstrapCredential } from "./external-cli-sync.js";
|
||||
import type { AuthProfileStore, OAuthCredential } from "./types.js";
|
||||
|
||||
const resolveExternalAuthProfilesWithPluginsMock = vi.fn<
|
||||
@@ -186,7 +186,7 @@ describe("auth external oauth helpers", () => {
|
||||
expect(overlaidProfile.access).toBe("fresh-cli-access-token");
|
||||
expect(overlaidProfile.refresh).toBe("fresh-cli-refresh-token");
|
||||
expect(overlaidProfile.accountId).toBe("acct-cli");
|
||||
const managedCredential = readManagedExternalCliCredential({
|
||||
const managedCredential = readExternalCliBootstrapCredential({
|
||||
profileId: "openai:default",
|
||||
credential: tokenlessCredential,
|
||||
});
|
||||
|
||||
@@ -46,7 +46,6 @@ vi.mock("./external-cli-sync.js", () => ({
|
||||
credential.expires - now > 5 * 60 * 1000,
|
||||
isSafeToUseExternalCliCredential: () => true,
|
||||
readExternalCliBootstrapCredential: () => null,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
shouldBootstrapFromExternalCliCredential: () => false,
|
||||
shouldReplaceStoredOAuthCredential: (existing: unknown, incoming: unknown) =>
|
||||
|
||||
@@ -26,8 +26,8 @@ import { log } from "./constants.js";
|
||||
import { resolveTokenExpiryState } from "./credential-state.js";
|
||||
import { formatAuthDoctorHint } from "./doctor.js";
|
||||
import {
|
||||
readExternalCliBootstrapCredential,
|
||||
readExternalCliFallbackCredential,
|
||||
readManagedExternalCliCredential,
|
||||
} from "./external-cli-sync.js";
|
||||
import { createOAuthManager, OAuthManagerRefreshError } from "./oauth-manager.js";
|
||||
import { OAuthRefreshFailureError } from "./oauth-refresh-failure.js";
|
||||
@@ -232,7 +232,7 @@ const oauthManager = createOAuthManager({
|
||||
buildApiKey: buildOAuthApiKey,
|
||||
refreshCredential: refreshOAuthCredential,
|
||||
readBootstrapCredential: ({ profileId, credential }) =>
|
||||
readManagedExternalCliCredential({
|
||||
readExternalCliBootstrapCredential({
|
||||
profileId,
|
||||
credential,
|
||||
}),
|
||||
|
||||
@@ -50,7 +50,7 @@ import {
|
||||
executePreparedCliRun,
|
||||
setCliRunnerExecuteTestDeps,
|
||||
} from "./cli-runner/execute.js";
|
||||
import { buildSystemPrompt, writeCliSystemPromptFile } from "./cli-runner/helpers.js";
|
||||
import { buildCliAgentSystemPrompt, writeCliSystemPromptFile } from "./cli-runner/helpers.js";
|
||||
import { cliBackendLog, formatCliBackendOutputDigest } from "./cli-runner/log.js";
|
||||
import { setCliRunnerPrepareTestDeps } from "./cli-runner/prepare.js";
|
||||
import type { PreparedCliRunContext } from "./cli-runner/types.js";
|
||||
@@ -391,7 +391,7 @@ describe("runCliAgent spawn path", () => {
|
||||
});
|
||||
|
||||
it("includes the OpenClaw skills prompt in CLI system prompts", () => {
|
||||
const systemPrompt = buildSystemPrompt({
|
||||
const systemPrompt = buildCliAgentSystemPrompt({
|
||||
workspaceDir: "/tmp",
|
||||
modelDisplay: "claude-cli/sonnet",
|
||||
tools: [],
|
||||
@@ -3710,7 +3710,7 @@ ${JSON.stringify({
|
||||
const { contextFiles } = await realResolveBootstrapContextForRun({
|
||||
workspaceDir,
|
||||
});
|
||||
const allArgs = buildSystemPrompt({
|
||||
const allArgs = buildCliAgentSystemPrompt({
|
||||
workspaceDir,
|
||||
modelDisplay: "claude-cli/sonnet",
|
||||
contextFiles,
|
||||
|
||||
@@ -197,9 +197,6 @@ export function buildCliAgentSystemPrompt(params: {
|
||||
});
|
||||
}
|
||||
|
||||
/** Alternate export name for the CLI system prompt builder. */
|
||||
export const buildSystemPrompt = buildCliAgentSystemPrompt;
|
||||
|
||||
/** Applies backend model aliases to a requested CLI model id. */
|
||||
export function normalizeCliModel(modelId: string, backend: CliBackendConfig): string {
|
||||
const trimmed = modelId.trim();
|
||||
|
||||
@@ -56,7 +56,6 @@ vi.mock("@clack/prompts", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("./migrate/skill-selection-prompt.js", () => ({
|
||||
promptMigrationSelectionValues: mocks.multiselect,
|
||||
promptMigrationSkillSelectionValues: mocks.multiselect,
|
||||
}));
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
resolveInteractiveMigrationPluginSelection,
|
||||
resolveInteractiveMigrationSkillSelection,
|
||||
} from "./migrate/selection.js";
|
||||
import { promptMigrationSelectionValues } from "./migrate/skill-selection-prompt.js";
|
||||
import { promptMigrationSkillSelectionValues } from "./migrate/skill-selection-prompt.js";
|
||||
import type {
|
||||
MigrateApplyOptions,
|
||||
MigrateCommonOptions,
|
||||
@@ -177,7 +177,7 @@ async function promptCodexMigrationSkillSelection(
|
||||
if (skillItems.length === 0) {
|
||||
return plan;
|
||||
}
|
||||
const selected = await promptMigrationSelectionValues({
|
||||
const selected = await promptMigrationSkillSelectionValues({
|
||||
message: stylePromptMessage("Select Codex skills to migrate into this agent"),
|
||||
options: [
|
||||
{
|
||||
@@ -238,7 +238,7 @@ async function promptCodexMigrationPluginSelection(
|
||||
if (pluginItems.length === 0) {
|
||||
return plan;
|
||||
}
|
||||
const selected = await promptMigrationSelectionValues({
|
||||
const selected = await promptMigrationSkillSelectionValues({
|
||||
message: stylePromptMessage("Select native Codex plugins to activate in this agent"),
|
||||
options: [
|
||||
{
|
||||
|
||||
@@ -255,10 +255,3 @@ export function promptMigrationSkillSelectionValues(
|
||||
|
||||
return prompt.prompt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility alias for plugin selection prompts that share the same picker.
|
||||
*
|
||||
* @deprecated Use promptMigrationSkillSelectionValues.
|
||||
*/
|
||||
export const promptMigrationSelectionValues = promptMigrationSkillSelectionValues;
|
||||
|
||||
Reference in New Issue
Block a user