mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 01:56:38 +00:00
fix(cron): normalize skill-filter snapshots and split isolated run helpers
This commit is contained in:
37
src/cron/isolated-agent/skills-snapshot.ts
Normal file
37
src/cron/isolated-agent/skills-snapshot.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resolveAgentSkillsFilter } from "../../agents/agent-scope.js";
|
||||
import { buildWorkspaceSkillSnapshot, type SkillSnapshot } from "../../agents/skills.js";
|
||||
import { matchesSkillFilter } from "../../agents/skills/filter.js";
|
||||
import { getSkillsSnapshotVersion } from "../../agents/skills/refresh.js";
|
||||
import { getRemoteSkillEligibility } from "../../infra/skills-remote.js";
|
||||
|
||||
export function resolveCronSkillsSnapshot(params: {
|
||||
workspaceDir: string;
|
||||
config: OpenClawConfig;
|
||||
agentId: string;
|
||||
existingSnapshot?: SkillSnapshot;
|
||||
isFastTestEnv: boolean;
|
||||
}): SkillSnapshot {
|
||||
if (params.isFastTestEnv) {
|
||||
// Fast unit-test mode skips filesystem scans and snapshot refresh writes.
|
||||
return params.existingSnapshot ?? { prompt: "", skills: [] };
|
||||
}
|
||||
|
||||
const snapshotVersion = getSkillsSnapshotVersion(params.workspaceDir);
|
||||
const skillFilter = resolveAgentSkillsFilter(params.config, params.agentId);
|
||||
const existingSnapshot = params.existingSnapshot;
|
||||
const shouldRefresh =
|
||||
!existingSnapshot ||
|
||||
existingSnapshot.version !== snapshotVersion ||
|
||||
!matchesSkillFilter(existingSnapshot.skillFilter, skillFilter);
|
||||
if (!shouldRefresh) {
|
||||
return existingSnapshot;
|
||||
}
|
||||
|
||||
return buildWorkspaceSkillSnapshot(params.workspaceDir, {
|
||||
config: params.config,
|
||||
skillFilter,
|
||||
eligibility: { remote: getRemoteSkillEligibility() },
|
||||
snapshotVersion,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user