Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/openclaw-plugin/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const MEMORY_URI_PATTERNS = [
const USER_STRUCTURE_DIRS = new Set(["memories"]);
const AGENT_STRUCTURE_DIRS = new Set(["memories", "skills", "instructions", "workspaces"]);

function md5Short(input: string): string {
export function md5Short(input: string): string {
return createHash("md5").update(input).digest("hex").slice(0, 12);
}

Expand Down
6 changes: 1 addition & 5 deletions examples/openclaw-plugin/context-engine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createHash } from "node:crypto";

import { md5Short } from "./client.js";
import type { OpenVikingClient } from "./client.js";
import type { MemoryOpenVikingConfig } from "./config.js";
import {
Expand Down Expand Up @@ -222,9 +221,6 @@ function warnOrInfo(logger: Logger, message: string): void {
logger.info(message);
}

function md5Short(input: string): string {
return createHash("md5").update(input).digest("hex").slice(0, 12);
}

const SAFE_SESSION_KEY_RE = /^[A-Za-z0-9_-]+$/;

Expand Down
8 changes: 4 additions & 4 deletions examples/openclaw-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const contextEnginePlugin = {

let sessionId = sessionIdIn;
let usedMappedSession = false;
const storeAgentId = sessionKeyIn ? resolveAgentId(sessionKeyIn) : undefined;
const storeAgentId = sessionKeyIn ? resolveSessionAgentId(sessionKeyIn) : undefined;
try {
const c = await getClient();
if (!sessionId && sessionKeyIn && contextEngineRef) {
Expand Down Expand Up @@ -418,7 +418,7 @@ const contextEnginePlugin = {
sessionAgentIds.set(ctx.sessionKey, ctx.agentId);
}
};
const resolveAgentId = (sessionId: string): string =>
const resolveSessionAgentId = (sessionId: string): string =>
sessionAgentIds.get(sessionId) ?? cfg.agentId;

api.on("session_start", async (_event: unknown, ctx?: HookAgentContext) => {
Expand All @@ -431,7 +431,7 @@ const contextEnginePlugin = {
rememberSessionAgentId(ctx ?? {});

const hookSessionId = ctx?.sessionId ?? ctx?.sessionKey ?? "";
const agentId = resolveAgentId(hookSessionId);
const agentId = resolveSessionAgentId(hookSessionId);
let client: OpenVikingClient;
try {
client = await withTimeout(
Expand Down Expand Up @@ -584,7 +584,7 @@ const contextEnginePlugin = {
cfg,
logger: api.logger,
getClient,
resolveAgentId,
resolveAgentId: resolveSessionAgentId,
});
return contextEngineRef;
});
Expand Down
4 changes: 1 addition & 3 deletions examples/openclaw-plugin/memory-ranking.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { FindResultItem } from "./client.js";
import { normalizeDedupeText } from "./text-utils.js";

export function clampScore(value: number | undefined): number {
if (typeof value !== "number" || Number.isNaN(value)) {
Expand All @@ -7,9 +8,6 @@ export function clampScore(value: number | undefined): number {
return Math.max(0, Math.min(1, value));
}

function normalizeDedupeText(text: string): string {
return text.toLowerCase().replace(/\s+/g, " ").trim();
}

function isEventOrCaseMemory(item: FindResultItem): boolean {
const category = (item.category ?? "").toLowerCase();
Expand Down
4 changes: 2 additions & 2 deletions examples/openclaw-plugin/openclaw.plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
},
"agentId": {
"label": "Agent ID",
"placeholder": "random unique ID",
"help": "Identifies this agent to OpenViking. A random unique ID is generated if not set."
"placeholder": "default",
"help": "Identifies this agent to OpenViking (sent as X-OpenViking-Agent header). Defaults to \"default\" if not set."
},
"apiKey": {
"label": "OpenViking API Key",
Expand Down
2 changes: 1 addition & 1 deletion examples/openclaw-plugin/text-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function isTranscriptLikeIngest(
};
}

function normalizeDedupeText(text: string): string {
export function normalizeDedupeText(text: string): string {
return text.toLowerCase().replace(/\s+/g, " ").trim();
}

Expand Down