@pentatonic-ai/ai-agent-sdk 0.4.5 → 0.4.6
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.
|
|
3
|
+
"version": "0.4.6",
|
|
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",
|
|
@@ -50,10 +50,14 @@ export async function search(db, ai, query, opts = {}) {
|
|
|
50
50
|
return textSearch(db, query, opts);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// Generate query embedding
|
|
54
|
-
|
|
53
|
+
// Generate query embedding — fall back to text search if embedding fails
|
|
54
|
+
let embResult;
|
|
55
|
+
try {
|
|
56
|
+
embResult = await ai.embed(query, "query");
|
|
57
|
+
} catch {
|
|
58
|
+
return textSearch(db, query, opts);
|
|
59
|
+
}
|
|
55
60
|
if (!embResult?.embedding) {
|
|
56
|
-
// Fall back to text-only search
|
|
57
61
|
return textSearch(db, query, opts);
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -249,18 +249,39 @@ async function main() {
|
|
|
249
249
|
res.setHeader("Content-Type", "application/json");
|
|
250
250
|
|
|
251
251
|
if (url.pathname === "/search" && req.method === "POST") {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
try {
|
|
253
|
+
const results = await memory.search(body.query || "", {
|
|
254
|
+
clientId: CLIENT_ID,
|
|
255
|
+
limit: body.limit || 5,
|
|
256
|
+
minScore: body.min_score || 0.3,
|
|
257
|
+
});
|
|
258
|
+
res.end(JSON.stringify({ results }));
|
|
259
|
+
} 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
|
+
}
|
|
258
273
|
} else if (url.pathname === "/store" && req.method === "POST") {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
274
|
+
try {
|
|
275
|
+
const result = await memory.ingest(body.content || "", {
|
|
276
|
+
clientId: CLIENT_ID,
|
|
277
|
+
metadata: body.metadata || {},
|
|
278
|
+
});
|
|
279
|
+
res.end(JSON.stringify(result));
|
|
280
|
+
} catch (err) {
|
|
281
|
+
process.stderr.write(`[memory-server] Store error: ${err.message}\n`);
|
|
282
|
+
res.statusCode = 500;
|
|
283
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
284
|
+
}
|
|
264
285
|
} else if (url.pathname === "/health") {
|
|
265
286
|
res.end(JSON.stringify({ status: "ok", client: CLIENT_ID }));
|
|
266
287
|
} else {
|