mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import {
|
|
collectCommandSecretAssignmentsFromSnapshot,
|
|
type CommandSecretAssignment,
|
|
} from "./command-config.js";
|
|
import { getActiveSecretsRuntimeSnapshot } from "./runtime.js";
|
|
|
|
export type { CommandSecretAssignment } from "./command-config.js";
|
|
|
|
export function resolveCommandSecretsFromActiveRuntimeSnapshot(params: {
|
|
commandName: string;
|
|
targetIds: ReadonlySet<string>;
|
|
}): { assignments: CommandSecretAssignment[]; diagnostics: string[]; inactiveRefPaths: string[] } {
|
|
const activeSnapshot = getActiveSecretsRuntimeSnapshot();
|
|
if (!activeSnapshot) {
|
|
throw new Error("Secrets runtime snapshot is not active.");
|
|
}
|
|
if (params.targetIds.size === 0) {
|
|
return { assignments: [], diagnostics: [], inactiveRefPaths: [] };
|
|
}
|
|
const inactiveRefPaths = [
|
|
...new Set(
|
|
activeSnapshot.warnings
|
|
.filter((warning) => warning.code === "SECRETS_REF_IGNORED_INACTIVE_SURFACE")
|
|
.map((warning) => warning.path),
|
|
),
|
|
];
|
|
const resolved = collectCommandSecretAssignmentsFromSnapshot({
|
|
sourceConfig: activeSnapshot.sourceConfig,
|
|
resolvedConfig: activeSnapshot.config,
|
|
commandName: params.commandName,
|
|
targetIds: params.targetIds,
|
|
inactiveRefPaths: new Set(inactiveRefPaths),
|
|
});
|
|
return {
|
|
assignments: resolved.assignments,
|
|
diagnostics: resolved.diagnostics,
|
|
inactiveRefPaths,
|
|
};
|
|
}
|