@senselab-ai/amfs 0.2.0 → 0.3.0
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/memory.d.ts +35 -0
- package/dist/memory.js +99 -0
- package/package.json +1 -1
package/dist/memory.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface AgentMemoryOptions {
|
|
|
11
11
|
config?: AMFSConfig;
|
|
12
12
|
}
|
|
13
13
|
export interface SearchOptions {
|
|
14
|
+
query?: string;
|
|
14
15
|
entityPath?: string;
|
|
15
16
|
entityPaths?: string[];
|
|
16
17
|
minConfidence?: number;
|
|
@@ -133,6 +134,40 @@ export declare class AgentMemory {
|
|
|
133
134
|
tree(maxDepth?: number): string;
|
|
134
135
|
/** Reset the session read log. */
|
|
135
136
|
clearReadLog(): void;
|
|
137
|
+
/** Join a room. The user owning this agent must have an accepted invite. */
|
|
138
|
+
roomJoin(roomId: string): Promise<Record<string, unknown>>;
|
|
139
|
+
/** Leave a room. Knowledge snapshots are preserved in private memory. */
|
|
140
|
+
roomLeave(roomId: string): Promise<Record<string, unknown>>;
|
|
141
|
+
/** List rooms this agent's user owns or is invited to. */
|
|
142
|
+
myRooms(): Promise<Record<string, unknown>[]>;
|
|
143
|
+
/** Get room details including members, settings, and discussion status. */
|
|
144
|
+
roomInfo(roomId: string): Promise<Record<string, unknown>>;
|
|
145
|
+
/** Get recent room activity (writes, joins, discussions, negotiations). */
|
|
146
|
+
roomUpdates(roomId: string, options?: {
|
|
147
|
+
since?: string;
|
|
148
|
+
}): Promise<Record<string, unknown>>;
|
|
149
|
+
roomDiscuss(roomId: string, content: string, options?: {
|
|
150
|
+
messageType?: string;
|
|
151
|
+
addressedTo?: string;
|
|
152
|
+
}): Promise<Record<string, unknown>>;
|
|
153
|
+
roomDiscussions(roomId: string, options?: {
|
|
154
|
+
limit?: number;
|
|
155
|
+
since?: string;
|
|
156
|
+
}): Promise<Record<string, unknown>>;
|
|
157
|
+
negotiateCreate(roomId: string, title: string, options?: {
|
|
158
|
+
description?: string;
|
|
159
|
+
maxRounds?: number;
|
|
160
|
+
}): Promise<Record<string, unknown>>;
|
|
161
|
+
negotiatePropose(roomId: string, sessionId: string, options?: {
|
|
162
|
+
action?: string;
|
|
163
|
+
proposal?: Record<string, unknown>;
|
|
164
|
+
rationale?: string;
|
|
165
|
+
}): Promise<Record<string, unknown>>;
|
|
166
|
+
negotiateRespond(roomId: string, sessionId: string, action: string, options?: {
|
|
167
|
+
rationale?: string;
|
|
168
|
+
}): Promise<Record<string, unknown>>;
|
|
169
|
+
negotiateStatus(roomId: string, sessionId: string): Promise<Record<string, unknown>>;
|
|
170
|
+
private _roomRequest;
|
|
136
171
|
}
|
|
137
172
|
/**
|
|
138
173
|
* A scoped view of AgentMemory bound to a fixed entity path.
|
package/dist/memory.js
CHANGED
|
@@ -69,9 +69,17 @@ export class AgentMemory {
|
|
|
69
69
|
const ref = options.patternRef;
|
|
70
70
|
entries = entries.filter((e) => e.provenance.patternRefs.includes(ref));
|
|
71
71
|
}
|
|
72
|
+
const queryLower = options?.query && !options?.recallConfig
|
|
73
|
+
? options.query.toLowerCase()
|
|
74
|
+
: undefined;
|
|
72
75
|
for (const entry of entries) {
|
|
73
76
|
if (!entry.shared && entry.provenance.agentId !== this.agentId)
|
|
74
77
|
continue;
|
|
78
|
+
if (queryLower &&
|
|
79
|
+
!entry.key.toLowerCase().includes(queryLower) &&
|
|
80
|
+
!String(entry.value).toLowerCase().includes(queryLower) &&
|
|
81
|
+
!entry.entityPath.toLowerCase().includes(queryLower))
|
|
82
|
+
continue;
|
|
75
83
|
const ek = `${entry.entityPath}/${entry.key}`;
|
|
76
84
|
if (!seenKeys.has(ek)) {
|
|
77
85
|
seenKeys.add(ek);
|
|
@@ -371,6 +379,97 @@ export class AgentMemory {
|
|
|
371
379
|
clearReadLog() {
|
|
372
380
|
this.readTracker.clear();
|
|
373
381
|
}
|
|
382
|
+
// ── Room operations (Pro — requires HTTP adapter with rooms backend) ──
|
|
383
|
+
/** Join a room. The user owning this agent must have an accepted invite. */
|
|
384
|
+
async roomJoin(roomId) {
|
|
385
|
+
return this._roomRequest("POST", `/api/v1/rooms/${roomId}/agents`, {
|
|
386
|
+
agent_id: this.agentId,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
/** Leave a room. Knowledge snapshots are preserved in private memory. */
|
|
390
|
+
async roomLeave(roomId) {
|
|
391
|
+
return this._roomRequest("DELETE", `/api/v1/rooms/${roomId}/agents/${this.agentId}`);
|
|
392
|
+
}
|
|
393
|
+
/** List rooms this agent's user owns or is invited to. */
|
|
394
|
+
async myRooms() {
|
|
395
|
+
const result = await this._roomRequest("GET", "/api/v1/rooms");
|
|
396
|
+
return Array.isArray(result) ? result : result.rooms ?? [];
|
|
397
|
+
}
|
|
398
|
+
/** Get room details including members, settings, and discussion status. */
|
|
399
|
+
async roomInfo(roomId) {
|
|
400
|
+
return this._roomRequest("GET", `/api/v1/rooms/${roomId}`);
|
|
401
|
+
}
|
|
402
|
+
/** Get recent room activity (writes, joins, discussions, negotiations). */
|
|
403
|
+
async roomUpdates(roomId, options) {
|
|
404
|
+
const params = options?.since ? `?since=${options.since}` : "";
|
|
405
|
+
return this._roomRequest("GET", `/api/v1/rooms/${roomId}/activity${params}`);
|
|
406
|
+
}
|
|
407
|
+
// -- Discussions --
|
|
408
|
+
async roomDiscuss(roomId, content, options) {
|
|
409
|
+
return this._roomRequest("POST", `/api/v1/rooms/${roomId}/discussions`, {
|
|
410
|
+
agent_id: this.agentId,
|
|
411
|
+
content,
|
|
412
|
+
message_type: options?.messageType ?? "message",
|
|
413
|
+
addressed_to: options?.addressedTo ?? null,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
async roomDiscussions(roomId, options) {
|
|
417
|
+
const params = new URLSearchParams();
|
|
418
|
+
if (options?.limit)
|
|
419
|
+
params.set("limit", String(options.limit));
|
|
420
|
+
if (options?.since)
|
|
421
|
+
params.set("since", options.since);
|
|
422
|
+
const qs = params.toString();
|
|
423
|
+
return this._roomRequest("GET", `/api/v1/rooms/${roomId}/discussions${qs ? `?${qs}` : ""}`);
|
|
424
|
+
}
|
|
425
|
+
// -- Negotiations --
|
|
426
|
+
async negotiateCreate(roomId, title, options) {
|
|
427
|
+
return this._roomRequest("POST", `/api/v1/rooms/${roomId}/negotiations`, {
|
|
428
|
+
title,
|
|
429
|
+
description: options?.description ?? null,
|
|
430
|
+
agent_id: this.agentId,
|
|
431
|
+
max_rounds: options?.maxRounds ?? 10,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
async negotiatePropose(roomId, sessionId, options) {
|
|
435
|
+
return this._roomRequest("POST", `/api/v1/rooms/${roomId}/negotiations/${sessionId}/propose`, {
|
|
436
|
+
agent_id: this.agentId,
|
|
437
|
+
action: options?.action ?? "propose",
|
|
438
|
+
proposal: options?.proposal ?? {},
|
|
439
|
+
rationale: options?.rationale ?? null,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
async negotiateRespond(roomId, sessionId, action, options) {
|
|
443
|
+
return this.negotiatePropose(roomId, sessionId, {
|
|
444
|
+
action,
|
|
445
|
+
rationale: options?.rationale,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
async negotiateStatus(roomId, sessionId) {
|
|
449
|
+
return this._roomRequest("GET", `/api/v1/rooms/${roomId}/negotiations/${sessionId}`);
|
|
450
|
+
}
|
|
451
|
+
async _roomRequest(method, path, body) {
|
|
452
|
+
const adapter = this.adapter;
|
|
453
|
+
const baseUrl = adapter._baseUrl ?? adapter.baseUrl;
|
|
454
|
+
if (typeof baseUrl !== "string") {
|
|
455
|
+
throw new Error("Room operations require the HTTP adapter (set AMFS_HTTP_URL)");
|
|
456
|
+
}
|
|
457
|
+
const url = `${baseUrl.replace(/\/$/, "")}${path}`;
|
|
458
|
+
const headers = { "Content-Type": "application/json" };
|
|
459
|
+
const apiKey = adapter._apiKey ?? adapter.apiKey;
|
|
460
|
+
if (typeof apiKey === "string") {
|
|
461
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
462
|
+
}
|
|
463
|
+
const resp = await fetch(url, {
|
|
464
|
+
method,
|
|
465
|
+
headers,
|
|
466
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
467
|
+
});
|
|
468
|
+
if (!resp.ok) {
|
|
469
|
+
throw new Error(`Room API error: ${resp.status} ${resp.statusText}`);
|
|
470
|
+
}
|
|
471
|
+
return resp.json();
|
|
472
|
+
}
|
|
374
473
|
}
|
|
375
474
|
/**
|
|
376
475
|
* A scoped view of AgentMemory bound to a fixed entity path.
|