MCPcopy Create free account
hub / github.com/MemTensor/MemOS / resolveHubClient

Function resolveHubClient

packages/memos-core/src/client/hub.ts:13–41  ·  view source on GitHub ↗
(store: SqliteStore, ctx: PluginContext, overrides?: { hubAddress?: string; userToken?: string })

Source from the content-addressed store, hash-verified

11}
12
13export async function resolveHubClient(store: SqliteStore, ctx: PluginContext, overrides?: { hubAddress?: string; userToken?: string }): Promise<ResolvedHubClient> {
14 const persisted = store.getClientHubConnection() as any;
15 if (persisted?.hubUrl && persisted?.userToken) {
16 return {
17 hubUrl: normalizeHubUrl(String(persisted.hubUrl)),
18 userToken: String(persisted.userToken),
19 userId: String(persisted.userId),
20 username: String(persisted.username ?? ""),
21 role: String(persisted.role ?? "member"),
22 };
23 }
24
25 const hubAddress = overrides?.hubAddress ?? ctx.config.sharing?.client?.hubAddress ?? "";
26 const userToken = overrides?.userToken ?? ctx.config.sharing?.client?.userToken ?? "";
27 if (!hubAddress || !userToken) {
28 throw new Error("hub client connection is not configured");
29 }
30
31 const hubUrl = normalizeHubUrl(hubAddress);
32 const me = await hubRequestJson(hubUrl, userToken, "/api/v1/hub/me", { method: "GET" }) as any;
33
34 return {
35 hubUrl,
36 userToken,
37 userId: String(me.id),
38 username: String(me.username ?? ""),
39 role: String(me.role ?? "member"),
40 };
41}
42
43export async function hubListMemories(
44 store: SqliteStore,

Callers 11

publishSkillBundleToHubFunction · 0.90
fetchHubSkillBundleFunction · 0.90
resolveHubClientAwareMethod · 0.90
hubListMemoriesFunction · 0.70
hubListTasksFunction · 0.70
hubListSkillsFunction · 0.70
hubSearchMemoriesFunction · 0.70
hubSearchSkillsFunction · 0.70
hubGetMemoryDetailFunction · 0.70
hubUpdateUsernameFunction · 0.70

Calls 3

normalizeHubUrlFunction · 0.70
hubRequestJsonFunction · 0.70

Tested by

no test coverage detected