@alfe.ai/openclaw-memory-cloud 0.0.4 → 0.0.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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +22 -0
- package/dist/auto-capture.d.ts +2 -3
- package/dist/auto-capture.d.ts.map +1 -1
- package/dist/auto-capture.js +1 -1
- package/dist/auto-capture.js.map +1 -1
- package/dist/auto-recall.d.ts +2 -3
- package/dist/auto-recall.d.ts.map +1 -1
- package/dist/auto-recall.js +4 -4
- package/dist/auto-recall.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -22
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/auto-capture.ts +3 -4
- package/src/auto-recall.ts +6 -7
- package/src/index.ts +17 -23
- package/src/types.ts +44 -0
- package/dist/memory-client.d.ts +0 -50
- package/dist/memory-client.d.ts.map +0 -1
- package/dist/memory-client.js +0 -108
- package/dist/memory-client.js.map +0 -1
- package/src/memory-client.ts +0 -132
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @alfe.ai/openclaw-memory-cloud
|
|
2
2
|
|
|
3
|
+
## 0.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [4f3b54a]
|
|
8
|
+
- @alfe.ai/agent-api-client@0.0.12
|
|
9
|
+
|
|
10
|
+
## 0.0.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 6921672: Fix plugin install and activation issues
|
|
15
|
+
|
|
16
|
+
- openclaw-memory-cloud: Add `openclaw.extensions`, refactor to use AgentApiClient instead of raw MemoryClient
|
|
17
|
+
- openclaw-secrets: Add missing `openclaw.extensions` field
|
|
18
|
+
- openclaw-google-chat: Fix poller not starting — registrationMode guard was blocking registerService
|
|
19
|
+
- agent-api-client: Add memory API methods, include Atlassian OAuth clientId/clientSecret in credentials
|
|
20
|
+
- All plugins: Remove registrationMode guard from activate() — OpenClaw handles mode filtering via registerService lifecycle
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [6921672]
|
|
23
|
+
- @alfe.ai/agent-api-client@0.0.11
|
|
24
|
+
|
|
3
25
|
## 0.0.4
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/auto-capture.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MemoryCloudConfig, SessionMetadata } from "./types.js";
|
|
1
|
+
import type { MemoryApi, MemoryCloudConfig, SessionMetadata } from "./types.js";
|
|
3
2
|
/**
|
|
4
3
|
* Auto-capture manages the idle debounce timer and flushes
|
|
5
4
|
* accumulated messages to the memory service.
|
|
@@ -19,7 +18,7 @@ export declare class AutoCapture {
|
|
|
19
18
|
private idleTimer;
|
|
20
19
|
private sessionKey;
|
|
21
20
|
private metadata;
|
|
22
|
-
constructor(client:
|
|
21
|
+
constructor(client: MemoryApi, config: MemoryCloudConfig, logger: {
|
|
23
22
|
debug: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
24
23
|
warn: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
25
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-capture.d.ts","sourceRoot":"","sources":["../src/auto-capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"auto-capture.d.ts","sourceRoot":"","sources":["../src/auto-capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAiB,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/F;;;;;;;;GAQG;AACH,qBAAa,WAAW;IASpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAVzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAO;IAC7C,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAuB;gBAGpB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;KAAE;IAGtJ,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI;IAKhE,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAsB3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBtB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;CAMvB"}
|
package/dist/auto-capture.js
CHANGED
|
@@ -56,7 +56,7 @@ export class AutoCapture {
|
|
|
56
56
|
messageCount: batch.length,
|
|
57
57
|
});
|
|
58
58
|
try {
|
|
59
|
-
await this.client.
|
|
59
|
+
await this.client.memoryIngest(this.sessionKey, batch, this.metadata);
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
62
|
this.logger.warn("Failed to flush memories", { error: String(err) });
|
package/dist/auto-capture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-capture.js","sourceRoot":"","sources":["../src/auto-capture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-capture.js","sourceRoot":"","sources":["../src/auto-capture.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,OAAO,WAAW;IASH;IACA;IACA;IAVX,MAAM,CAAU,cAAc,GAAG,GAAG,CAAC;IACrC,eAAe,GAAoB,EAAE,CAAC;IACtC,YAAY,GAAG,CAAC,CAAC;IACjB,SAAS,GAAyC,IAAI,CAAC;IACvD,UAAU,GAAkB,IAAI,CAAC;IACjC,QAAQ,GAAoB,EAAE,CAAC;IAEvC,YACmB,MAAiB,EACjB,MAAyB,EACzB,MAAmI;QAFnI,WAAM,GAAN,MAAM,CAAW;QACjB,WAAM,GAAN,MAAM,CAAmB;QACzB,WAAM,GAAN,MAAM,CAA6H;IACnJ,CAAC;IAEJ,UAAU,CAAC,UAAkB,EAAE,QAA0B;QACvD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACzC,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,OAAe;QACxC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW;YAAE,OAAO;QACrC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;YACjD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAC1D,CAAC;QAED,mDAAmD;QACnD,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;YAC9D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6CAA6C,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;YAC5G,IAAI,CAAC,eA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CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAC/B,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;IAEO,cAAc;QACpB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC"}
|
package/dist/auto-recall.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MemoryCloudConfig } from "./types.js";
|
|
1
|
+
import type { MemoryApi, MemoryCloudConfig } from "./types.js";
|
|
3
2
|
/**
|
|
4
3
|
* Auto-recall loads tiered memory context at session start
|
|
5
4
|
* and formats it for injection into the agent's prompt.
|
|
@@ -10,7 +9,7 @@ export declare class AutoRecall {
|
|
|
10
9
|
private readonly client;
|
|
11
10
|
private readonly config;
|
|
12
11
|
private readonly logger;
|
|
13
|
-
constructor(client:
|
|
12
|
+
constructor(client: MemoryApi, config: MemoryCloudConfig, logger: {
|
|
14
13
|
debug: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
15
14
|
warn: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
16
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-recall.d.ts","sourceRoot":"","sources":["../src/auto-recall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"auto-recall.d.ts","sourceRoot":"","sources":["../src/auto-recall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;GAKG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;KAAE;IAGtJ;;;OAGG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CA8BtE"}
|
package/dist/auto-recall.js
CHANGED
|
@@ -25,7 +25,7 @@ export class AutoRecall {
|
|
|
25
25
|
const topicHint = extractTopicHint(userMessage);
|
|
26
26
|
// Load L1 (facts) + L2 (topic context) in one call
|
|
27
27
|
const tier = topicHint ? 2 : 1;
|
|
28
|
-
const context = await this.client.
|
|
28
|
+
const context = await this.client.memoryLoadContext(tier, topicHint);
|
|
29
29
|
if (!context.formatted || context.formatted.length === 0) {
|
|
30
30
|
this.logger.debug("No relevant memories found for prompt");
|
|
31
31
|
return undefined;
|
|
@@ -33,9 +33,9 @@ export class AutoRecall {
|
|
|
33
33
|
this.logger.debug("Loaded memory context for prompt", {
|
|
34
34
|
tier,
|
|
35
35
|
topicHint,
|
|
36
|
-
factCount: context.facts.length,
|
|
37
|
-
memoryCount: context.memories.length,
|
|
38
|
-
tokenEstimate: context.tokenEstimate,
|
|
36
|
+
factCount: Array.isArray(context.facts) ? context.facts.length : 0,
|
|
37
|
+
memoryCount: Array.isArray(context.memories) ? context.memories.length : 0,
|
|
38
|
+
tokenEstimate: typeof context.tokenEstimate === "number" ? context.tokenEstimate : 0,
|
|
39
39
|
});
|
|
40
40
|
return context.formatted;
|
|
41
41
|
}
|
package/dist/auto-recall.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-recall.js","sourceRoot":"","sources":["../src/auto-recall.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-recall.js","sourceRoot":"","sources":["../src/auto-recall.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAEF;IACA;IACA;IAHnB,YACmB,MAAiB,EACjB,MAAyB,EACzB,MAAmI;QAFnI,WAAM,GAAN,MAAM,CAAW;QACjB,WAAM,GAAN,MAAM,CAAmB;QACzB,WAAM,GAAN,MAAM,CAA6H;IACnJ,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QAE9C,IAAI,CAAC;YACH,0DAA0D;YAC1D,MAAM,SAAS,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;YAEhD,mDAAmD;YACnD,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAErE,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;gBAC3D,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE;gBACpD,IAAI;gBACJ,SAAS;gBACT,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,K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M,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACvG,2BAA2B,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,KAAK,MAAM,EAAE,KAAK,IAAI,CAAC;IACtG,qBAAqB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;AAED,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACpF;;;;;;;kBA2Be,SAAS,GAAG,IAAI;;AAPhC,wBAgNE"}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* - Lifecycle hooks: before_agent_start (auto-recall), agent_end (auto-capture), message_received (idle debounce)
|
|
12
12
|
* - Memory runtime: replaces builtin SQLite backend with cloud backend
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { resolveConfig } from "@alfe.ai/config";
|
|
15
|
+
import { AgentApiClient } from "@alfe.ai/agent-api-client";
|
|
15
16
|
import { AutoCapture } from "./auto-capture.js";
|
|
16
17
|
import { AutoRecall } from "./auto-recall.js";
|
|
17
18
|
import { formatSearchResults } from "./formatter.js";
|
|
@@ -24,7 +25,7 @@ const DEFAULT_CONFIG = {
|
|
|
24
25
|
captureMaxChars: 500,
|
|
25
26
|
idleFlushSeconds: 60,
|
|
26
27
|
};
|
|
27
|
-
function
|
|
28
|
+
function resolvePluginConfig(pluginConfig) {
|
|
28
29
|
return {
|
|
29
30
|
autoCapture: typeof pluginConfig?.autoCapture === "boolean" ? pluginConfig.autoCapture : DEFAULT_CONFIG.autoCapture,
|
|
30
31
|
autoRecall: typeof pluginConfig?.autoRecall === "boolean" ? pluginConfig.autoRecall : DEFAULT_CONFIG.autoRecall,
|
|
@@ -39,19 +40,13 @@ export default {
|
|
|
39
40
|
version: pkg.version,
|
|
40
41
|
kind: "memory",
|
|
41
42
|
register(api) {
|
|
42
|
-
const config =
|
|
43
|
+
const config = resolvePluginConfig(api.pluginConfig);
|
|
43
44
|
const logger = api.logger;
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const agentApiKey = typeof cfgKey === "string" ? cfgKey : "";
|
|
50
|
-
const agentId = typeof cfgAgent === "string" ? cfgAgent : "";
|
|
51
|
-
if (!memoryServiceUrl) {
|
|
52
|
-
throw new Error("memory-cloud: memoryServiceUrl not configured — cannot register memory extension");
|
|
53
|
-
}
|
|
54
|
-
const client = new MemoryClient(memoryServiceUrl, agentApiKey, agentId);
|
|
45
|
+
const alfeConfig = resolveConfig();
|
|
46
|
+
const client = new AgentApiClient({
|
|
47
|
+
apiKey: alfeConfig.apiKey,
|
|
48
|
+
apiUrl: alfeConfig.apiUrl,
|
|
49
|
+
});
|
|
55
50
|
const autoCapture = new AutoCapture(client, config, logger);
|
|
56
51
|
const autoRecall = new AutoRecall(client, config, logger);
|
|
57
52
|
// ─── Memory prompt section ──────────────────────────────────
|
|
@@ -85,7 +80,7 @@ export default {
|
|
|
85
80
|
required: ["query"],
|
|
86
81
|
},
|
|
87
82
|
execute: async (_toolCallId, params) => {
|
|
88
|
-
const results = await client.
|
|
83
|
+
const results = await client.memorySearch(params.query, {
|
|
89
84
|
limit: params.limit,
|
|
90
85
|
topic: params.topic,
|
|
91
86
|
tag: params.tag,
|
|
@@ -108,7 +103,7 @@ export default {
|
|
|
108
103
|
required: ["text"],
|
|
109
104
|
},
|
|
110
105
|
execute: async (_toolCallId, params) => {
|
|
111
|
-
const result = await client.
|
|
106
|
+
const result = await client.memoryStore(params.text, {
|
|
112
107
|
topic: params.topic,
|
|
113
108
|
tag: params.tag,
|
|
114
109
|
importance: params.importance,
|
|
@@ -128,13 +123,13 @@ export default {
|
|
|
128
123
|
required: ["query"],
|
|
129
124
|
},
|
|
130
125
|
execute: async (_toolCallId, params) => {
|
|
131
|
-
const results = await client.
|
|
126
|
+
const results = await client.memorySearch(params.query, { limit: 5 });
|
|
132
127
|
if (results.memories.length === 0)
|
|
133
128
|
return "No matching memories found.";
|
|
134
129
|
const deleted = [];
|
|
135
130
|
for (const mem of results.memories) {
|
|
136
131
|
try {
|
|
137
|
-
await client.
|
|
132
|
+
await client.memoryDelete(mem.id);
|
|
138
133
|
deleted.push(mem.id);
|
|
139
134
|
}
|
|
140
135
|
catch {
|
|
@@ -156,7 +151,7 @@ export default {
|
|
|
156
151
|
required: ["entity"],
|
|
157
152
|
},
|
|
158
153
|
execute: async (_toolCallId, params) => {
|
|
159
|
-
const result = await client.
|
|
154
|
+
const result = await client.memoryLookupEntity(params.entity);
|
|
160
155
|
if (result.triples.length === 0)
|
|
161
156
|
return `No knowledge found about "${params.entity}".`;
|
|
162
157
|
const facts = result.triples.map((t) => `- ${result.subject} ${t.predicate} ${t.object} (since ${t.validFrom.slice(0, 10)})`);
|
|
@@ -169,7 +164,7 @@ export default {
|
|
|
169
164
|
description: "Get memory storage statistics.",
|
|
170
165
|
parameters: { type: "object", properties: {} },
|
|
171
166
|
execute: async () => {
|
|
172
|
-
const s = await client.
|
|
167
|
+
const s = await client.memoryStats();
|
|
173
168
|
return `Memories: ${String(s.vectorCount)}, Knowledge facts: ${String(s.tripleCount)}, Storage: ${String(Math.round(s.storageEstimateBytes / 1024))} KB`;
|
|
174
169
|
},
|
|
175
170
|
}), { names: ["memory_stats"] });
|
|
@@ -179,8 +174,8 @@ export default {
|
|
|
179
174
|
description: "Browse your memory palace structure — list topics, subtopics, and memory counts.",
|
|
180
175
|
parameters: { type: "object", properties: {} },
|
|
181
176
|
execute: async () => {
|
|
182
|
-
const nav = await client.
|
|
183
|
-
const topics = nav
|
|
177
|
+
const nav = await client.memoryNavigate();
|
|
178
|
+
const topics = nav.topics;
|
|
184
179
|
if (topics.length === 0)
|
|
185
180
|
return "No memories stored yet.";
|
|
186
181
|
const lines = topics.map((t) => `- ${t.name} (${String(t.tripleCount)} facts, subtopics: ${t.subtopics.join(", ") || "none"})`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAoC9D,MAAM,cAAc,GAAs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,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,0BAA0B;QAC1B,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,KAAc,EAAE,EAAE;YAC3C,MAAM,QAAQ,GAAG,KAAgC,CAAC;YAClD,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,WAAW,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,GAAG,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,KAAc,EAAE,EAAE;YAC3C,MAAM,QAAQ,GAAG,KAAgC,CAAC;YAClD,IAAI,QAAQ,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;gBAC/B,MAAM,WAAW,CAAC,UAAU,EAAE,CAAC;YACjC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACvH,CAAC;CACF,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -51,4 +51,61 @@ export interface MemoryContext {
|
|
|
51
51
|
tokenEstimate: number;
|
|
52
52
|
formatted: string;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Interface for memory API calls. Satisfied by AgentApiClient so the plugin
|
|
56
|
+
* doesn't need a hard dependency on the agent-api-client package.
|
|
57
|
+
*/
|
|
58
|
+
export interface MemoryApi {
|
|
59
|
+
memorySearch(query: string, opts?: {
|
|
60
|
+
limit?: number;
|
|
61
|
+
topic?: string;
|
|
62
|
+
subtopic?: string;
|
|
63
|
+
tag?: string;
|
|
64
|
+
includeKnowledge?: boolean;
|
|
65
|
+
}): Promise<MemorySearchResult>;
|
|
66
|
+
memoryStore(text: string, opts?: {
|
|
67
|
+
topic?: string;
|
|
68
|
+
subtopic?: string;
|
|
69
|
+
tag?: string;
|
|
70
|
+
importance?: number;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
memoryId: string;
|
|
73
|
+
}>;
|
|
74
|
+
memoryIngest(sessionKey: string, messages: MemoryMessage[], metadata?: SessionMetadata): Promise<{
|
|
75
|
+
queued: boolean;
|
|
76
|
+
messageCount: number;
|
|
77
|
+
}>;
|
|
78
|
+
memoryLoadContext(tier?: number, topicHint?: string): Promise<{
|
|
79
|
+
formatted: string;
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
}>;
|
|
82
|
+
memoryLookupEntity(subject: string): Promise<{
|
|
83
|
+
subject: string;
|
|
84
|
+
triples: {
|
|
85
|
+
tripleId: string;
|
|
86
|
+
predicate: string;
|
|
87
|
+
object: string;
|
|
88
|
+
validFrom: string;
|
|
89
|
+
validTo?: string;
|
|
90
|
+
confidence: number;
|
|
91
|
+
}[];
|
|
92
|
+
}>;
|
|
93
|
+
memoryNavigate(): Promise<{
|
|
94
|
+
topics: {
|
|
95
|
+
name: string;
|
|
96
|
+
tripleCount: number;
|
|
97
|
+
subtopics: string[];
|
|
98
|
+
}[];
|
|
99
|
+
cursor: string | null;
|
|
100
|
+
}>;
|
|
101
|
+
memoryDelete(memoryId: string): Promise<{
|
|
102
|
+
deleted: boolean;
|
|
103
|
+
}>;
|
|
104
|
+
memoryStats(): Promise<{
|
|
105
|
+
vectorCount: number;
|
|
106
|
+
tripleCount: number;
|
|
107
|
+
storageEstimateBytes: number;
|
|
108
|
+
lastIngestionAt?: string;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
54
111
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED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Turbopuffer vectors + DynamoDB knowledge graph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"./dist/index.js"
|
|
11
11
|
]
|
|
12
12
|
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@alfe.ai/agent-api-client": "0.0.12",
|
|
15
|
+
"@alfe.ai/config": "0.0.8"
|
|
16
|
+
},
|
|
13
17
|
"license": "UNLICENSED",
|
|
14
18
|
"scripts": {
|
|
15
19
|
"build": "tsc",
|
package/src/auto-capture.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MemoryCloudConfig, MemoryMessage, SessionMetadata } from "./types.js";
|
|
1
|
+
import type { MemoryApi, MemoryCloudConfig, MemoryMessage, SessionMetadata } from "./types.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Auto-capture manages the idle debounce timer and flushes
|
|
@@ -19,7 +18,7 @@ export class AutoCapture {
|
|
|
19
18
|
private metadata: SessionMetadata = {};
|
|
20
19
|
|
|
21
20
|
constructor(
|
|
22
|
-
private readonly client:
|
|
21
|
+
private readonly client: MemoryApi,
|
|
23
22
|
private readonly config: MemoryCloudConfig,
|
|
24
23
|
private readonly logger: { debug: (msg: string, ctx?: Record<string, unknown>) => void; warn: (msg: string, ctx?: Record<string, unknown>) => void },
|
|
25
24
|
) {}
|
|
@@ -63,7 +62,7 @@ export class AutoCapture {
|
|
|
63
62
|
});
|
|
64
63
|
|
|
65
64
|
try {
|
|
66
|
-
await this.client.
|
|
65
|
+
await this.client.memoryIngest(this.sessionKey, batch, this.metadata);
|
|
67
66
|
} catch (err) {
|
|
68
67
|
this.logger.warn("Failed to flush memories", { error: String(err) });
|
|
69
68
|
// Re-add failed messages for next flush attempt
|
package/src/auto-recall.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MemoryCloudConfig } from "./types.js";
|
|
1
|
+
import type { MemoryApi, MemoryCloudConfig } from "./types.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Auto-recall loads tiered memory context at session start
|
|
@@ -9,7 +8,7 @@ import type { MemoryCloudConfig } from "./types.js";
|
|
|
9
8
|
*/
|
|
10
9
|
export class AutoRecall {
|
|
11
10
|
constructor(
|
|
12
|
-
private readonly client:
|
|
11
|
+
private readonly client: MemoryApi,
|
|
13
12
|
private readonly config: MemoryCloudConfig,
|
|
14
13
|
private readonly logger: { debug: (msg: string, ctx?: Record<string, unknown>) => void; warn: (msg: string, ctx?: Record<string, unknown>) => void },
|
|
15
14
|
) {}
|
|
@@ -27,7 +26,7 @@ export class AutoRecall {
|
|
|
27
26
|
|
|
28
27
|
// Load L1 (facts) + L2 (topic context) in one call
|
|
29
28
|
const tier = topicHint ? 2 : 1;
|
|
30
|
-
const context = await this.client.
|
|
29
|
+
const context = await this.client.memoryLoadContext(tier, topicHint);
|
|
31
30
|
|
|
32
31
|
if (!context.formatted || context.formatted.length === 0) {
|
|
33
32
|
this.logger.debug("No relevant memories found for prompt");
|
|
@@ -37,9 +36,9 @@ export class AutoRecall {
|
|
|
37
36
|
this.logger.debug("Loaded memory context for prompt", {
|
|
38
37
|
tier,
|
|
39
38
|
topicHint,
|
|
40
|
-
factCount: context.facts.length,
|
|
41
|
-
memoryCount: context.memories.length,
|
|
42
|
-
tokenEstimate: context.tokenEstimate,
|
|
39
|
+
factCount: Array.isArray(context.facts) ? context.facts.length : 0,
|
|
40
|
+
memoryCount: Array.isArray(context.memories) ? context.memories.length : 0,
|
|
41
|
+
tokenEstimate: typeof context.tokenEstimate === "number" ? context.tokenEstimate : 0,
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
return context.formatted;
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* - Memory runtime: replaces builtin SQLite backend with cloud backend
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { resolveConfig } from "@alfe.ai/config";
|
|
16
|
+
import { AgentApiClient } from "@alfe.ai/agent-api-client";
|
|
16
17
|
import { AutoCapture } from "./auto-capture.js";
|
|
17
18
|
import { AutoRecall } from "./auto-recall.js";
|
|
18
19
|
import { formatSearchResults } from "./formatter.js";
|
|
@@ -62,7 +63,7 @@ const DEFAULT_CONFIG: MemoryCloudConfig = {
|
|
|
62
63
|
idleFlushSeconds: 60,
|
|
63
64
|
};
|
|
64
65
|
|
|
65
|
-
function
|
|
66
|
+
function resolvePluginConfig(pluginConfig?: Record<string, unknown>): MemoryCloudConfig {
|
|
66
67
|
return {
|
|
67
68
|
autoCapture: typeof pluginConfig?.autoCapture === "boolean" ? pluginConfig.autoCapture : DEFAULT_CONFIG.autoCapture,
|
|
68
69
|
autoRecall: typeof pluginConfig?.autoRecall === "boolean" ? pluginConfig.autoRecall : DEFAULT_CONFIG.autoRecall,
|
|
@@ -79,22 +80,15 @@ export default {
|
|
|
79
80
|
kind: "memory" as const,
|
|
80
81
|
|
|
81
82
|
register(api: PluginApi): void {
|
|
82
|
-
const config =
|
|
83
|
+
const config = resolvePluginConfig(api.pluginConfig);
|
|
83
84
|
const logger = api.logger;
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const agentApiKey = typeof cfgKey === "string" ? cfgKey : "";
|
|
91
|
-
const agentId = typeof cfgAgent === "string" ? cfgAgent : "";
|
|
92
|
-
|
|
93
|
-
if (!memoryServiceUrl) {
|
|
94
|
-
throw new Error("memory-cloud: memoryServiceUrl not configured — cannot register memory extension");
|
|
95
|
-
}
|
|
86
|
+
const alfeConfig = resolveConfig();
|
|
87
|
+
const client = new AgentApiClient({
|
|
88
|
+
apiKey: alfeConfig.apiKey,
|
|
89
|
+
apiUrl: alfeConfig.apiUrl,
|
|
90
|
+
});
|
|
96
91
|
|
|
97
|
-
const client = new MemoryClient(memoryServiceUrl, agentApiKey, agentId);
|
|
98
92
|
const autoCapture = new AutoCapture(client, config, logger);
|
|
99
93
|
const autoRecall = new AutoRecall(client, config, logger);
|
|
100
94
|
|
|
@@ -130,7 +124,7 @@ export default {
|
|
|
130
124
|
required: ["query"],
|
|
131
125
|
},
|
|
132
126
|
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
133
|
-
const results = await client.
|
|
127
|
+
const results = await client.memorySearch(
|
|
134
128
|
params.query as string,
|
|
135
129
|
{
|
|
136
130
|
limit: params.limit as number | undefined,
|
|
@@ -157,7 +151,7 @@ export default {
|
|
|
157
151
|
required: ["text"],
|
|
158
152
|
},
|
|
159
153
|
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
160
|
-
const result = await client.
|
|
154
|
+
const result = await client.memoryStore(
|
|
161
155
|
params.text as string,
|
|
162
156
|
{
|
|
163
157
|
topic: params.topic as string | undefined,
|
|
@@ -181,13 +175,13 @@ export default {
|
|
|
181
175
|
required: ["query"],
|
|
182
176
|
},
|
|
183
177
|
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
184
|
-
const results = await client.
|
|
178
|
+
const results = await client.memorySearch(params.query as string, { limit: 5 });
|
|
185
179
|
if (results.memories.length === 0) return "No matching memories found.";
|
|
186
180
|
|
|
187
181
|
const deleted: string[] = [];
|
|
188
182
|
for (const mem of results.memories) {
|
|
189
183
|
try {
|
|
190
|
-
await client.
|
|
184
|
+
await client.memoryDelete(mem.id);
|
|
191
185
|
deleted.push(mem.id);
|
|
192
186
|
} catch {
|
|
193
187
|
logger.warn("Failed to delete memory", { memoryId: mem.id });
|
|
@@ -209,7 +203,7 @@ export default {
|
|
|
209
203
|
required: ["entity"],
|
|
210
204
|
},
|
|
211
205
|
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
212
|
-
const result = await client.
|
|
206
|
+
const result = await client.memoryLookupEntity(params.entity as string);
|
|
213
207
|
if (result.triples.length === 0) return `No knowledge found about "${params.entity as string}".`;
|
|
214
208
|
const facts = result.triples.map((t) => `- ${result.subject} ${t.predicate} ${t.object} (since ${t.validFrom.slice(0, 10)})`);
|
|
215
209
|
return `Known facts about ${result.subject}:\n${facts.join("\n")}`;
|
|
@@ -222,7 +216,7 @@ export default {
|
|
|
222
216
|
description: "Get memory storage statistics.",
|
|
223
217
|
parameters: { type: "object", properties: {} },
|
|
224
218
|
execute: async () => {
|
|
225
|
-
const s = await client.
|
|
219
|
+
const s = await client.memoryStats();
|
|
226
220
|
return `Memories: ${String(s.vectorCount)}, Knowledge facts: ${String(s.tripleCount)}, Storage: ${String(Math.round(s.storageEstimateBytes / 1024))} KB`;
|
|
227
221
|
},
|
|
228
222
|
}), { names: ["memory_stats"] });
|
|
@@ -233,8 +227,8 @@ export default {
|
|
|
233
227
|
description: "Browse your memory palace structure — list topics, subtopics, and memory counts.",
|
|
234
228
|
parameters: { type: "object", properties: {} },
|
|
235
229
|
execute: async () => {
|
|
236
|
-
const nav = await client.
|
|
237
|
-
const topics = nav
|
|
230
|
+
const nav = await client.memoryNavigate();
|
|
231
|
+
const topics = nav.topics;
|
|
238
232
|
if (topics.length === 0) return "No memories stored yet.";
|
|
239
233
|
const lines = topics.map((t) => `- ${t.name} (${String(t.tripleCount)} facts, subtopics: ${t.subtopics.join(", ") || "none"})`);
|
|
240
234
|
return `Memory topics:\n${lines.join("\n")}`;
|
package/src/types.ts
CHANGED
|
@@ -45,3 +45,47 @@ export interface MemoryContext {
|
|
|
45
45
|
tokenEstimate: number;
|
|
46
46
|
formatted: string;
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Interface for memory API calls. Satisfied by AgentApiClient so the plugin
|
|
51
|
+
* doesn't need a hard dependency on the agent-api-client package.
|
|
52
|
+
*/
|
|
53
|
+
export interface MemoryApi {
|
|
54
|
+
memorySearch(query: string, opts?: {
|
|
55
|
+
limit?: number;
|
|
56
|
+
topic?: string;
|
|
57
|
+
subtopic?: string;
|
|
58
|
+
tag?: string;
|
|
59
|
+
includeKnowledge?: boolean;
|
|
60
|
+
}): Promise<MemorySearchResult>;
|
|
61
|
+
|
|
62
|
+
memoryStore(text: string, opts?: {
|
|
63
|
+
topic?: string;
|
|
64
|
+
subtopic?: string;
|
|
65
|
+
tag?: string;
|
|
66
|
+
importance?: number;
|
|
67
|
+
}): Promise<{ memoryId: string }>;
|
|
68
|
+
|
|
69
|
+
memoryIngest(sessionKey: string, messages: MemoryMessage[], metadata?: SessionMetadata): Promise<{ queued: boolean; messageCount: number }>;
|
|
70
|
+
|
|
71
|
+
memoryLoadContext(tier?: number, topicHint?: string): Promise<{ formatted: string; [key: string]: unknown }>;
|
|
72
|
+
|
|
73
|
+
memoryLookupEntity(subject: string): Promise<{
|
|
74
|
+
subject: string;
|
|
75
|
+
triples: { tripleId: string; predicate: string; object: string; validFrom: string; validTo?: string; confidence: number }[];
|
|
76
|
+
}>;
|
|
77
|
+
|
|
78
|
+
memoryNavigate(): Promise<{
|
|
79
|
+
topics: { name: string; tripleCount: number; subtopics: string[] }[];
|
|
80
|
+
cursor: string | null;
|
|
81
|
+
}>;
|
|
82
|
+
|
|
83
|
+
memoryDelete(memoryId: string): Promise<{ deleted: boolean }>;
|
|
84
|
+
|
|
85
|
+
memoryStats(): Promise<{
|
|
86
|
+
vectorCount: number;
|
|
87
|
+
tripleCount: number;
|
|
88
|
+
storageEstimateBytes: number;
|
|
89
|
+
lastIngestionAt?: string;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
package/dist/memory-client.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { MemorySearchResult, MemoryContext, MemoryMessage, SessionMetadata } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* HTTP client for services/memory.
|
|
4
|
-
* All memory operations go through the Lambda service — no direct Turbopuffer/DynamoDB access.
|
|
5
|
-
*/
|
|
6
|
-
export declare class MemoryClient {
|
|
7
|
-
private readonly baseUrl;
|
|
8
|
-
private readonly agentApiKey;
|
|
9
|
-
private readonly agentId;
|
|
10
|
-
constructor(baseUrl: string, agentApiKey: string, agentId: string);
|
|
11
|
-
search(query: string, opts?: {
|
|
12
|
-
limit?: number;
|
|
13
|
-
topic?: string;
|
|
14
|
-
subtopic?: string;
|
|
15
|
-
tag?: string;
|
|
16
|
-
includeKnowledge?: boolean;
|
|
17
|
-
}): Promise<MemorySearchResult>;
|
|
18
|
-
store(text: string, opts?: {
|
|
19
|
-
topic?: string;
|
|
20
|
-
subtopic?: string;
|
|
21
|
-
tag?: string;
|
|
22
|
-
importance?: number;
|
|
23
|
-
}): Promise<{
|
|
24
|
-
memoryId: string;
|
|
25
|
-
}>;
|
|
26
|
-
ingest(sessionKey: string, messages: MemoryMessage[], metadata?: SessionMetadata): Promise<void>;
|
|
27
|
-
loadContext(tier: number, topicHint?: string): Promise<MemoryContext>;
|
|
28
|
-
lookupEntity(subject: string): Promise<{
|
|
29
|
-
subject: string;
|
|
30
|
-
triples: {
|
|
31
|
-
tripleId: string;
|
|
32
|
-
predicate: string;
|
|
33
|
-
object: string;
|
|
34
|
-
validFrom: string;
|
|
35
|
-
validTo?: string;
|
|
36
|
-
confidence: number;
|
|
37
|
-
}[];
|
|
38
|
-
}>;
|
|
39
|
-
navigate(): Promise<unknown>;
|
|
40
|
-
deleteMemory(memoryId: string): Promise<void>;
|
|
41
|
-
stats(): Promise<{
|
|
42
|
-
vectorCount: number;
|
|
43
|
-
tripleCount: number;
|
|
44
|
-
storageEstimateBytes: number;
|
|
45
|
-
}>;
|
|
46
|
-
private post;
|
|
47
|
-
private get;
|
|
48
|
-
private del;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=memory-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-client.d.ts","sourceRoot":"","sources":["../src/memory-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpG;;;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AC,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC7H,CAAC;IAOI,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAK5B,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,KAAK,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,CAAC;YAKpF,IAAI;YAgBJ,GAAG;YAaH,GAAG;CAYlB"}
|
package/dist/memory-client.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP client for services/memory.
|
|
3
|
-
* All memory operations go through the Lambda service — no direct Turbopuffer/DynamoDB access.
|
|
4
|
-
*/
|
|
5
|
-
export class MemoryClient {
|
|
6
|
-
baseUrl;
|
|
7
|
-
agentApiKey;
|
|
8
|
-
agentId;
|
|
9
|
-
constructor(baseUrl, agentApiKey, agentId) {
|
|
10
|
-
this.baseUrl = baseUrl;
|
|
11
|
-
this.agentApiKey = agentApiKey;
|
|
12
|
-
this.agentId = agentId;
|
|
13
|
-
if (!baseUrl)
|
|
14
|
-
throw new Error("MemoryClient: baseUrl is required");
|
|
15
|
-
}
|
|
16
|
-
async search(query, opts) {
|
|
17
|
-
const resp = await this.post("/memory/search", {
|
|
18
|
-
query,
|
|
19
|
-
limit: opts?.limit ?? 10,
|
|
20
|
-
topic: opts?.topic,
|
|
21
|
-
subtopic: opts?.subtopic,
|
|
22
|
-
tag: opts?.tag,
|
|
23
|
-
includeKnowledge: opts?.includeKnowledge ?? true,
|
|
24
|
-
});
|
|
25
|
-
return resp.data;
|
|
26
|
-
}
|
|
27
|
-
async store(text, opts) {
|
|
28
|
-
const resp = await this.post("/memory/store", {
|
|
29
|
-
text,
|
|
30
|
-
topic: opts?.topic ?? "general",
|
|
31
|
-
subtopic: opts?.subtopic ?? "general",
|
|
32
|
-
tag: opts?.tag ?? "fact",
|
|
33
|
-
importance: opts?.importance ?? 0.7,
|
|
34
|
-
});
|
|
35
|
-
return resp.data;
|
|
36
|
-
}
|
|
37
|
-
async ingest(sessionKey, messages, metadata) {
|
|
38
|
-
await this.post("/memory/ingest", {
|
|
39
|
-
agentId: this.agentId,
|
|
40
|
-
sessionKey,
|
|
41
|
-
lastProcessedIndex: messages.length > 0 ? messages[messages.length - 1].index : -1,
|
|
42
|
-
messages,
|
|
43
|
-
metadata,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
async loadContext(tier, topicHint) {
|
|
47
|
-
const params = new URLSearchParams({ tier: String(tier) });
|
|
48
|
-
if (topicHint)
|
|
49
|
-
params.set("topicHint", topicHint);
|
|
50
|
-
const resp = await this.get(`/memory/context?${params.toString()}`);
|
|
51
|
-
return resp.data;
|
|
52
|
-
}
|
|
53
|
-
async lookupEntity(subject) {
|
|
54
|
-
const resp = await this.get(`/memory/knowledge/entities?subject=${encodeURIComponent(subject)}`);
|
|
55
|
-
return resp.data;
|
|
56
|
-
}
|
|
57
|
-
async navigate() {
|
|
58
|
-
const resp = await this.get("/memory/navigate");
|
|
59
|
-
return resp.data;
|
|
60
|
-
}
|
|
61
|
-
async deleteMemory(memoryId) {
|
|
62
|
-
await this.del(`/memory/${encodeURIComponent(memoryId)}`);
|
|
63
|
-
}
|
|
64
|
-
async stats() {
|
|
65
|
-
const resp = await this.get("/memory/stats");
|
|
66
|
-
return resp.data;
|
|
67
|
-
}
|
|
68
|
-
async post(path, body) {
|
|
69
|
-
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
70
|
-
method: "POST",
|
|
71
|
-
headers: {
|
|
72
|
-
"Content-Type": "application/json",
|
|
73
|
-
Authorization: `Bearer ${this.agentApiKey}`,
|
|
74
|
-
"x-agent-id": this.agentId,
|
|
75
|
-
},
|
|
76
|
-
body: JSON.stringify(body),
|
|
77
|
-
});
|
|
78
|
-
if (!resp.ok) {
|
|
79
|
-
throw new Error(`Memory API error: ${String(resp.status)} ${await resp.text()}`);
|
|
80
|
-
}
|
|
81
|
-
return resp.json();
|
|
82
|
-
}
|
|
83
|
-
async get(path) {
|
|
84
|
-
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
85
|
-
headers: {
|
|
86
|
-
Authorization: `Bearer ${this.agentApiKey}`,
|
|
87
|
-
"x-agent-id": this.agentId,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
if (!resp.ok) {
|
|
91
|
-
throw new Error(`Memory API error: ${String(resp.status)} ${await resp.text()}`);
|
|
92
|
-
}
|
|
93
|
-
return resp.json();
|
|
94
|
-
}
|
|
95
|
-
async del(path) {
|
|
96
|
-
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
97
|
-
method: "DELETE",
|
|
98
|
-
headers: {
|
|
99
|
-
Authorization: `Bearer ${this.agentApiKey}`,
|
|
100
|
-
"x-agent-id": this.agentId,
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
if (!resp.ok) {
|
|
104
|
-
throw new Error(`Memory API error: ${String(resp.status)} ${await resp.text()}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=memory-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-client.js","sourceRoot":"","sources":["../src/memory-client.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,YAAY;IAEJ;IACA;IACA;IAHnB,YACmB,OAAe,EACf,WAAmB,EACnB,OAAe;QAFf,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAQ;QAEhC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,IAM3B;QACC,MAAM,IAAI,GAAG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F"}
|
package/src/memory-client.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import type { MemorySearchResult, MemoryContext, MemoryMessage, SessionMetadata } from "./types.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* HTTP client for services/memory.
|
|
5
|
-
* All memory operations go through the Lambda service — no direct Turbopuffer/DynamoDB access.
|
|
6
|
-
*/
|
|
7
|
-
export class MemoryClient {
|
|
8
|
-
constructor(
|
|
9
|
-
private readonly baseUrl: string,
|
|
10
|
-
private readonly agentApiKey: string,
|
|
11
|
-
private readonly agentId: string,
|
|
12
|
-
) {
|
|
13
|
-
if (!baseUrl) throw new Error("MemoryClient: baseUrl is required");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async search(query: string, opts?: {
|
|
17
|
-
limit?: number;
|
|
18
|
-
topic?: string;
|
|
19
|
-
subtopic?: string;
|
|
20
|
-
tag?: string;
|
|
21
|
-
includeKnowledge?: boolean;
|
|
22
|
-
}): Promise<MemorySearchResult> {
|
|
23
|
-
const resp = await this.post<{ data: MemorySearchResult }>("/memory/search", {
|
|
24
|
-
query,
|
|
25
|
-
limit: opts?.limit ?? 10,
|
|
26
|
-
topic: opts?.topic,
|
|
27
|
-
subtopic: opts?.subtopic,
|
|
28
|
-
tag: opts?.tag,
|
|
29
|
-
includeKnowledge: opts?.includeKnowledge ?? true,
|
|
30
|
-
});
|
|
31
|
-
return resp.data;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async store(text: string, opts?: {
|
|
35
|
-
topic?: string;
|
|
36
|
-
subtopic?: string;
|
|
37
|
-
tag?: string;
|
|
38
|
-
importance?: number;
|
|
39
|
-
}): Promise<{ memoryId: string }> {
|
|
40
|
-
const resp = await this.post<{ data: { memoryId: string } }>("/memory/store", {
|
|
41
|
-
text,
|
|
42
|
-
topic: opts?.topic ?? "general",
|
|
43
|
-
subtopic: opts?.subtopic ?? "general",
|
|
44
|
-
tag: opts?.tag ?? "fact",
|
|
45
|
-
importance: opts?.importance ?? 0.7,
|
|
46
|
-
});
|
|
47
|
-
return resp.data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async ingest(sessionKey: string, messages: MemoryMessage[], metadata?: SessionMetadata): Promise<void> {
|
|
51
|
-
await this.post("/memory/ingest", {
|
|
52
|
-
agentId: this.agentId,
|
|
53
|
-
sessionKey,
|
|
54
|
-
lastProcessedIndex: messages.length > 0 ? messages[messages.length - 1].index : -1,
|
|
55
|
-
messages,
|
|
56
|
-
metadata,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async loadContext(tier: number, topicHint?: string): Promise<MemoryContext> {
|
|
61
|
-
const params = new URLSearchParams({ tier: String(tier) });
|
|
62
|
-
if (topicHint) params.set("topicHint", topicHint);
|
|
63
|
-
const resp = await this.get<{ data: MemoryContext }>(`/memory/context?${params.toString()}`);
|
|
64
|
-
return resp.data;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async lookupEntity(subject: string): Promise<{
|
|
68
|
-
subject: string;
|
|
69
|
-
triples: { tripleId: string; predicate: string; object: string; validFrom: string; validTo?: string; confidence: number }[];
|
|
70
|
-
}> {
|
|
71
|
-
const resp = await this.get<{ data: { subject: string; triples: { tripleId: string; predicate: string; object: string; validFrom: string; validTo?: string; confidence: number }[] } }>(
|
|
72
|
-
`/memory/knowledge/entities?subject=${encodeURIComponent(subject)}`,
|
|
73
|
-
);
|
|
74
|
-
return resp.data;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async navigate(): Promise<unknown> {
|
|
78
|
-
const resp = await this.get<{ data: unknown }>("/memory/navigate");
|
|
79
|
-
return resp.data;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async deleteMemory(memoryId: string): Promise<void> {
|
|
83
|
-
await this.del(`/memory/${encodeURIComponent(memoryId)}`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async stats(): Promise<{ vectorCount: number; tripleCount: number; storageEstimateBytes: number }> {
|
|
87
|
-
const resp = await this.get<{ data: { vectorCount: number; tripleCount: number; storageEstimateBytes: number } }>("/memory/stats");
|
|
88
|
-
return resp.data;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private async post<T>(path: string, body: unknown): Promise<T> {
|
|
92
|
-
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
93
|
-
method: "POST",
|
|
94
|
-
headers: {
|
|
95
|
-
"Content-Type": "application/json",
|
|
96
|
-
Authorization: `Bearer ${this.agentApiKey}`,
|
|
97
|
-
"x-agent-id": this.agentId,
|
|
98
|
-
},
|
|
99
|
-
body: JSON.stringify(body),
|
|
100
|
-
});
|
|
101
|
-
if (!resp.ok) {
|
|
102
|
-
throw new Error(`Memory API error: ${String(resp.status)} ${await resp.text()}`);
|
|
103
|
-
}
|
|
104
|
-
return resp.json() as Promise<T>;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private async get<T>(path: string): Promise<T> {
|
|
108
|
-
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
109
|
-
headers: {
|
|
110
|
-
Authorization: `Bearer ${this.agentApiKey}`,
|
|
111
|
-
"x-agent-id": this.agentId,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
if (!resp.ok) {
|
|
115
|
-
throw new Error(`Memory API error: ${String(resp.status)} ${await resp.text()}`);
|
|
116
|
-
}
|
|
117
|
-
return resp.json() as Promise<T>;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private async del(path: string): Promise<void> {
|
|
121
|
-
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
122
|
-
method: "DELETE",
|
|
123
|
-
headers: {
|
|
124
|
-
Authorization: `Bearer ${this.agentApiKey}`,
|
|
125
|
-
"x-agent-id": this.agentId,
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
if (!resp.ok) {
|
|
129
|
-
throw new Error(`Memory API error: ${String(resp.status)} ${await resp.text()}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|