refactor: trim migration helper exports

This commit is contained in:
Peter Steinberger
2026-05-01 19:55:37 +01:00
parent c566956b1f
commit 5c528a53f3
4 changed files with 16 additions and 33 deletions

View File

@@ -2,7 +2,7 @@ import os from "node:os";
import path from "node:path";
import { exists, isDirectory, readJsonObject, resolveHomePath } from "./helpers.js";
export type ClaudeArchivePath = {
type ClaudeArchivePath = {
id: string;
path: string;
relativePath: string;

View File

@@ -57,7 +57,7 @@ function providerConfig(entry: HermesProviderConfig): Record<string, unknown> {
};
}
export function collectHermesProviders(
function collectHermesProviders(
config: Record<string, unknown>,
modelRef?: string,
): HermesProviderConfig[] {

View File

@@ -7,29 +7,6 @@ import {
} from "openclaw/plugin-sdk/migration";
import { readString } from "./helpers.js";
export type HermesModelDetails = {
model: string;
};
export type HermesSecretDetails = {
envVar: string;
provider: string;
profileId: string;
};
export type HermesModelItem = MigrationItem & {
id: "config:default-model";
kind: "config";
action: "skip" | "update";
details: HermesModelDetails;
};
export type HermesSecretItem = MigrationItem & {
kind: "secret";
action: "skip" | "create";
details: HermesSecretDetails;
};
export const HERMES_REASON_ALREADY_CONFIGURED = "already configured";
export const HERMES_REASON_DEFAULT_MODEL_CONFIGURED = "default model already configured";
export const HERMES_REASON_INCLUDE_SECRETS = "use --include-secrets to import";
@@ -43,7 +20,7 @@ export function createHermesModelItem(params: {
model: string;
currentModel?: string;
overwrite?: boolean;
}): HermesModelItem {
}): MigrationItem {
const alreadyConfigured = params.currentModel === params.model;
const conflict = Boolean(params.currentModel && !params.overwrite && !alreadyConfigured);
return createMigrationItem({
@@ -58,10 +35,10 @@ export function createHermesModelItem(params: {
? HERMES_REASON_DEFAULT_MODEL_CONFIGURED
: undefined,
details: { model: params.model },
}) as HermesModelItem;
});
}
export function readHermesModelDetails(item: MigrationItem): HermesModelDetails | undefined {
export function readHermesModelDetails(item: MigrationItem): { model: string } | undefined {
const model = readString(item.details?.model);
return model ? { model } : undefined;
}
@@ -72,8 +49,12 @@ export function createHermesSecretItem(params: {
target: string;
includeSecrets?: boolean;
existsAlready?: boolean;
details: HermesSecretDetails;
}): HermesSecretItem {
details: {
envVar: string;
provider: string;
profileId: string;
};
}): MigrationItem {
const skipped = !params.includeSecrets;
const conflict = Boolean(params.existsAlready && !skipped);
return createMigrationItem({
@@ -90,10 +71,12 @@ export function createHermesSecretItem(params: {
? HERMES_REASON_AUTH_PROFILE_EXISTS
: undefined,
details: params.details,
}) as HermesSecretItem;
});
}
export function readHermesSecretDetails(item: MigrationItem): HermesSecretDetails | undefined {
export function readHermesSecretDetails(
item: MigrationItem,
): { envVar: string; provider: string; profileId: string } | undefined {
const envVar = readString(item.details?.envVar);
const provider = readString(item.details?.provider);
const profileId = readString(item.details?.profileId);

View File

@@ -13,7 +13,7 @@ export type HermesSource = {
archivePaths: HermesArchivePath[];
};
export type HermesArchivePath = {
type HermesArchivePath = {
id: string;
path: string;
relativePath: string;