@pentatonic-ai/ai-agent-sdk 0.4.6 → 0.4.7

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.6",
3
+ "version": "0.4.7",
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",
@@ -25,6 +25,14 @@ import { createMemorySystem } from "./index.js";
25
25
 
26
26
  const { Pool } = pg;
27
27
 
28
+ // Prevent unhandled rejections from killing the process
29
+ process.on("uncaughtException", (err) => {
30
+ process.stderr.write(`[memory-server] Uncaught: ${err.message}\n`);
31
+ });
32
+ process.on("unhandledRejection", (err) => {
33
+ process.stderr.write(`[memory-server] Unhandled rejection: ${err?.message || err}\n`);
34
+ });
35
+
28
36
  const CLIENT_ID = process.env.CLIENT_ID || "default";
29
37
 
30
38
  function createMemory() {
@@ -250,25 +258,19 @@ async function main() {
250
258
 
251
259
  if (url.pathname === "/search" && req.method === "POST") {
252
260
  try {
253
- const results = await memory.search(body.query || "", {
261
+ // Use text search by default (fast, no external dependencies).
262
+ // Vector search available via ?mode=vector if embeddings are working.
263
+ const useVector = url.searchParams.get("mode") === "vector";
264
+ const searchFn = useVector ? memory.search : memory.textSearch;
265
+ const results = await searchFn(body.query || "", {
254
266
  clientId: CLIENT_ID,
255
267
  limit: body.limit || 5,
256
268
  minScore: body.min_score || 0.3,
257
269
  });
258
270
  res.end(JSON.stringify({ results }));
259
271
  } catch (err) {
260
- process.stderr.write(`[memory-server] Search error: ${err.message}\n`);
261
- // Fall back to text search
262
- try {
263
- const results = await memory.textSearch(body.query || "", {
264
- clientId: CLIENT_ID,
265
- limit: body.limit || 5,
266
- });
267
- res.end(JSON.stringify({ results }));
268
- } catch (err2) {
269
- process.stderr.write(`[memory-server] Text search also failed: ${err2.message}\n`);
270
- res.end(JSON.stringify({ results: [], error: err2.message }));
271
- }
272
+ process.stderr.write(`[memory-server] Search error: ${err.message}\n${err.stack}\n`);
273
+ res.end(JSON.stringify({ results: [], error: err.message }));
272
274
  }
273
275
  } else if (url.pathname === "/store" && req.method === "POST") {
274
276
  try {