@pentatonic-ai/ai-agent-sdk 0.4.0-beta.2 → 0.4.0
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/bin/cli.js +15 -1
- package/package.json +4 -3
- package/packages/memory/src/migrate.js +13 -9
- package/packages/memory/src/search.js +1 -1
package/bin/cli.js
CHANGED
|
@@ -190,13 +190,27 @@ async function setupLocalMemory() {
|
|
|
190
190
|
llmSpinner.fail(`Failed to pull ${llmModel}. Run manually: docker compose exec ollama ollama pull ${llmModel}`);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
// Write local config
|
|
193
|
+
// Write local config (warn if hosted config exists)
|
|
194
194
|
const configDir = join(homedir(), ".claude-pentatonic");
|
|
195
195
|
if (!existsSync(configDir)) {
|
|
196
196
|
mkdirSync(configDir, { recursive: true });
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
const configPath = join(configDir, "tes-memory.local.md");
|
|
200
|
+
if (existsSync(configPath)) {
|
|
201
|
+
const existing = readFileSync(configPath, "utf-8");
|
|
202
|
+
if (existing.includes("tes_endpoint") && !existing.includes("mode: local")) {
|
|
203
|
+
console.log("\n ⚠ Hosted TES config detected. Switching to local mode will");
|
|
204
|
+
console.log(" disable hosted memory. To restore, run: npx @pentatonic-ai/ai-agent-sdk init\n");
|
|
205
|
+
const confirm = await ask(" Switch to local mode? (y/n): ");
|
|
206
|
+
if (confirm.toLowerCase() !== "y") {
|
|
207
|
+
console.log(" Cancelled. Hosted config unchanged.\n");
|
|
208
|
+
rl.close();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
200
214
|
writeFileSync(
|
|
201
215
|
configPath,
|
|
202
216
|
`---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pentatonic-ai/ai-agent-sdk",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"prepare": "node build.js",
|
|
31
31
|
"build": "node build.js",
|
|
32
|
-
"test": "NODE_OPTIONS='--experimental-vm-modules' jest --config jest.config.cjs",
|
|
32
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest --config jest.config.cjs --testPathIgnorePatterns='/e2e/'",
|
|
33
33
|
"test:watch": "NODE_OPTIONS='--experimental-vm-modules' jest --config jest.config.cjs --watch",
|
|
34
34
|
"prepublishOnly": "npm run build && npm test"
|
|
35
35
|
},
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@jest/globals": "^29.7.0",
|
|
66
|
-
"jest": "^29.7.0"
|
|
66
|
+
"jest": "^29.7.0",
|
|
67
|
+
"pg": "^8.20.0"
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -5,22 +5,26 @@
|
|
|
5
5
|
* in a schema_migrations table.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { readFileSync, readdirSync } from "fs";
|
|
9
|
-
import { resolve, dirname } from "path";
|
|
10
|
-
import { fileURLToPath } from "url";
|
|
11
|
-
|
|
12
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
const MIGRATIONS_DIR = resolve(__dirname, "../migrations");
|
|
14
|
-
|
|
15
8
|
/**
|
|
16
9
|
* Apply all pending database migrations.
|
|
17
10
|
*
|
|
11
|
+
* Note: This function uses Node.js fs/path APIs and will not work in
|
|
12
|
+
* Cloudflare Workers. TES uses its own migration system instead.
|
|
13
|
+
*
|
|
18
14
|
* @param {Function} db - Database query function: (sql, params) => {rows}
|
|
19
15
|
* @param {object} [opts]
|
|
20
16
|
* @param {Function} [opts.logger] - Optional logger
|
|
17
|
+
* @param {string} [opts.migrationsDir] - Override migrations directory
|
|
21
18
|
* @returns {Promise<{applied: string[], total: number}>}
|
|
22
19
|
*/
|
|
23
20
|
export async function migrate(db, opts = {}) {
|
|
21
|
+
const { readFileSync, readdirSync } = await import("fs");
|
|
22
|
+
const { resolve, dirname } = await import("path");
|
|
23
|
+
const { fileURLToPath } = await import("url");
|
|
24
|
+
|
|
25
|
+
const migrationsDir =
|
|
26
|
+
opts.migrationsDir ||
|
|
27
|
+
resolve(dirname(fileURLToPath(import.meta.url)), "../migrations");
|
|
24
28
|
const log = opts.logger || (() => {});
|
|
25
29
|
|
|
26
30
|
// Ensure migrations tracking table exists
|
|
@@ -40,7 +44,7 @@ export async function migrate(db, opts = {}) {
|
|
|
40
44
|
const appliedSet = new Set((applied.rows || []).map((r) => r.name));
|
|
41
45
|
|
|
42
46
|
// Read migration files
|
|
43
|
-
const files = readdirSync(
|
|
47
|
+
const files = readdirSync(migrationsDir)
|
|
44
48
|
.filter((f) => f.endsWith(".sql"))
|
|
45
49
|
.sort();
|
|
46
50
|
|
|
@@ -49,7 +53,7 @@ export async function migrate(db, opts = {}) {
|
|
|
49
53
|
for (const file of files) {
|
|
50
54
|
if (appliedSet.has(file)) continue;
|
|
51
55
|
|
|
52
|
-
const sql = readFileSync(resolve(
|
|
56
|
+
const sql = readFileSync(resolve(migrationsDir, file), "utf-8");
|
|
53
57
|
log(`Applying migration: ${file}`);
|
|
54
58
|
|
|
55
59
|
await db(sql, []);
|
|
@@ -174,6 +174,6 @@ function mapRow(row) {
|
|
|
174
174
|
: null,
|
|
175
175
|
created_at: row.created_at ? new Date(row.created_at).toISOString() : null,
|
|
176
176
|
updated_at: row.updated_at ? new Date(row.updated_at).toISOString() : null,
|
|
177
|
-
similarity: row.final_score
|
|
177
|
+
similarity: parseFloat(row.final_score || row.confidence || 0),
|
|
178
178
|
};
|
|
179
179
|
}
|