mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 09:33:06 +00:00
refactor(tasks): remove flow registry layer
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
import {
|
||||
configureFlowRegistryRuntime,
|
||||
type FlowRegistryStore,
|
||||
type FlowRegistryStoreSnapshot,
|
||||
} from "../tasks/flow-registry.store.js";
|
||||
import type { FlowRecord } from "../tasks/flow-registry.types.js";
|
||||
import {
|
||||
configureTaskRegistryRuntime,
|
||||
type TaskRegistryStore,
|
||||
@@ -22,24 +16,13 @@ function cloneDeliveryState(state: TaskDeliveryState): TaskDeliveryState {
|
||||
};
|
||||
}
|
||||
|
||||
function cloneFlow(flow: FlowRecord): FlowRecord {
|
||||
return {
|
||||
...flow,
|
||||
...(flow.requesterOrigin ? { requesterOrigin: { ...flow.requesterOrigin } } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export function installInMemoryTaskAndFlowRegistryRuntime(): {
|
||||
export function installInMemoryTaskRegistryRuntime(): {
|
||||
taskStore: TaskRegistryStore;
|
||||
flowStore: FlowRegistryStore;
|
||||
} {
|
||||
let taskSnapshot: TaskRegistryStoreSnapshot = {
|
||||
tasks: new Map<string, TaskRecord>(),
|
||||
deliveryStates: new Map<string, TaskDeliveryState>(),
|
||||
};
|
||||
let flowSnapshot: FlowRegistryStoreSnapshot = {
|
||||
flows: new Map<string, FlowRecord>(),
|
||||
};
|
||||
|
||||
const taskStore: TaskRegistryStore = {
|
||||
loadSnapshot: () => ({
|
||||
@@ -80,28 +63,6 @@ export function installInMemoryTaskAndFlowRegistryRuntime(): {
|
||||
},
|
||||
};
|
||||
|
||||
const flowStore: FlowRegistryStore = {
|
||||
loadSnapshot: () => ({
|
||||
flows: new Map(
|
||||
[...flowSnapshot.flows.entries()].map(([flowId, flow]) => [flowId, cloneFlow(flow)]),
|
||||
),
|
||||
}),
|
||||
saveSnapshot: (snapshot) => {
|
||||
flowSnapshot = {
|
||||
flows: new Map(
|
||||
[...snapshot.flows.entries()].map(([flowId, flow]) => [flowId, cloneFlow(flow)]),
|
||||
),
|
||||
};
|
||||
},
|
||||
upsertFlow: (flow) => {
|
||||
flowSnapshot.flows.set(flow.flowId, cloneFlow(flow));
|
||||
},
|
||||
deleteFlow: (flowId) => {
|
||||
flowSnapshot.flows.delete(flowId);
|
||||
},
|
||||
};
|
||||
|
||||
configureTaskRegistryRuntime({ store: taskStore });
|
||||
configureFlowRegistryRuntime({ store: flowStore });
|
||||
return { taskStore, flowStore };
|
||||
return { taskStore };
|
||||
}
|
||||
Reference in New Issue
Block a user