@pentatonic-ai/ai-agent-sdk 0.4.8 → 0.4.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pentatonic-ai/ai-agent-sdk",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "TES SDK — LLM observability and lifecycle tracking via Pentatonic Thing Event System. Track token usage, tool calls, and conversations. Manage things through event-sourced lifecycle stages with AI enrichment and vector search.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -82,8 +82,40 @@ async function main() {
82
82
 
83
83
  const memory = createMemory();
84
84
 
85
+ // Enable pgvector before migrations (so migration 002 can create the vector column)
86
+ const setupPool = new Pool({ connectionString: process.env.DATABASE_URL });
87
+ try {
88
+ await setupPool.query("CREATE EXTENSION IF NOT EXISTS vector");
89
+ process.stderr.write("[memory-server] pgvector extension enabled\n");
90
+ } catch (err) {
91
+ process.stderr.write(`[memory-server] pgvector not available: ${err.message}\n`);
92
+ }
93
+
85
94
  // Run migrations on startup
86
95
  await memory.migrate();
96
+
97
+ // Fix: if migration 002 ran without pgvector, the vector column is missing.
98
+ // Re-apply it now that the extension is enabled.
99
+ try {
100
+ const colCheck = await setupPool.query(
101
+ `SELECT 1 FROM information_schema.columns
102
+ WHERE table_name = 'memory_nodes' AND column_name = 'embedding_vec' LIMIT 1`
103
+ );
104
+ if (colCheck.rows.length === 0) {
105
+ process.stderr.write("[memory-server] embedding_vec column missing — re-applying migration 002\n");
106
+ const { readFileSync } = await import("fs");
107
+ const { resolve, dirname } = await import("path");
108
+ const { fileURLToPath } = await import("url");
109
+ const migrationPath = resolve(dirname(fileURLToPath(import.meta.url)), "../migrations/002-vector-index.sql");
110
+ const sql = readFileSync(migrationPath, "utf-8");
111
+ await setupPool.query(sql);
112
+ process.stderr.write("[memory-server] embedding_vec column created\n");
113
+ }
114
+ } catch (err) {
115
+ process.stderr.write(`[memory-server] Vector column repair skipped: ${err.message}\n`);
116
+ }
117
+ await setupPool.end();
118
+
87
119
  await memory.ensureLayers(CLIENT_ID);
88
120
 
89
121
  const server = new McpServer({