Create session mapping entries during prepare
This commit is contained in:
parent
529965aa3b
commit
4cf4ae49af
4
dist/src/taskState.js
vendored
4
dist/src/taskState.js
vendored
@ -77,6 +77,10 @@ export async function upsertXWorkmateSessionMapping(api, input) {
|
||||
let mapping;
|
||||
await patchSessionEntry({
|
||||
sessionKey: input.openclawSessionKey,
|
||||
fallbackEntry: {
|
||||
sessionId: input.openclawSessionKey,
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
preserveActivity: true,
|
||||
update: (entry) => {
|
||||
const existing = readMappingFromEntry(entry);
|
||||
|
||||
@ -25,12 +25,17 @@ function createApiFixture(tasks: Record<string, unknown> = {}) {
|
||||
})),
|
||||
patchSessionEntry: async ({
|
||||
sessionKey,
|
||||
fallbackEntry,
|
||||
update,
|
||||
}: {
|
||||
sessionKey: string;
|
||||
fallbackEntry?: any;
|
||||
update: (entry: any) => Partial<any> | null;
|
||||
}) => {
|
||||
const current = sessions.get(sessionKey) ?? { sessionId: sessionKey, updatedAt: 0 };
|
||||
const current = sessions.get(sessionKey) ?? fallbackEntry;
|
||||
if (!current) {
|
||||
return null;
|
||||
}
|
||||
const patch = update(current);
|
||||
if (patch) {
|
||||
sessions.set(sessionKey, { ...current, ...patch });
|
||||
|
||||
@ -49,6 +49,7 @@ type SessionEntry = Record<string, unknown> & {
|
||||
|
||||
type PatchSessionEntry = (params: {
|
||||
sessionKey: string;
|
||||
fallbackEntry?: SessionEntry;
|
||||
preserveActivity?: boolean;
|
||||
update: (entry: SessionEntry) => Partial<SessionEntry> | null;
|
||||
}) => Promise<SessionEntry | null> | SessionEntry | null;
|
||||
@ -159,6 +160,10 @@ export async function upsertXWorkmateSessionMapping(
|
||||
let mapping: XWorkmateSessionMappingV1 | undefined;
|
||||
await patchSessionEntry({
|
||||
sessionKey: input.openclawSessionKey,
|
||||
fallbackEntry: {
|
||||
sessionId: input.openclawSessionKey,
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
preserveActivity: true,
|
||||
update: (entry) => {
|
||||
const existing = readMappingFromEntry(entry);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user