@contextableai/openclaw-memory-graphiti 0.2.2 → 0.2.4
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.
- package/config.ts +3 -5
- package/docker/docker-compose.yml +1 -1
- package/index.ts +27 -0
- package/package.json +1 -1
package/config.ts
CHANGED
|
@@ -19,6 +19,7 @@ export type GraphitiMemoryConfig = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const DEFAULT_SPICEDB_ENDPOINT = "localhost:50051";
|
|
22
|
+
const DEFAULT_SPICEDB_TOKEN = "";
|
|
22
23
|
const DEFAULT_GRAPHITI_ENDPOINT = "http://localhost:8000";
|
|
23
24
|
const DEFAULT_GROUP_ID = "main";
|
|
24
25
|
const DEFAULT_UUID_POLL_INTERVAL_MS = 3000;
|
|
@@ -68,10 +69,7 @@ export const graphitiMemoryConfigSchema = {
|
|
|
68
69
|
);
|
|
69
70
|
|
|
70
71
|
// SpiceDB config
|
|
71
|
-
const spicedb = cfg.spicedb as Record<string, unknown>
|
|
72
|
-
if (!spicedb || typeof spicedb.token !== "string") {
|
|
73
|
-
throw new Error("spicedb.token is required");
|
|
74
|
-
}
|
|
72
|
+
const spicedb = (cfg.spicedb as Record<string, unknown>) ?? {};
|
|
75
73
|
assertAllowedKeys(spicedb, ["endpoint", "token", "insecure"], "spicedb config");
|
|
76
74
|
|
|
77
75
|
// Graphiti config
|
|
@@ -87,7 +85,7 @@ export const graphitiMemoryConfigSchema = {
|
|
|
87
85
|
spicedb: {
|
|
88
86
|
endpoint:
|
|
89
87
|
typeof spicedb.endpoint === "string" ? spicedb.endpoint : DEFAULT_SPICEDB_ENDPOINT,
|
|
90
|
-
token: resolveEnvVars(spicedb.token),
|
|
88
|
+
token: typeof spicedb.token === "string" ? resolveEnvVars(spicedb.token) : DEFAULT_SPICEDB_TOKEN,
|
|
91
89
|
insecure: spicedb.insecure !== false,
|
|
92
90
|
},
|
|
93
91
|
graphiti: {
|
|
@@ -81,7 +81,7 @@ services:
|
|
|
81
81
|
environment:
|
|
82
82
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
|
83
83
|
- EPISODE_ID_PREFIX=${EPISODE_ID_PREFIX:-epi-}
|
|
84
|
-
- FALKORDB_URI=redis://
|
|
84
|
+
- FALKORDB_URI=redis://falkordb:6379
|
|
85
85
|
depends_on:
|
|
86
86
|
falkordb:
|
|
87
87
|
condition: service_healthy
|
package/index.ts
CHANGED
|
@@ -65,8 +65,33 @@ const memoryGraphitiPlugin = {
|
|
|
65
65
|
const graphiti = new GraphitiClient(cfg.graphiti.endpoint);
|
|
66
66
|
graphiti.uuidPollIntervalMs = cfg.graphiti.uuidPollIntervalMs;
|
|
67
67
|
graphiti.uuidPollMaxAttempts = cfg.graphiti.uuidPollMaxAttempts;
|
|
68
|
+
if (!cfg.spicedb.token) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
"openclaw-memory-graphiti: spicedb.token is not configured. " +
|
|
71
|
+
"Set it in plugins.entries.openclaw-memory-graphiti.config.spicedb.token " +
|
|
72
|
+
"in ~/.openclaw/openclaw.json",
|
|
73
|
+
);
|
|
74
|
+
}
|
|
68
75
|
const spicedb = new SpiceDbClient(cfg.spicedb);
|
|
69
76
|
|
|
77
|
+
// Catch unhandled rejections from @grpc/grpc-js internals during initial
|
|
78
|
+
// connection setup. The gRPC load balancer state machine can emit promise
|
|
79
|
+
// rejections that bypass our try/catch blocks and crash the process.
|
|
80
|
+
const grpcRejectionHandler = (reason: unknown) => {
|
|
81
|
+
const msg = String(reason);
|
|
82
|
+
if (msg.includes("generateMetadata") || msg.includes("grpc")) {
|
|
83
|
+
api.logger.warn(`openclaw-memory-graphiti: suppressed grpc-js rejection: ${msg}`);
|
|
84
|
+
} else {
|
|
85
|
+
// Re-throw non-grpc rejections so they surface normally
|
|
86
|
+
throw reason;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
process.on("unhandledRejection", grpcRejectionHandler);
|
|
90
|
+
const grpcGuardTimer = setTimeout(() => {
|
|
91
|
+
process.removeListener("unhandledRejection", grpcRejectionHandler);
|
|
92
|
+
}, 10_000);
|
|
93
|
+
grpcGuardTimer.unref(); // Don't keep the process alive for this timer
|
|
94
|
+
|
|
70
95
|
const currentSubject: Subject = {
|
|
71
96
|
type: cfg.subjectType,
|
|
72
97
|
id: cfg.subjectId,
|
|
@@ -735,6 +760,8 @@ const memoryGraphitiPlugin = {
|
|
|
735
760
|
);
|
|
736
761
|
},
|
|
737
762
|
stop() {
|
|
763
|
+
clearTimeout(grpcGuardTimer);
|
|
764
|
+
process.removeListener("unhandledRejection", grpcRejectionHandler);
|
|
738
765
|
api.logger.info("openclaw-memory-graphiti: stopped");
|
|
739
766
|
},
|
|
740
767
|
});
|
package/package.json
CHANGED