@memtensor/memos-local-openclaw-plugin 1.0.4-beta.4 → 1.0.4-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +22 -39
  2. package/dist/capture/index.d.ts.map +1 -1
  3. package/dist/capture/index.js +6 -0
  4. package/dist/capture/index.js.map +1 -1
  5. package/dist/config.d.ts +1 -2
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +3 -72
  8. package/dist/config.js.map +1 -1
  9. package/dist/embedding/index.d.ts +2 -4
  10. package/dist/embedding/index.d.ts.map +1 -1
  11. package/dist/embedding/index.js +1 -17
  12. package/dist/embedding/index.js.map +1 -1
  13. package/dist/index.d.ts +0 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -4
  16. package/dist/index.js.map +1 -1
  17. package/dist/ingest/providers/index.d.ts +2 -10
  18. package/dist/ingest/providers/index.d.ts.map +1 -1
  19. package/dist/ingest/providers/index.js +43 -209
  20. package/dist/ingest/providers/index.js.map +1 -1
  21. package/dist/ingest/providers/openai.d.ts +0 -1
  22. package/dist/ingest/providers/openai.d.ts.map +1 -1
  23. package/dist/ingest/providers/openai.js +0 -1
  24. package/dist/ingest/providers/openai.js.map +1 -1
  25. package/dist/ingest/task-processor.js +1 -1
  26. package/dist/ingest/task-processor.js.map +1 -1
  27. package/dist/recall/engine.js +1 -1
  28. package/dist/recall/engine.js.map +1 -1
  29. package/dist/shared/llm-call.d.ts +2 -4
  30. package/dist/shared/llm-call.d.ts.map +1 -1
  31. package/dist/shared/llm-call.js +81 -20
  32. package/dist/shared/llm-call.js.map +1 -1
  33. package/dist/skill/evaluator.d.ts.map +1 -1
  34. package/dist/skill/evaluator.js +2 -2
  35. package/dist/skill/evaluator.js.map +1 -1
  36. package/dist/skill/evolver.d.ts +2 -0
  37. package/dist/skill/evolver.d.ts.map +1 -1
  38. package/dist/skill/evolver.js +3 -0
  39. package/dist/skill/evolver.js.map +1 -1
  40. package/dist/skill/generator.d.ts.map +1 -1
  41. package/dist/skill/generator.js +4 -4
  42. package/dist/skill/generator.js.map +1 -1
  43. package/dist/skill/upgrader.js +1 -1
  44. package/dist/skill/upgrader.js.map +1 -1
  45. package/dist/skill/validator.js +1 -1
  46. package/dist/skill/validator.js.map +1 -1
  47. package/dist/storage/ensure-binding.d.ts.map +1 -1
  48. package/dist/storage/ensure-binding.js +1 -3
  49. package/dist/storage/ensure-binding.js.map +1 -1
  50. package/dist/storage/sqlite.d.ts +0 -294
  51. package/dist/storage/sqlite.d.ts.map +1 -1
  52. package/dist/storage/sqlite.js +0 -821
  53. package/dist/storage/sqlite.js.map +1 -1
  54. package/dist/telemetry.d.ts +12 -5
  55. package/dist/telemetry.d.ts.map +1 -1
  56. package/dist/telemetry.js +135 -38
  57. package/dist/telemetry.js.map +1 -1
  58. package/dist/tools/index.d.ts +0 -1
  59. package/dist/tools/index.d.ts.map +1 -1
  60. package/dist/tools/index.js +1 -3
  61. package/dist/tools/index.js.map +1 -1
  62. package/dist/tools/memory-search.d.ts +2 -3
  63. package/dist/tools/memory-search.d.ts.map +1 -1
  64. package/dist/tools/memory-search.js +7 -48
  65. package/dist/tools/memory-search.js.map +1 -1
  66. package/dist/types.d.ts +2 -49
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/types.js.map +1 -1
  69. package/dist/viewer/html.d.ts.map +1 -1
  70. package/dist/viewer/html.js +471 -2974
  71. package/dist/viewer/html.js.map +1 -1
  72. package/dist/viewer/server.d.ts +0 -45
  73. package/dist/viewer/server.d.ts.map +1 -1
  74. package/dist/viewer/server.js +18 -1155
  75. package/dist/viewer/server.js.map +1 -1
  76. package/index.ts +42 -430
  77. package/openclaw.plugin.json +1 -2
  78. package/package.json +3 -4
  79. package/scripts/postinstall.cjs +46 -283
  80. package/skill/memos-memory-guide/SKILL.md +2 -26
  81. package/src/capture/index.ts +8 -0
  82. package/src/config.ts +3 -94
  83. package/src/embedding/index.ts +1 -21
  84. package/src/index.ts +4 -7
  85. package/src/ingest/providers/index.ts +46 -246
  86. package/src/ingest/providers/openai.ts +1 -1
  87. package/src/ingest/task-processor.ts +1 -1
  88. package/src/recall/engine.ts +1 -1
  89. package/src/shared/llm-call.ts +95 -23
  90. package/src/skill/evaluator.ts +2 -3
  91. package/src/skill/evolver.ts +5 -0
  92. package/src/skill/generator.ts +4 -6
  93. package/src/skill/upgrader.ts +1 -1
  94. package/src/skill/validator.ts +1 -1
  95. package/src/storage/ensure-binding.ts +1 -3
  96. package/src/storage/sqlite.ts +0 -1085
  97. package/src/telemetry.ts +152 -39
  98. package/src/tools/index.ts +0 -1
  99. package/src/tools/memory-search.ts +8 -57
  100. package/src/types.ts +2 -44
  101. package/src/viewer/html.ts +471 -2974
  102. package/src/viewer/server.ts +21 -1070
  103. package/dist/client/connector.d.ts +0 -30
  104. package/dist/client/connector.d.ts.map +0 -1
  105. package/dist/client/connector.js +0 -219
  106. package/dist/client/connector.js.map +0 -1
  107. package/dist/client/hub.d.ts +0 -61
  108. package/dist/client/hub.d.ts.map +0 -1
  109. package/dist/client/hub.js +0 -148
  110. package/dist/client/hub.js.map +0 -1
  111. package/dist/client/skill-sync.d.ts +0 -29
  112. package/dist/client/skill-sync.d.ts.map +0 -1
  113. package/dist/client/skill-sync.js +0 -216
  114. package/dist/client/skill-sync.js.map +0 -1
  115. package/dist/hub/auth.d.ts +0 -19
  116. package/dist/hub/auth.d.ts.map +0 -1
  117. package/dist/hub/auth.js +0 -70
  118. package/dist/hub/auth.js.map +0 -1
  119. package/dist/hub/server.d.ts +0 -41
  120. package/dist/hub/server.d.ts.map +0 -1
  121. package/dist/hub/server.js +0 -747
  122. package/dist/hub/server.js.map +0 -1
  123. package/dist/hub/user-manager.d.ts +0 -29
  124. package/dist/hub/user-manager.d.ts.map +0 -1
  125. package/dist/hub/user-manager.js +0 -125
  126. package/dist/hub/user-manager.js.map +0 -1
  127. package/dist/openclaw-api.d.ts +0 -53
  128. package/dist/openclaw-api.d.ts.map +0 -1
  129. package/dist/openclaw-api.js +0 -189
  130. package/dist/openclaw-api.js.map +0 -1
  131. package/dist/sharing/types.contract.d.ts +0 -2
  132. package/dist/sharing/types.contract.d.ts.map +0 -1
  133. package/dist/sharing/types.contract.js +0 -3
  134. package/dist/sharing/types.contract.js.map +0 -1
  135. package/dist/sharing/types.d.ts +0 -80
  136. package/dist/sharing/types.d.ts.map +0 -1
  137. package/dist/sharing/types.js +0 -3
  138. package/dist/sharing/types.js.map +0 -1
  139. package/dist/tools/network-memory-detail.d.ts +0 -4
  140. package/dist/tools/network-memory-detail.d.ts.map +0 -1
  141. package/dist/tools/network-memory-detail.js +0 -34
  142. package/dist/tools/network-memory-detail.js.map +0 -1
  143. package/src/client/connector.ts +0 -218
  144. package/src/client/hub.ts +0 -189
  145. package/src/client/skill-sync.ts +0 -202
  146. package/src/hub/auth.ts +0 -78
  147. package/src/hub/server.ts +0 -740
  148. package/src/hub/user-manager.ts +0 -139
  149. package/src/openclaw-api.ts +0 -287
  150. package/src/sharing/types.contract.ts +0 -40
  151. package/src/sharing/types.ts +0 -102
  152. package/src/tools/network-memory-detail.ts +0 -34
@@ -1,139 +0,0 @@
1
- import { randomUUID, createHash } from "crypto";
2
- import { issueUserToken } from "./auth";
3
- import type { Logger } from "../types";
4
- import type { UserInfo } from "../sharing/types";
5
- import type { SqliteStore } from "../storage/sqlite";
6
-
7
- type ManagedHubUser = UserInfo & { tokenHash: string; createdAt: number; approvedAt: number | null };
8
-
9
- export class HubUserManager {
10
- constructor(private store: SqliteStore, private log: Logger) {}
11
-
12
- createPendingUser(input: { username: string; deviceName?: string }): ManagedHubUser {
13
- const user = {
14
- id: randomUUID(),
15
- username: input.username,
16
- deviceName: input.deviceName,
17
- role: "member" as const,
18
- status: "pending" as const,
19
- groups: [],
20
- tokenHash: "",
21
- createdAt: Date.now(),
22
- approvedAt: null,
23
- };
24
- this.store.upsertHubUser(user);
25
- return user;
26
- }
27
-
28
- listPendingUsers(): ManagedHubUser[] {
29
- return this.store.listHubUsers("pending");
30
- }
31
-
32
- approveUser(userId: string, token: string): ManagedHubUser | null {
33
- const user = this.store.getHubUser(userId);
34
- if (!user) return null;
35
- const updated = {
36
- ...user,
37
- status: "active" as const,
38
- tokenHash: createHash("sha256").update(token).digest("hex"),
39
- approvedAt: Date.now(),
40
- };
41
- this.store.upsertHubUser(updated);
42
- return updated;
43
- }
44
-
45
- ensureBootstrapAdmin(secret: string, username = "admin", bootstrapUserId?: string, bootstrapToken?: string): { user: ManagedHubUser; token: string } {
46
- if (bootstrapUserId) {
47
- const bootstrapUser = this.store.getHubUser(bootstrapUserId);
48
- if (bootstrapUser && bootstrapUser.role === "admin" && bootstrapUser.status === "active") {
49
- if (bootstrapToken && bootstrapUser.tokenHash === createHash("sha256").update(bootstrapToken).digest("hex")) {
50
- return { user: bootstrapUser, token: bootstrapToken };
51
- }
52
- const refreshedToken = issueUserToken(
53
- { userId: bootstrapUser.id, username: bootstrapUser.username, role: bootstrapUser.role, status: bootstrapUser.status },
54
- secret,
55
- 3650 * 24 * 60 * 60 * 1000,
56
- );
57
- const refreshedUser: ManagedHubUser = {
58
- ...bootstrapUser,
59
- tokenHash: createHash("sha256").update(refreshedToken).digest("hex"),
60
- };
61
- this.store.upsertHubUser(refreshedUser);
62
- return { user: refreshedUser, token: refreshedToken };
63
- }
64
- }
65
-
66
- const existing = this.store.listHubUsers().find((user) => user.role === "admin" && user.status === "active");
67
- if (existing) {
68
- const refreshedToken = issueUserToken(
69
- { userId: existing.id, username: existing.username, role: existing.role, status: existing.status },
70
- secret,
71
- 3650 * 24 * 60 * 60 * 1000,
72
- );
73
- const refreshedUser: ManagedHubUser = {
74
- ...existing,
75
- tokenHash: createHash("sha256").update(refreshedToken).digest("hex"),
76
- };
77
- this.store.upsertHubUser(refreshedUser);
78
- return { user: refreshedUser, token: refreshedToken };
79
- }
80
-
81
- const user: ManagedHubUser = {
82
- id: randomUUID(),
83
- username,
84
- deviceName: "hub",
85
- role: "admin",
86
- status: "active",
87
- groups: [],
88
- tokenHash: "",
89
- createdAt: Date.now(),
90
- approvedAt: Date.now(),
91
- };
92
- const token = issueUserToken(
93
- { userId: user.id, username: user.username, role: user.role, status: user.status },
94
- secret,
95
- 3650 * 24 * 60 * 60 * 1000,
96
- );
97
- user.tokenHash = createHash("sha256").update(token).digest("hex");
98
- this.store.upsertHubUser(user);
99
- return { user, token };
100
- }
101
-
102
- isUsernameTaken(username: string, excludeUserId?: string): boolean {
103
- const users = this.store.listHubUsers();
104
- return users.some(u => u.username === username && u.id !== excludeUserId);
105
- }
106
-
107
- updateUsername(userId: string, newUsername: string): ManagedHubUser | null {
108
- const user = this.store.getHubUser(userId);
109
- if (!user) return null;
110
- const updated = { ...user, username: newUsername };
111
- this.store.upsertHubUser(updated);
112
- return updated;
113
- }
114
-
115
- rejectUser(userId: string): ManagedHubUser | null {
116
- const user = this.store.getHubUser(userId);
117
- if (!user) return null;
118
- const updated = {
119
- ...user,
120
- status: "rejected" as const,
121
- approvedAt: Date.now(),
122
- };
123
- this.store.upsertHubUser(updated);
124
- return updated;
125
- }
126
-
127
- resetToPending(userId: string): ManagedHubUser | null {
128
- const user = this.store.getHubUser(userId);
129
- if (!user) return null;
130
- const updated = {
131
- ...user,
132
- status: "pending" as const,
133
- tokenHash: "",
134
- approvedAt: null,
135
- };
136
- this.store.upsertHubUser(updated);
137
- return updated;
138
- }
139
- }
@@ -1,287 +0,0 @@
1
- /**
2
- * OpenClaw Host Model Proxy
3
- *
4
- * Reads the host's configured model providers (api.config.models.providers)
5
- * and proxies completion / embedding requests via OpenAI-compatible HTTP calls.
6
- */
7
-
8
- import type { Logger, OpenClawAPI } from "./types";
9
-
10
- // ── Request / Response types ────────────────────────────────────────
11
-
12
- export interface OpenClawEmbedRequest {
13
- texts: string[];
14
- model?: string;
15
- }
16
-
17
- export interface OpenClawEmbedResponse {
18
- embeddings: number[][];
19
- dimensions: number;
20
- }
21
-
22
- export interface OpenClawCompleteRequest {
23
- prompt: string;
24
- maxTokens?: number;
25
- temperature?: number;
26
- model?: string;
27
- }
28
-
29
- export interface OpenClawCompleteResponse {
30
- text: string;
31
- }
32
-
33
- // ── Host model config (mirrors OpenClaw SDK types loosely) ──────────
34
-
35
- export interface HostModelDefinition {
36
- id: string;
37
- name: string;
38
- api?: string;
39
- [key: string]: unknown;
40
- }
41
-
42
- export interface HostModelProvider {
43
- baseUrl: string;
44
- apiKey?: string | { source: string; provider: string; id: string };
45
- api?: string;
46
- headers?: Record<string, string>;
47
- models: HostModelDefinition[];
48
- }
49
-
50
- export interface HostModelsConfig {
51
- providers?: Record<string, HostModelProvider>;
52
- }
53
-
54
- // ── Resolved provider info (internal) ───────────────────────────────
55
-
56
- interface ResolvedProvider {
57
- name: string;
58
- baseUrl: string;
59
- apiKey?: string;
60
- api?: string;
61
- headers?: Record<string, string>;
62
- model: string;
63
- }
64
-
65
- // ── Client ──────────────────────────────────────────────────────────
66
-
67
- export class OpenClawAPIClient implements OpenClawAPI {
68
- private completionProvider: ResolvedProvider | undefined;
69
- private embeddingProvider: ResolvedProvider | undefined;
70
-
71
- constructor(
72
- private log: Logger,
73
- hostModels?: HostModelsConfig,
74
- ) {
75
- if (hostModels?.providers) {
76
- this.completionProvider = pickCompletionProvider(hostModels.providers, log);
77
- this.embeddingProvider = pickEmbeddingProvider(hostModels.providers, log);
78
- }
79
- }
80
-
81
- // ── Embedding ─────────────────────────────────────────────────────
82
-
83
- async embed(request: OpenClawEmbedRequest): Promise<OpenClawEmbedResponse> {
84
- const provider = this.embeddingProvider;
85
- if (!provider) {
86
- throw new Error(
87
- "No host embedding provider available. " +
88
- "Configure a model provider with an embedding model in OpenClaw, " +
89
- "or use an explicit embedding provider (openai, gemini, cohere, etc.)."
90
- );
91
- }
92
-
93
- const model = request.model ?? provider.model;
94
- const endpoint = normalizeEndpoint(provider.baseUrl, "/embeddings");
95
-
96
- this.log.debug(`OpenClawAPI.embed → ${provider.name} (${model}) [${request.texts.length} texts]`);
97
-
98
- const resp = await fetch(endpoint, {
99
- method: "POST",
100
- headers: buildHeaders(provider),
101
- body: JSON.stringify({ input: request.texts, model }),
102
- signal: AbortSignal.timeout(30_000),
103
- });
104
-
105
- if (!resp.ok) {
106
- const body = await resp.text();
107
- throw new Error(`Host embedding failed (${provider.name} ${resp.status}): ${body}`);
108
- }
109
-
110
- const json = (await resp.json()) as {
111
- data: Array<{ embedding: number[] }>;
112
- };
113
-
114
- const embeddings = json.data.map((d) => d.embedding);
115
- const dimensions = embeddings[0]?.length ?? 0;
116
-
117
- this.log.debug(`OpenClawAPI.embed ← ${embeddings.length} vectors, dim=${dimensions}`);
118
- return { embeddings, dimensions };
119
- }
120
-
121
- // ── Completion ────────────────────────────────────────────────────
122
-
123
- async complete(request: OpenClawCompleteRequest): Promise<OpenClawCompleteResponse> {
124
- const provider = this.completionProvider;
125
- if (!provider) {
126
- throw new Error(
127
- "No host completion provider available. " +
128
- "Configure a model provider in OpenClaw, " +
129
- "or use an explicit summarizer provider (openai, anthropic, gemini, etc.)."
130
- );
131
- }
132
-
133
- const model = request.model ?? provider.model;
134
- const endpoint = normalizeEndpoint(provider.baseUrl, "/chat/completions");
135
-
136
- this.log.debug(`OpenClawAPI.complete → ${provider.name} (${model})`);
137
-
138
- const body: Record<string, unknown> = {
139
- model,
140
- messages: [{ role: "user", content: request.prompt }],
141
- temperature: request.temperature ?? 0,
142
- };
143
- if (request.maxTokens) {
144
- body.max_tokens = request.maxTokens;
145
- }
146
-
147
- const resp = await fetch(endpoint, {
148
- method: "POST",
149
- headers: buildHeaders(provider),
150
- body: JSON.stringify(body),
151
- signal: AbortSignal.timeout(60_000),
152
- });
153
-
154
- if (!resp.ok) {
155
- const respBody = await resp.text();
156
- throw new Error(`Host completion failed (${provider.name} ${resp.status}): ${respBody}`);
157
- }
158
-
159
- const json = (await resp.json()) as {
160
- choices: Array<{ message: { content: string } }>;
161
- };
162
-
163
- const text = json.choices?.[0]?.message?.content ?? "";
164
- this.log.debug(`OpenClawAPI.complete ← ${text.length} chars`);
165
- return { text };
166
- }
167
- }
168
-
169
- // ── Helpers ─────────────────────────────────────────────────────────
170
-
171
- /**
172
- * Resolve a SecretInput (string | SecretRef) to a plain string.
173
- * For env-sourced SecretRef, reads from process.env.
174
- * Other sources are not supported — returns undefined.
175
- */
176
- function resolveApiKey(
177
- input: string | { source: string; provider: string; id: string } | undefined,
178
- ): string | undefined {
179
- if (!input) return undefined;
180
- if (typeof input === "string") return input;
181
- // SecretRef — only env source is supported in plugin context
182
- if (input.source === "env") return process.env[input.id];
183
- return undefined;
184
- }
185
-
186
- function buildHeaders(provider: ResolvedProvider): Record<string, string> {
187
- const headers: Record<string, string> = {
188
- "Content-Type": "application/json",
189
- ...provider.headers,
190
- };
191
- if (provider.apiKey) {
192
- headers["Authorization"] = `Bearer ${provider.apiKey}`;
193
- }
194
- return headers;
195
- }
196
-
197
- /**
198
- * Normalize base URL + path suffix.
199
- * e.g. "https://api.openai.com/v1" + "/chat/completions"
200
- * → "https://api.openai.com/v1/chat/completions"
201
- */
202
- function normalizeEndpoint(baseUrl: string, suffix: string): string {
203
- const base = baseUrl.replace(/\/+$/, "");
204
- // If baseUrl already ends with the suffix, don't double-append
205
- if (base.endsWith(suffix)) return base;
206
- return `${base}${suffix}`;
207
- }
208
-
209
- /**
210
- * Pick the best provider for chat completions.
211
- * Priority: openai-completions API > has apiKey > first with models.
212
- */
213
- function pickCompletionProvider(
214
- providers: Record<string, HostModelProvider>,
215
- log: Logger,
216
- ): ResolvedProvider | undefined {
217
- const entries = Object.entries(providers).filter(([, p]) => p.models?.length > 0);
218
- if (entries.length === 0) return undefined;
219
-
220
- // Sort: prefer openai-completions api, then providers with apiKey
221
- entries.sort(([, a], [, b]) => {
222
- const aScore = (a.api === "openai-completions" ? 2 : 0) + (resolveApiKey(a.apiKey) ? 1 : 0);
223
- const bScore = (b.api === "openai-completions" ? 2 : 0) + (resolveApiKey(b.apiKey) ? 1 : 0);
224
- return bScore - aScore;
225
- });
226
-
227
- const [name, provider] = entries[0];
228
- const model = provider.models[0].id;
229
- log.info(`Host completion provider: ${name} → ${model}`);
230
-
231
- return {
232
- name,
233
- baseUrl: provider.baseUrl,
234
- apiKey: resolveApiKey(provider.apiKey),
235
- api: provider.api,
236
- headers: provider.headers,
237
- model,
238
- };
239
- }
240
-
241
- /**
242
- * Pick the best provider for embeddings.
243
- * Priority: model name contains "embed" > first provider with apiKey.
244
- */
245
- function pickEmbeddingProvider(
246
- providers: Record<string, HostModelProvider>,
247
- log: Logger,
248
- ): ResolvedProvider | undefined {
249
- const entries = Object.entries(providers).filter(([, p]) => p.models?.length > 0);
250
- if (entries.length === 0) return undefined;
251
-
252
- // Try to find a provider that has an embedding model
253
- for (const [name, provider] of entries) {
254
- const embedModel = provider.models.find((m) =>
255
- m.id.toLowerCase().includes("embed") || m.name.toLowerCase().includes("embed"),
256
- );
257
- if (embedModel) {
258
- log.info(`Host embedding provider: ${name} → ${embedModel.id}`);
259
- return {
260
- name,
261
- baseUrl: provider.baseUrl,
262
- apiKey: resolveApiKey(provider.apiKey),
263
- api: provider.api,
264
- headers: provider.headers,
265
- model: embedModel.id,
266
- };
267
- }
268
- }
269
-
270
- // Fallback: use first provider with apiKey, pick first model
271
- const withKey = entries.find(([, p]) => !!resolveApiKey(p.apiKey));
272
- if (withKey) {
273
- const [name, provider] = withKey;
274
- const model = provider.models[0].id;
275
- log.info(`Host embedding provider (fallback): ${name} → ${model}`);
276
- return {
277
- name,
278
- baseUrl: provider.baseUrl,
279
- apiKey: resolveApiKey(provider.apiKey),
280
- api: provider.api,
281
- headers: provider.headers,
282
- model,
283
- };
284
- }
285
-
286
- return undefined;
287
- }
@@ -1,40 +0,0 @@
1
- import type {
2
- ClientModeConfig as RootClientModeConfig,
3
- HubModeConfig as RootHubModeConfig,
4
- SharingCapabilities as RootSharingCapabilities,
5
- SharingConfig as RootSharingConfig,
6
- SharingRole as RootSharingRole,
7
- } from "../types";
8
- import type {
9
- ClientModeConfig as SharingClientModeConfig,
10
- GroupInfo,
11
- HubModeConfig as SharingHubModeConfig,
12
- HubSearchHit,
13
- NetworkSearchResult,
14
- SharingCapabilities as SharingSharingCapabilities,
15
- SharingConfig as SharingSharingConfig,
16
- SharingRole as SharingSharingRole,
17
- SkillBundle,
18
- UserInfo,
19
- } from "./types";
20
-
21
- type Assert<T extends true> = T;
22
- type Equal<A, B> =
23
- (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2)
24
- ? ((<T>() => T extends B ? 1 : 2) extends (<T>() => T extends A ? 1 : 2) ? true : false)
25
- : false;
26
- type Extends<A, B> = A extends B ? true : false;
27
-
28
- type _SharingRoleMatchesRoot = Assert<Equal<SharingSharingRole, RootSharingRole>>;
29
- type _SharingCapabilitiesMatchRoot = Assert<Equal<SharingSharingCapabilities, RootSharingCapabilities>>;
30
- type _HubModeConfigMatchesRoot = Assert<Equal<SharingHubModeConfig, RootHubModeConfig>>;
31
- type _ClientModeConfigMatchesRoot = Assert<Equal<SharingClientModeConfig, RootClientModeConfig>>;
32
- type _SharingConfigMatchesRoot = Assert<Equal<SharingSharingConfig, RootSharingConfig>>;
33
-
34
- type _GroupInfoExists = Assert<Extends<GroupInfo, { id: string; name: string }>>;
35
- type _UserInfoExists = Assert<Extends<UserInfo, { id: string; username: string }>>;
36
- type _HubSearchHitExists = Assert<Extends<HubSearchHit, { remoteHitId: string; hubRank: number }>>;
37
- type _NetworkSearchResultExists = Assert<Extends<NetworkSearchResult, { local: unknown; hub: unknown }>>;
38
- type _SkillBundleExists = Assert<Extends<SkillBundle, { metadata: unknown; bundle: unknown }>>;
39
-
40
- export {};
@@ -1,102 +0,0 @@
1
- import type {
2
- ClientModeConfig,
3
- HubModeConfig,
4
- Role,
5
- SearchResult,
6
- SharingCapabilities,
7
- SharingConfig,
8
- SharingRole,
9
- SkillGenerateOutput,
10
- } from "../types";
11
-
12
- export type HubScope = "local" | "group" | "all";
13
- export type SharedVisibility = "group" | "public";
14
- export type UserRole = "admin" | "member";
15
- export type UserStatus = "pending" | "active" | "blocked" | "rejected";
16
-
17
- export type { ClientModeConfig, HubModeConfig, SharingCapabilities, SharingConfig, SharingRole };
18
-
19
- export interface GroupInfo {
20
- id: string;
21
- name: string;
22
- description?: string;
23
- }
24
-
25
- export interface UserInfo {
26
- id: string;
27
- username: string;
28
- deviceName?: string;
29
- role: UserRole;
30
- status: UserStatus;
31
- groups: GroupInfo[];
32
- }
33
-
34
- export interface HubSearchHit {
35
- remoteHitId: string;
36
- summary: string;
37
- excerpt: string;
38
- hubRank: number;
39
- taskTitle: string | null;
40
- ownerName: string;
41
- groupName: string | null;
42
- visibility: SharedVisibility;
43
- source: {
44
- ts: number;
45
- role: Role;
46
- };
47
- }
48
-
49
- export interface HubSearchMeta {
50
- totalCandidates: number;
51
- searchedGroups: string[];
52
- includedPublic: boolean;
53
- }
54
-
55
- export interface HubSearchResult {
56
- hits: HubSearchHit[];
57
- meta: HubSearchMeta;
58
- }
59
-
60
- export interface HubMemoryDetail {
61
- remoteHitId: string;
62
- content: string;
63
- summary: string;
64
- source: {
65
- ts: number;
66
- role: Role;
67
- };
68
- }
69
-
70
- export interface HubSkillHit {
71
- skillId: string;
72
- name: string;
73
- description: string;
74
- version: number;
75
- visibility: SharedVisibility;
76
- groupName: string | null;
77
- ownerName: string;
78
- qualityScore: number | null;
79
- }
80
-
81
- export interface HubSkillSearchResult {
82
- hits: HubSkillHit[];
83
- }
84
-
85
- export interface NetworkSearchResult {
86
- local: SearchResult;
87
- hub: HubSearchResult;
88
- }
89
-
90
- export interface SkillBundleMetadata {
91
- id: string;
92
- name: string;
93
- description: string;
94
- version: number;
95
- qualityScore: number | null;
96
- }
97
-
98
- export interface SkillBundle {
99
- metadata: SkillBundleMetadata;
100
- bundle: SkillGenerateOutput;
101
- }
102
-
@@ -1,34 +0,0 @@
1
- import { hubGetMemoryDetail } from "../client/hub";
2
- import type { PluginContext, ToolDefinition } from "../types";
3
- import type { SqliteStore } from "../storage/sqlite";
4
-
5
- export function createNetworkMemoryDetailTool(store: SqliteStore, ctx: PluginContext): ToolDefinition {
6
- return {
7
- name: "network_memory_detail",
8
- description:
9
- "Fetch the full detail for one Hub search hit using its remoteHitId. Use this after memory_search(scope=group|all) when you need the full shared content.",
10
- inputSchema: {
11
- type: "object",
12
- properties: {
13
- remoteHitId: {
14
- type: "string",
15
- description: "The remoteHitId returned by memory_search hub results.",
16
- },
17
- hubAddress: {
18
- type: "string",
19
- description: "Optional hub address override for integration tests or manual routing.",
20
- },
21
- userToken: {
22
- type: "string",
23
- description: "Optional hub bearer token override for integration tests.",
24
- },
25
- },
26
- required: ["remoteHitId"],
27
- },
28
- handler: async (input) => hubGetMemoryDetail(store, ctx, {
29
- remoteHitId: String(input.remoteHitId ?? ""),
30
- hubAddress: input.hubAddress as string | undefined,
31
- userToken: input.userToken as string | undefined,
32
- }),
33
- };
34
- }