@senselab-ai/amfs 0.3.0 → 0.3.1
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/dist/adapters/http.d.ts +10 -0
- package/dist/adapters/http.js +11 -0
- package/package.json +1 -1
package/dist/adapters/http.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ import type { AmfsAdapter, WatchHandle } from "../adapter.js";
|
|
|
6
6
|
export interface HttpAdapterOptions {
|
|
7
7
|
url: string;
|
|
8
8
|
apiKey?: string;
|
|
9
|
+
agentId?: string;
|
|
9
10
|
headers?: Record<string, string>;
|
|
10
11
|
}
|
|
11
12
|
export declare class HttpAdapter implements AmfsAdapter {
|
|
12
13
|
private readonly baseUrl;
|
|
13
14
|
private readonly headers;
|
|
15
|
+
private readonly agentId;
|
|
14
16
|
constructor(opts: HttpAdapterOptions);
|
|
15
17
|
private fetch;
|
|
16
18
|
read(entityPath: string, key: string, options?: {
|
|
@@ -24,6 +26,10 @@ export declare class HttpAdapter implements AmfsAdapter {
|
|
|
24
26
|
value: unknown;
|
|
25
27
|
confidence?: number;
|
|
26
28
|
memoryType?: string;
|
|
29
|
+
agentId?: string;
|
|
30
|
+
shared?: boolean;
|
|
31
|
+
patternRefs?: string[];
|
|
32
|
+
branch?: string;
|
|
27
33
|
}): Promise<MemoryEntry>;
|
|
28
34
|
list(entityPath?: string, options?: {
|
|
29
35
|
includeSuperseded?: boolean;
|
|
@@ -35,6 +41,8 @@ export declare class HttpAdapter implements AmfsAdapter {
|
|
|
35
41
|
query?: string;
|
|
36
42
|
entityPath?: string;
|
|
37
43
|
minConfidence?: number;
|
|
44
|
+
agentId?: string;
|
|
45
|
+
sortBy?: string;
|
|
38
46
|
limit?: number;
|
|
39
47
|
}): Promise<MemoryEntry[]>;
|
|
40
48
|
watch(entityPath: string, callback: (entry: MemoryEntry) => void): WatchHandle;
|
|
@@ -42,6 +50,8 @@ export declare class HttpAdapter implements AmfsAdapter {
|
|
|
42
50
|
commitOutcomeAsync(record: {
|
|
43
51
|
outcomeRef: string;
|
|
44
52
|
outcomeType: string;
|
|
53
|
+
entityPath?: string;
|
|
54
|
+
causalEntryKeys?: string[];
|
|
45
55
|
}): Promise<unknown>;
|
|
46
56
|
statsAsync(): Promise<Record<string, unknown>>;
|
|
47
57
|
healthAsync(): Promise<Record<string, unknown>>;
|
package/dist/adapters/http.js
CHANGED
|
@@ -5,8 +5,10 @@ import { createWatchHandle } from "../adapter.js";
|
|
|
5
5
|
export class HttpAdapter {
|
|
6
6
|
baseUrl;
|
|
7
7
|
headers;
|
|
8
|
+
agentId;
|
|
8
9
|
constructor(opts) {
|
|
9
10
|
this.baseUrl = opts.url.replace(/\/+$/, "");
|
|
11
|
+
this.agentId = opts.agentId;
|
|
10
12
|
this.headers = {
|
|
11
13
|
"Content-Type": "application/json",
|
|
12
14
|
...opts.headers,
|
|
@@ -43,6 +45,7 @@ export class HttpAdapter {
|
|
|
43
45
|
return entry;
|
|
44
46
|
}
|
|
45
47
|
async writeAsync(entry) {
|
|
48
|
+
const agentId = entry.agentId ?? this.agentId;
|
|
46
49
|
return this.fetch("/api/v1/entries", {
|
|
47
50
|
method: "POST",
|
|
48
51
|
body: JSON.stringify({
|
|
@@ -51,6 +54,10 @@ export class HttpAdapter {
|
|
|
51
54
|
value: entry.value,
|
|
52
55
|
confidence: entry.confidence ?? 1.0,
|
|
53
56
|
memory_type: entry.memoryType ?? "fact",
|
|
57
|
+
...(agentId ? { agent_id: agentId } : {}),
|
|
58
|
+
...(entry.shared != null ? { shared: entry.shared } : {}),
|
|
59
|
+
...(entry.patternRefs?.length ? { pattern_refs: entry.patternRefs } : {}),
|
|
60
|
+
...(entry.branch ? { branch: entry.branch } : {}),
|
|
54
61
|
}),
|
|
55
62
|
});
|
|
56
63
|
}
|
|
@@ -75,6 +82,8 @@ export class HttpAdapter {
|
|
|
75
82
|
entity_path: query.entityPath,
|
|
76
83
|
min_confidence: query.minConfidence ?? 0.0,
|
|
77
84
|
limit: query.limit ?? 100,
|
|
85
|
+
...(query.agentId ? { agent_id: query.agentId } : {}),
|
|
86
|
+
...(query.sortBy ? { sort_by: query.sortBy } : {}),
|
|
78
87
|
}),
|
|
79
88
|
});
|
|
80
89
|
}
|
|
@@ -127,6 +136,8 @@ export class HttpAdapter {
|
|
|
127
136
|
body: JSON.stringify({
|
|
128
137
|
outcome_ref: record.outcomeRef,
|
|
129
138
|
outcome_type: record.outcomeType,
|
|
139
|
+
...(record.entityPath ? { entity_path: record.entityPath } : {}),
|
|
140
|
+
...(record.causalEntryKeys?.length ? { causal_entry_keys: record.causalEntryKeys } : {}),
|
|
130
141
|
}),
|
|
131
142
|
});
|
|
132
143
|
}
|