mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 19:21:08 +00:00
perf(secrets): trim runtime import walls
This commit is contained in:
39
src/secrets/runtime-command-secrets.ts
Normal file
39
src/secrets/runtime-command-secrets.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user