mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:48:26 +00:00
feat (memory): Implement new (opt-in) QMD memory backend
This commit is contained in:
committed by
Vignesh
parent
e9f182def7
commit
5d3af3bc62
@@ -1,11 +1,16 @@
|
||||
import { z } from "zod";
|
||||
import { ToolsSchema } from "./zod-schema.agent-runtime.js";
|
||||
import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zod-schema.agents.js";
|
||||
import { ApprovalsSchema } from "./zod-schema.approvals.js";
|
||||
import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zod-schema.agents.js";
|
||||
import { HexColorSchema, ModelsConfigSchema } from "./zod-schema.core.js";
|
||||
import { HookMappingSchema, HooksGmailSchema, InternalHooksSchema } from "./zod-schema.hooks.js";
|
||||
import { ChannelsSchema } from "./zod-schema.providers.js";
|
||||
import { CommandsSchema, MessagesSchema, SessionSchema } from "./zod-schema.session.js";
|
||||
import {
|
||||
CommandsSchema,
|
||||
MessagesSchema,
|
||||
SessionSchema,
|
||||
SessionSendPolicySchema,
|
||||
} from "./zod-schema.session.js";
|
||||
|
||||
const BrowserSnapshotDefaultsSchema = z
|
||||
.object({
|
||||
@@ -27,7 +32,62 @@ const NodeHostSchema = z
|
||||
.strict()
|
||||
.optional();
|
||||
|
||||
export const OpenClawSchema = z
|
||||
const MemoryQmdPathSchema = z
|
||||
.object({
|
||||
path: z.string(),
|
||||
name: z.string().optional(),
|
||||
pattern: z.string().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const MemoryQmdSessionSchema = z
|
||||
.object({
|
||||
enabled: z.boolean().optional(),
|
||||
exportDir: z.string().optional(),
|
||||
retentionDays: z.number().int().nonnegative().optional(),
|
||||
redactToolOutputs: z.boolean().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const MemoryQmdUpdateSchema = z
|
||||
.object({
|
||||
interval: z.string().optional(),
|
||||
debounceMs: z.number().int().nonnegative().optional(),
|
||||
onBoot: z.boolean().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const MemoryQmdLimitsSchema = z
|
||||
.object({
|
||||
maxResults: z.number().int().positive().optional(),
|
||||
maxSnippetChars: z.number().int().positive().optional(),
|
||||
maxInjectedChars: z.number().int().positive().optional(),
|
||||
timeoutMs: z.number().int().nonnegative().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const MemoryQmdSchema = z
|
||||
.object({
|
||||
command: z.string().optional(),
|
||||
includeDefaultMemory: z.boolean().optional(),
|
||||
paths: z.array(MemoryQmdPathSchema).optional(),
|
||||
sessions: MemoryQmdSessionSchema.optional(),
|
||||
update: MemoryQmdUpdateSchema.optional(),
|
||||
limits: MemoryQmdLimitsSchema.optional(),
|
||||
scope: SessionSendPolicySchema.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const MemorySchema = z
|
||||
.object({
|
||||
backend: z.union([z.literal("builtin"), z.literal("qmd")]).optional(),
|
||||
citations: z.union([z.literal("auto"), z.literal("on"), z.literal("off")]).optional(),
|
||||
qmd: MemoryQmdSchema.optional(),
|
||||
})
|
||||
.strict()
|
||||
.optional();
|
||||
|
||||
export const MoltbotSchema = z
|
||||
.object({
|
||||
meta: z
|
||||
.object({
|
||||
@@ -154,7 +214,7 @@ export const OpenClawSchema = z
|
||||
.object({
|
||||
cdpPort: z.number().int().min(1).max(65535).optional(),
|
||||
cdpUrl: z.string().optional(),
|
||||
driver: z.union([z.literal("openclaw"), z.literal("extension")]).optional(),
|
||||
driver: z.union([z.literal("clawd"), z.literal("extension")]).optional(),
|
||||
color: HexColorSchema,
|
||||
})
|
||||
.strict()
|
||||
@@ -268,7 +328,6 @@ export const OpenClawSchema = z
|
||||
wideArea: z
|
||||
.object({
|
||||
enabled: z.boolean().optional(),
|
||||
domain: z.string().optional(),
|
||||
})
|
||||
.strict()
|
||||
.optional(),
|
||||
@@ -446,6 +505,7 @@ export const OpenClawSchema = z
|
||||
})
|
||||
.strict()
|
||||
.optional(),
|
||||
memory: MemorySchema,
|
||||
skills: z
|
||||
.object({
|
||||
allowBundled: z.array(z.string()).optional(),
|
||||
@@ -532,23 +592,15 @@ export const OpenClawSchema = z
|
||||
.strict()
|
||||
.superRefine((cfg, ctx) => {
|
||||
const agents = cfg.agents?.list ?? [];
|
||||
if (agents.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (agents.length === 0) return;
|
||||
const agentIds = new Set(agents.map((agent) => agent.id));
|
||||
|
||||
const broadcast = cfg.broadcast;
|
||||
if (!broadcast) {
|
||||
return;
|
||||
}
|
||||
if (!broadcast) return;
|
||||
|
||||
for (const [peerId, ids] of Object.entries(broadcast)) {
|
||||
if (peerId === "strategy") {
|
||||
continue;
|
||||
}
|
||||
if (!Array.isArray(ids)) {
|
||||
continue;
|
||||
}
|
||||
if (peerId === "strategy") continue;
|
||||
if (!Array.isArray(ids)) continue;
|
||||
for (let idx = 0; idx < ids.length; idx += 1) {
|
||||
const agentId = ids[idx];
|
||||
if (!agentIds.has(agentId)) {
|
||||
|
||||
Reference in New Issue
Block a user