@hivemagnus/hivemem-sdk 1.0.2 → 1.0.3

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/context.js CHANGED
@@ -10,6 +10,18 @@ export class ContextPackage {
10
10
  if (formatted && typeof formatted === "object" && Array.isArray(formatted.messages)) {
11
11
  return formatted.messages;
12
12
  }
13
+ if (formatted && typeof formatted === "object"
14
+ && formatted.format === "markdown"
15
+ && typeof formatted.content === "string") {
16
+ // Use the server's selected context verbatim, preserving citations and its token budget.
17
+ const content = formatted.content;
18
+ const messages = [];
19
+ if (options.assistantPeerId)
20
+ messages.push({ role: "system", content: `Assistant peer id: ${options.assistantPeerId}` });
21
+ if (content)
22
+ messages.push({ role: "system", content });
23
+ return messages;
24
+ }
13
25
  const messages = [];
14
26
  if (options.assistantPeerId) {
15
27
  messages.push({ role: "system", content: `Assistant peer id: ${options.assistantPeerId}` });
@@ -24,8 +36,12 @@ export class ContextPackage {
24
36
  if (content)
25
37
  messages.push({ role: "system", content: `HiveMem peer context:\n${content}` });
26
38
  }
27
- for (const memory of (this.data.memories ?? [])) {
28
- messages.push({ role: "system", content: `Memory: ${memory.content}` });
39
+ for (const entry of this.data.memories ?? []) {
40
+ const memory = "memory" in entry && entry.memory && typeof entry.memory === "object"
41
+ ? entry.memory
42
+ : entry;
43
+ if (typeof memory.content === "string")
44
+ messages.push({ role: "system", content: `Memory: ${memory.content}` });
29
45
  }
30
46
  return messages;
31
47
  }
package/dist/types.d.ts CHANGED
@@ -148,9 +148,18 @@ export interface WebhookEndpoint {
148
148
  updated_at: string;
149
149
  deleted_at?: string | null;
150
150
  }
151
+ export interface ContextMemory {
152
+ memory: MemoryRecord;
153
+ collection: string;
154
+ score: number | null;
155
+ tokens_used: number;
156
+ citation?: SearchResponse["results"][number]["citation"];
157
+ score_components?: Record<string, number | null>;
158
+ selection_reason?: "query" | "relationship" | "entity";
159
+ }
151
160
  export interface ContextResponse {
152
161
  summary?: unknown;
153
- memories?: MemoryRecord[];
162
+ memories?: Array<ContextMemory | MemoryRecord>;
154
163
  representation?: unknown;
155
164
  formatted_context?: unknown;
156
165
  [key: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hivemagnus/hivemem-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "TypeScript client for HiveMem, the shared long-term memory service for AI agents",
5
5
  "keywords": [
6
6
  "hivemem",