@senselab-ai/amfs 0.3.1 → 0.3.2

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.
@@ -41,9 +41,14 @@ export declare class HttpAdapter implements AmfsAdapter {
41
41
  query?: string;
42
42
  entityPath?: string;
43
43
  minConfidence?: number;
44
+ maxConfidence?: number;
44
45
  agentId?: string;
46
+ since?: string;
47
+ patternRef?: string;
45
48
  sortBy?: string;
46
49
  limit?: number;
50
+ depth?: number;
51
+ branch?: string;
47
52
  }): Promise<MemoryEntry[]>;
48
53
  watch(entityPath: string, callback: (entry: MemoryEntry) => void): WatchHandle;
49
54
  commitOutcome(record: OutcomeRecord): MemoryEntry[];
@@ -52,9 +57,26 @@ export declare class HttpAdapter implements AmfsAdapter {
52
57
  outcomeType: string;
53
58
  entityPath?: string;
54
59
  causalEntryKeys?: string[];
60
+ causalConfidence?: number;
61
+ agentId?: string;
55
62
  }): Promise<unknown>;
56
63
  statsAsync(): Promise<Record<string, unknown>>;
57
64
  healthAsync(): Promise<Record<string, unknown>>;
65
+ briefingAsync(options?: {
66
+ entityPath?: string;
67
+ limit?: number;
68
+ }): Promise<unknown>;
69
+ consolidationStatusAsync(): Promise<unknown>;
70
+ consolidationProposalsAsync(options?: {
71
+ status?: string;
72
+ limit?: number;
73
+ }): Promise<unknown>;
74
+ consolidationCandidatesAsync(options?: {
75
+ limit?: number;
76
+ }): Promise<unknown>;
77
+ consolidateAsync(options?: {
78
+ dryRun?: boolean;
79
+ }): Promise<unknown>;
58
80
  listTracesAsync(options?: {
59
81
  entityPath?: string;
60
82
  agentId?: string;
@@ -65,58 +87,58 @@ export declare class HttpAdapter implements AmfsAdapter {
65
87
  }
66
88
  export interface DecisionTraceSummary {
67
89
  id: string;
68
- agent_id: string;
69
- outcome_ref: string;
70
- outcome_type: string;
71
- decision_summary?: string;
72
- causal_entries: number;
73
- external_contexts: number;
74
- session_duration_ms?: number;
75
- created_at: string;
90
+ agentId: string;
91
+ outcomeRef: string;
92
+ outcomeType: string;
93
+ decisionSummary?: string;
94
+ causalEntries: number;
95
+ externalContexts: number;
96
+ sessionDurationMs?: number;
97
+ createdAt: string;
76
98
  }
77
99
  export interface DecisionTrace {
78
100
  id: string;
79
- agent_id: string;
80
- session_id: string;
81
- outcome_ref: string;
82
- outcome_type: string;
83
- decision_summary?: string;
84
- causal_entries: Array<{
85
- entity_path: string;
101
+ agentId: string;
102
+ sessionId: string;
103
+ outcomeRef: string;
104
+ outcomeType: string;
105
+ decisionSummary?: string;
106
+ causalEntries: Array<{
107
+ entityPath: string;
86
108
  key: string;
87
109
  version: number;
88
110
  confidence: number;
89
111
  value?: unknown;
90
- memory_type?: string;
91
- written_by?: string;
92
- read_at?: string;
112
+ memoryType?: string;
113
+ writtenBy?: string;
114
+ readAt?: string;
93
115
  }>;
94
- external_contexts: Array<{
116
+ externalContexts: Array<{
95
117
  label: string;
96
118
  summary: string;
97
119
  source?: string;
98
- recorded_at?: string;
120
+ recordedAt?: string;
99
121
  }>;
100
- query_events: Array<{
122
+ queryEvents: Array<{
101
123
  operation: string;
102
124
  parameters: Record<string, unknown>;
103
- result_count: number;
104
- duration_ms?: number;
105
- occurred_at?: string;
125
+ resultCount: number;
126
+ durationMs?: number;
127
+ occurredAt?: string;
106
128
  }>;
107
- error_events: Array<{
129
+ errorEvents: Array<{
108
130
  operation: string;
109
- error_type: string;
131
+ errorType: string;
110
132
  message: string;
111
- stack_trace?: string;
112
- occurred_at?: string;
133
+ stackTrace?: string;
134
+ occurredAt?: string;
113
135
  }>;
114
- state_diff?: {
115
- entries_created: number;
116
- entries_updated: number;
136
+ stateDiff?: {
137
+ entriesCreated: number;
138
+ entriesUpdated: number;
117
139
  };
118
- session_started_at?: string;
119
- session_ended_at?: string;
120
- session_duration_ms?: number;
121
- created_at: string;
140
+ sessionStartedAt?: string;
141
+ sessionEndedAt?: string;
142
+ sessionDurationMs?: number;
143
+ createdAt: string;
122
144
  }
@@ -2,6 +2,23 @@
2
2
  * HttpAdapter — connects the TS SDK to a remote AMFS HTTP API server.
3
3
  */
4
4
  import { createWatchHandle } from "../adapter.js";
5
+ function snakeToCamel(str) {
6
+ return str.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
7
+ }
8
+ function convertKeys(obj) {
9
+ if (obj === null || obj === undefined)
10
+ return obj;
11
+ if (Array.isArray(obj))
12
+ return obj.map(convertKeys);
13
+ if (typeof obj === "object") {
14
+ const result = {};
15
+ for (const [k, v] of Object.entries(obj)) {
16
+ result[snakeToCamel(k)] = convertKeys(v);
17
+ }
18
+ return result;
19
+ }
20
+ return obj;
21
+ }
5
22
  export class HttpAdapter {
6
23
  baseUrl;
7
24
  headers;
@@ -26,10 +43,10 @@ export class HttpAdapter {
26
43
  const body = await resp.text().catch(() => "");
27
44
  throw new Error(`AMFS API ${resp.status}: ${body}`);
28
45
  }
29
- return resp.json();
46
+ const raw = await resp.json();
47
+ return convertKeys(raw);
30
48
  }
31
49
  read(entityPath, key, options) {
32
- // Synchronous interface — return null and let callers use readAsync
33
50
  return null;
34
51
  }
35
52
  async readAsync(entityPath, key) {
@@ -41,7 +58,6 @@ export class HttpAdapter {
41
58
  }
42
59
  }
43
60
  write(entry) {
44
- // Synchronous interface — callers should use writeAsync for HTTP
45
61
  return entry;
46
62
  }
47
63
  async writeAsync(entry) {
@@ -62,7 +78,6 @@ export class HttpAdapter {
62
78
  });
63
79
  }
64
80
  list(entityPath, options) {
65
- // Synchronous interface — return empty, callers should use listAsync
66
81
  return [];
67
82
  }
68
83
  async listAsync(entityPath, options) {
@@ -72,7 +87,10 @@ export class HttpAdapter {
72
87
  if (options?.includeSuperseded)
73
88
  params.set("include_superseded", "true");
74
89
  const qs = params.toString();
75
- return this.fetch(`/api/v1/entries${qs ? `?${qs}` : ""}`);
90
+ const data = await this.fetch(`/api/v1/entries${qs ? `?${qs}` : ""}`);
91
+ if (Array.isArray(data))
92
+ return data;
93
+ return data.entries ?? [];
76
94
  }
77
95
  async searchAsync(query) {
78
96
  return this.fetch("/api/v1/search", {
@@ -82,8 +100,13 @@ export class HttpAdapter {
82
100
  entity_path: query.entityPath,
83
101
  min_confidence: query.minConfidence ?? 0.0,
84
102
  limit: query.limit ?? 100,
103
+ ...(query.maxConfidence != null ? { max_confidence: query.maxConfidence } : {}),
85
104
  ...(query.agentId ? { agent_id: query.agentId } : {}),
105
+ ...(query.since ? { since: query.since } : {}),
106
+ ...(query.patternRef ? { pattern_ref: query.patternRef } : {}),
86
107
  ...(query.sortBy ? { sort_by: query.sortBy } : {}),
108
+ ...(query.depth != null ? { depth: query.depth } : {}),
109
+ ...(query.branch ? { branch: query.branch } : {}),
87
110
  }),
88
111
  });
89
112
  }
@@ -110,7 +133,7 @@ export class HttpAdapter {
110
133
  const raw = line.slice(5).trim();
111
134
  if (raw) {
112
135
  try {
113
- callback(JSON.parse(raw));
136
+ callback(convertKeys(JSON.parse(raw)));
114
137
  }
115
138
  catch { /* skip malformed */ }
116
139
  }
@@ -127,10 +150,10 @@ export class HttpAdapter {
127
150
  return createWatchHandle(() => controller.abort());
128
151
  }
129
152
  commitOutcome(record) {
130
- // Synchronous interface — return empty, callers should use commitOutcomeAsync
131
153
  return [];
132
154
  }
133
155
  async commitOutcomeAsync(record) {
156
+ const agentId = record.agentId ?? this.agentId;
134
157
  return this.fetch("/api/v1/outcomes", {
135
158
  method: "POST",
136
159
  body: JSON.stringify({
@@ -138,6 +161,8 @@ export class HttpAdapter {
138
161
  outcome_type: record.outcomeType,
139
162
  ...(record.entityPath ? { entity_path: record.entityPath } : {}),
140
163
  ...(record.causalEntryKeys?.length ? { causal_entry_keys: record.causalEntryKeys } : {}),
164
+ ...(record.causalConfidence != null ? { causal_confidence: record.causalConfidence } : {}),
165
+ ...(agentId ? { agent_id: agentId } : {}),
141
166
  }),
142
167
  });
143
168
  }
@@ -147,6 +172,40 @@ export class HttpAdapter {
147
172
  async healthAsync() {
148
173
  return this.fetch("/api/v1/health");
149
174
  }
175
+ async briefingAsync(options) {
176
+ const params = new URLSearchParams();
177
+ if (options?.entityPath)
178
+ params.set("entity_path", options.entityPath);
179
+ if (options?.limit)
180
+ params.set("limit", String(options.limit));
181
+ const qs = params.toString();
182
+ return this.fetch(`/api/v1/briefing${qs ? `?${qs}` : ""}`);
183
+ }
184
+ async consolidationStatusAsync() {
185
+ return this.fetch("/api/v1/cortex/consolidation/status");
186
+ }
187
+ async consolidationProposalsAsync(options) {
188
+ const params = new URLSearchParams();
189
+ if (options?.status)
190
+ params.set("status", options.status);
191
+ if (options?.limit)
192
+ params.set("limit", String(options.limit));
193
+ const qs = params.toString();
194
+ return this.fetch(`/api/v1/cortex/consolidation/proposals${qs ? `?${qs}` : ""}`);
195
+ }
196
+ async consolidationCandidatesAsync(options) {
197
+ const params = new URLSearchParams();
198
+ if (options?.limit)
199
+ params.set("limit", String(options.limit));
200
+ const qs = params.toString();
201
+ return this.fetch(`/api/v1/cortex/consolidation/candidates${qs ? `?${qs}` : ""}`);
202
+ }
203
+ async consolidateAsync(options) {
204
+ return this.fetch("/api/v1/cortex/consolidate", {
205
+ method: "POST",
206
+ body: JSON.stringify({ dry_run: options?.dryRun ?? true }),
207
+ });
208
+ }
150
209
  async listTracesAsync(options) {
151
210
  const params = new URLSearchParams();
152
211
  if (options?.entityPath)
@@ -159,6 +218,8 @@ export class HttpAdapter {
159
218
  params.set("limit", String(options.limit));
160
219
  const qs = params.toString();
161
220
  const data = await this.fetch(`/api/v1/traces${qs ? `?${qs}` : ""}`);
221
+ if (Array.isArray(data))
222
+ return data;
162
223
  return data.traces ?? [];
163
224
  }
164
225
  async getTraceAsync(traceId) {
package/dist/memory.d.ts CHANGED
@@ -20,7 +20,7 @@ export interface SearchOptions {
20
20
  since?: string;
21
21
  patternRef?: string;
22
22
  limit?: number;
23
- sortBy?: "confidence" | "recency" | "version";
23
+ sortBy?: "confidence" | "recency" | "version" | "priority";
24
24
  recallConfig?: RecallConfig;
25
25
  }
26
26
  export interface MemoryStats {
package/dist/models.d.ts CHANGED
@@ -39,6 +39,11 @@ export interface MemoryEntry {
39
39
  contentHash: string | null;
40
40
  integrityChain: string | null;
41
41
  commitId: string | null;
42
+ memoryType?: string;
43
+ branch?: string;
44
+ recallCount?: number;
45
+ priorityScore?: number;
46
+ tier?: string;
42
47
  }
43
48
  export interface CommitEntry {
44
49
  entityPath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senselab-ai/amfs",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "AMFS TypeScript SDK — Agent Memory File System",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",