@tpsdev-ai/flair 0.3.13 → 0.3.14

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.
@@ -1,6 +1,7 @@
1
1
  import { databases } from "@harperfast/harper";
2
2
  import { patchRecord } from "./table-helpers.js";
3
3
  import { isAdmin } from "./auth-middleware.js";
4
+ import { getEmbedding } from "./embeddings-provider.js";
4
5
  export class Memory extends databases.flair.Memory {
5
6
  /**
6
7
  * Override search() to scope collection GETs by authenticated agent.
@@ -81,11 +82,23 @@ export class Memory extends databases.flair.Memory {
81
82
  const ttlHours = Number(process.env.FLAIR_EPHEMERAL_TTL_HOURS || 24);
82
83
  content.expiresAt = new Date(Date.now() + ttlHours * 3600_000).toISOString();
83
84
  }
85
+ // Generate embedding from content text
86
+ if (content.content && !content.embedding) {
87
+ const vec = await getEmbedding(content.content);
88
+ if (vec)
89
+ content.embedding = vec;
90
+ }
84
91
  return super.post(content);
85
92
  }
86
93
  async put(content) {
87
94
  const now = new Date().toISOString();
88
95
  content.updatedAt = now;
96
+ // Re-generate embedding if content changed
97
+ if (content.content && !content.embedding) {
98
+ const vec = await getEmbedding(content.content);
99
+ if (vec)
100
+ content.embedding = vec;
101
+ }
89
102
  // If archiving, record who + when
90
103
  if (content.archived === true && !content.archivedAt) {
91
104
  content.archivedAt = now;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpsdev-ai/flair",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "Identity, memory, and soul for AI agents. Cryptographic identity (Ed25519), semantic memory with local embeddings, and persistent personality — all in a single process.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1,6 +1,7 @@
1
1
  import { databases } from "@harperfast/harper";
2
2
  import { patchRecord } from "./table-helpers.js";
3
3
  import { isAdmin } from "./auth-middleware.js";
4
+ import { getEmbedding } from "./embeddings-provider.js";
4
5
 
5
6
  export class Memory extends (databases as any).flair.Memory {
6
7
  /**
@@ -90,6 +91,12 @@ export class Memory extends (databases as any).flair.Memory {
90
91
  content.expiresAt = new Date(Date.now() + ttlHours * 3600_000).toISOString();
91
92
  }
92
93
 
94
+ // Generate embedding from content text
95
+ if (content.content && !content.embedding) {
96
+ const vec = await getEmbedding(content.content);
97
+ if (vec) content.embedding = vec;
98
+ }
99
+
93
100
  return super.post(content);
94
101
  }
95
102
 
@@ -97,6 +104,12 @@ export class Memory extends (databases as any).flair.Memory {
97
104
  const now = new Date().toISOString();
98
105
  content.updatedAt = now;
99
106
 
107
+ // Re-generate embedding if content changed
108
+ if (content.content && !content.embedding) {
109
+ const vec = await getEmbedding(content.content);
110
+ if (vec) content.embedding = vec;
111
+ }
112
+
100
113
  // If archiving, record who + when
101
114
  if (content.archived === true && !content.archivedAt) {
102
115
  content.archivedAt = now;