mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 23:11:25 +00:00
fix(core): unify session-key normalization and plugin boundary checks
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveCronAgentSessionKey } from "./run.js";
|
||||
import { resolveCronAgentSessionKey } from "./session-key.js";
|
||||
|
||||
describe("resolveCronAgentSessionKey", () => {
|
||||
it("builds an agent-scoped key for legacy aliases", () => {
|
||||
|
||||
@@ -40,11 +40,7 @@ import {
|
||||
import type { AgentDefaultsConfig } from "../../config/types.js";
|
||||
import { registerAgentRunContext } from "../../infra/agent-events.js";
|
||||
import { logWarn } from "../../logger.js";
|
||||
import {
|
||||
buildAgentMainSessionKey,
|
||||
normalizeAgentId,
|
||||
parseAgentSessionKey,
|
||||
} from "../../routing/session-key.js";
|
||||
import { normalizeAgentId } from "../../routing/session-key.js";
|
||||
import {
|
||||
buildSafeExternalPrompt,
|
||||
detectSuspiciousPatterns,
|
||||
@@ -67,6 +63,7 @@ import {
|
||||
pickSummaryFromPayloads,
|
||||
resolveHeartbeatAckMaxChars,
|
||||
} from "./helpers.js";
|
||||
import { resolveCronAgentSessionKey } from "./session-key.js";
|
||||
import { resolveCronSession } from "./session.js";
|
||||
import { resolveCronSkillsSnapshot } from "./skills-snapshot.js";
|
||||
|
||||
@@ -647,18 +644,3 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
|
||||
return resolveRunOutcome({ delivered, deliveryAttempted });
|
||||
}
|
||||
|
||||
export function resolveCronAgentSessionKey(params: {
|
||||
sessionKey: string;
|
||||
agentId: string;
|
||||
}): string {
|
||||
const baseSessionKey = params.sessionKey.trim();
|
||||
const normalizedBaseSessionKey = baseSessionKey.toLowerCase();
|
||||
if (parseAgentSessionKey(normalizedBaseSessionKey)) {
|
||||
return normalizedBaseSessionKey;
|
||||
}
|
||||
return buildAgentMainSessionKey({
|
||||
agentId: params.agentId,
|
||||
mainKey: baseSessionKey,
|
||||
});
|
||||
}
|
||||
|
||||
13
src/cron/isolated-agent/session-key.ts
Normal file
13
src/cron/isolated-agent/session-key.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { toAgentStoreSessionKey } from "../../routing/session-key.js";
|
||||
|
||||
export function resolveCronAgentSessionKey(params: {
|
||||
sessionKey: string;
|
||||
agentId: string;
|
||||
mainKey?: string | undefined;
|
||||
}): string {
|
||||
return toAgentStoreSessionKey({
|
||||
agentId: params.agentId,
|
||||
requestKey: params.sessionKey.trim(),
|
||||
mainKey: params.mainKey,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user