Skip to content

Commit 64e2753

Browse files
authored
refactor(memory-wiki): inline gateway source sync (#134992)
1 parent ac2cd78 commit 64e2753

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

‎extensions/memory-wiki/src/gateway.ts‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,6 @@ function respondError(respond: GatewayRespond, error: unknown) {
9999
respond(false, undefined, { code: "internal_error", message });
100100
}
101101

102-
async function syncImportedSourcesIfNeeded(
103-
config: ResolvedMemoryWikiConfig,
104-
appConfig?: OpenClawConfig,
105-
signal?: AbortSignal,
106-
) {
107-
await syncMemoryWikiImportedSources({
108-
config,
109-
appConfig,
110-
...(signal ? { signal } : {}),
111-
});
112-
}
113-
114102
export function registerMemoryWikiGatewayMethods(params: {
115103
api: OpenClawPluginApi;
116104
config: ResolvedMemoryWikiConfig;
@@ -189,7 +177,7 @@ export function registerMemoryWikiGatewayMethods(params: {
189177
async ({ params: requestParams, respond }) => {
190178
try {
191179
const { appConfig, config, signal } = resolveRequestContext(requestParams);
192-
await syncImportedSourcesIfNeeded(config, appConfig, signal);
180+
await syncMemoryWikiImportedSources({ config, appConfig, ...(signal ? { signal } : {}) });
193181
respond(
194182
true,
195183
await resolveMemoryWikiStatus(config, {
@@ -266,7 +254,7 @@ export function registerMemoryWikiGatewayMethods(params: {
266254
async ({ params: requestParams, respond }) => {
267255
try {
268256
const { appConfig, config, signal } = resolveRequestContext(requestParams);
269-
await syncImportedSourcesIfNeeded(config, appConfig, signal);
257+
await syncMemoryWikiImportedSources({ config, appConfig, ...(signal ? { signal } : {}) });
270258
const status = await resolveMemoryWikiStatus(config, {
271259
appConfig,
272260
});
@@ -283,7 +271,7 @@ export function registerMemoryWikiGatewayMethods(params: {
283271
async ({ params: requestParams, respond }) => {
284272
try {
285273
const { appConfig, config, signal } = resolveRequestContext(requestParams);
286-
await syncImportedSourcesIfNeeded(config, appConfig, signal);
274+
await syncMemoryWikiImportedSources({ config, appConfig, ...(signal ? { signal } : {}) });
287275
respond(true, await compileMemoryWikiVault(config, signal ? { signal } : undefined));
288276
} catch (error) {
289277
respondError(respond, error);
@@ -320,7 +308,7 @@ export function registerMemoryWikiGatewayMethods(params: {
320308
async ({ params: requestParams, respond }) => {
321309
try {
322310
const { appConfig, config, signal } = resolveRequestContext(requestParams);
323-
await syncImportedSourcesIfNeeded(config, appConfig, signal);
311+
await syncMemoryWikiImportedSources({ config, appConfig, ...(signal ? { signal } : {}) });
324312
respond(true, await lintMemoryWikiVault(config, signal ? { signal } : undefined));
325313
} catch (error) {
326314
respondError(respond, error);
@@ -377,7 +365,7 @@ export function registerMemoryWikiGatewayMethods(params: {
377365
async ({ params: requestParams, respond }) => {
378366
try {
379367
const { agentId, appConfig, config, signal } = resolveRequestContext(requestParams);
380-
await syncImportedSourcesIfNeeded(config, appConfig, signal);
368+
await syncMemoryWikiImportedSources({ config, appConfig, ...(signal ? { signal } : {}) });
381369
const query = readStringParam(requestParams, "query", { required: true });
382370
const maxResults = readPositiveIntegerParam(requestParams, "maxResults");
383371
const searchBackend = readEnumParam(requestParams, "backend", WIKI_SEARCH_BACKENDS);
@@ -410,7 +398,7 @@ export function registerMemoryWikiGatewayMethods(params: {
410398
const { appConfig, config, signal } = resolveRequestContext(requestParams);
411399
// Source sync can write imported pages and indexes, so validate first.
412400
const mutation = normalizeMemoryWikiMutationInput(requestParams);
413-
await syncImportedSourcesIfNeeded(config, appConfig, signal);
401+
await syncMemoryWikiImportedSources({ config, appConfig, ...(signal ? { signal } : {}) });
414402
respond(
415403
true,
416404
await applyMemoryWikiMutation({
@@ -431,7 +419,7 @@ export function registerMemoryWikiGatewayMethods(params: {
431419
async ({ params: requestParams, respond }) => {
432420
try {
433421
const { agentId, appConfig, config, signal } = resolveRequestContext(requestParams);
434-
await syncImportedSourcesIfNeeded(config, appConfig, signal);
422+
await syncMemoryWikiImportedSources({ config, appConfig, ...(signal ? { signal } : {}) });
435423
const lookup = readStringParam(requestParams, "lookup", { required: true });
436424
const fromLine = readPositiveIntegerParam(requestParams, "fromLine");
437425
const lineCount = readPositiveIntegerParam(requestParams, "lineCount");

0 commit comments

Comments
 (0)