fix(core): unify session-key normalization and plugin boundary checks

This commit is contained in:
Peter Steinberger
2026-02-26 12:40:57 +00:00
parent e3385a6578
commit 4b71de384c
13 changed files with 182 additions and 34 deletions

View File

@@ -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", () => {

View File

@@ -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,
});
}

View 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,
});
}