mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(slack): resolve thread freshness owner (#114009)
This commit is contained in:
committed by
GitHub
parent
c0d4cafbcc
commit
3f27d76ea7
@@ -1,4 +1,5 @@
|
||||
// Slack plugin module implements prepare thread context behavior.
|
||||
import { resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-runtime";
|
||||
import {
|
||||
formatInboundEnvelope,
|
||||
resolveInboundSupplementalSenderAllowed,
|
||||
@@ -49,6 +50,7 @@ type SlackSessionResetFreshness = {
|
||||
type SlackSessionFreshnessRuntime = {
|
||||
session?: {
|
||||
resolveEntryResetFreshness?: (params: {
|
||||
defaultAgentId?: string;
|
||||
storePath?: string;
|
||||
sessionKey: string;
|
||||
sessionCfg?: OpenClawConfig["session"];
|
||||
@@ -67,6 +69,7 @@ function resolveSlackThreadSessionFreshness(params: {
|
||||
// intentionally keeps non-context helpers untyped for external plugins.
|
||||
const runtime = params.ctx.channelRuntime as SlackSessionFreshnessRuntime | undefined;
|
||||
return runtime?.session?.resolveEntryResetFreshness?.({
|
||||
defaultAgentId: resolveDefaultAgentId(params.ctx.cfg),
|
||||
storePath: params.storePath,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionCfg: params.ctx.cfg.session,
|
||||
|
||||
@@ -43,6 +43,32 @@ describe("resolveSessionEntryResetFreshness", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the configured default agent for an unqualified session key", async () => {
|
||||
const sessionKey = "global";
|
||||
const now = new Date("2026-01-02T12:00:00Z").getTime();
|
||||
await upsertSessionEntry(
|
||||
{ agentId: "ops", defaultAgentId: "ops", sessionKey, storePath },
|
||||
{
|
||||
sessionId: "session-global-ops",
|
||||
updatedAt: now,
|
||||
sessionStartedAt: now,
|
||||
lastInteractionAt: now,
|
||||
},
|
||||
);
|
||||
|
||||
const result = resolveSessionEntryResetFreshness({
|
||||
defaultAgentId: "ops",
|
||||
sessionKey,
|
||||
storePath,
|
||||
sessionCfg: {},
|
||||
resetType: "direct",
|
||||
now,
|
||||
});
|
||||
|
||||
expect(result.state).toBe("fresh");
|
||||
expect(result.entry?.sessionId).toBe("session-global-ops");
|
||||
});
|
||||
|
||||
it("resolves stale daily freshness from lifecycle timestamps instead of activity", async () => {
|
||||
const sessionKey = "agent:main:main:thread:100.000";
|
||||
const now = new Date("2026-01-02T12:00:00Z").getTime();
|
||||
|
||||
@@ -54,7 +54,8 @@ export function hasProviderOwnedSession(entry: SessionEntry | undefined): boolea
|
||||
export function resolveSessionEntryResetFreshness(
|
||||
params: ResolveSessionEntryResetFreshnessParams,
|
||||
): ResolvedSessionEntryResetFreshness {
|
||||
const agentId = params.agentId ?? resolveAgentIdFromSessionKey(params.sessionKey);
|
||||
const agentId =
|
||||
params.agentId ?? resolveAgentIdFromSessionKey(params.sessionKey, params.defaultAgentId);
|
||||
const sessionCfg = params.sessionCfg;
|
||||
const storePath =
|
||||
params.storePath ??
|
||||
|
||||
Reference in New Issue
Block a user