Skip to content

Commit 0a10f8c

Browse files
Remove npm deprecation warnings from the CLI and DuckDB packages (#2)
1 parent 4fb97bd commit 0a10f8c

11 files changed

Lines changed: 165 additions & 884 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"agentpond": patch
3+
---
4+
5+
Replace the deprecated `duckdb` package with `@duckdb/node-api` to remove deprecated transitive install warnings from npm installs.

AGENTS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Agent Instructions
2+
3+
## Changelog
4+
5+
This repository uses Changesets to generate package changelogs.
6+
7+
- Add a changeset in `.changeset/` for every user-facing change, package dependency change, CLI behavior change, or release-worthy bug fix.
8+
- Use `patch` for fixes and dependency maintenance, `minor` for new features, and `major` for breaking changes.
9+
- Keep changeset summaries concise and written for AgentPond users.
10+
- Do not manually edit generated changelog output unless the release process has already run `pnpm changeset version`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img src="docs/assets/agentpond-logo-gpt-image.png" alt="AgentPond - trace analytics for AI agents" width="720">
2+
<img src="https://raw.githubusercontent.com/marcusschiesser/agentpond/main/docs/assets/agentpond-logo-gpt-image.png" alt="AgentPond - trace analytics for AI agents" width="720">
33
</p>
44

55
AgentPond is a data pond for AI agent traces with a agent-native CLI for local analytics. It accepts Langfuse SDK ingestion and its using the same data format, so you can use it as a drop-in replacement.

apps/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"@aws-sdk/client-s3": "^3.936.0",
27-
"duckdb": "^1.4.2",
27+
"@duckdb/node-api": "^1.5.4-r.1",
2828
"protobufjs": "^7.6.4",
2929
"zod": "^4.3.6"
3030
}

apps/cli/tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export default defineConfig({
1010
sourcemap: true,
1111
splitting: false,
1212
noExternal: [/^@agentpond\//],
13-
external: ["duckdb"],
13+
external: ["@duckdb/node-api", "@duckdb/node-bindings"],
1414
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
},
2525
"dependencies": {
2626
"@aws-sdk/client-s3": "^3.936.0",
27+
"@duckdb/node-api": "^1.5.4-r.1",
2728
"@opentelemetry/otlp-transformer": "^0.208.0",
28-
"duckdb": "^1.4.2",
2929
"fastify": "^5.6.2",
3030
"protobufjs": "^7.6.4",
3131
"zod": "^4.3.6"

packages/duckdb/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
".": "./src/index.ts"
88
},
99
"dependencies": {
10-
"@agentpond/core": "workspace:*"
10+
"@agentpond/core": "workspace:*",
11+
"@duckdb/node-api": "^1.5.4-r.1"
1112
}
1213
}

packages/duckdb/src/cache.ts

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@ import {
77
type ObjectStore,
88
otelResourceSpansToEvents,
99
} from "@agentpond/core";
10-
import duckdb from "duckdb";
11-
12-
type DuckConnection = {
13-
run(sql: string, callback: (err: Error | null) => void): void;
14-
all<T = Record<string, unknown>>(
15-
sql: string,
16-
callback: (err: Error | null, rows: T[]) => void,
17-
): void;
18-
close(callback: (err: Error | null) => void): void;
19-
};
10+
import { type DuckDBConnection, DuckDBInstance } from "@duckdb/node-api";
2011

2112
export type SyncResult = {
2213
manifestsProcessed: number;
@@ -25,12 +16,11 @@ export type SyncResult = {
2516
};
2617

2718
export class AgentPondDuckDb {
28-
private readonly db: duckdb.Database;
29-
private connection?: DuckConnection;
19+
private instance?: DuckDBInstance;
20+
private connection?: DuckDBConnection;
3021

3122
constructor(readonly dbPath: string) {
3223
mkdirSync(dirname(dbPath), { recursive: true });
33-
this.db = new duckdb.Database(dbPath);
3424
}
3525

3626
async init(): Promise<void> {
@@ -182,17 +172,13 @@ export class AgentPondDuckDb {
182172
if (this.connection) {
183173
const connection = this.connection;
184174
this.connection = undefined;
185-
await new Promise<void>((resolve, reject) => {
186-
connection.close((err) =>
187-
err && !isAlreadyClosedConnectionError(err) ? reject(err) : resolve(),
188-
);
189-
});
175+
connection.closeSync();
176+
}
177+
if (this.instance) {
178+
const instance = this.instance;
179+
this.instance = undefined;
180+
instance.closeSync();
190181
}
191-
await new Promise<void>((resolve, reject) => {
192-
this.db.close((err) =>
193-
err && !isAlreadyClosedConnectionError(err) ? reject(err) : resolve(),
194-
);
195-
});
196182
}
197183

198184
private async projectEvent(
@@ -373,28 +359,23 @@ export class AgentPondDuckDb {
373359
);
374360
}
375361

376-
private getConnection(): DuckConnection {
377-
if (!this.connection)
378-
this.connection = this.db.connect() as unknown as DuckConnection;
362+
private async getConnection(): Promise<DuckDBConnection> {
363+
if (!this.connection) {
364+
this.instance = await DuckDBInstance.create(this.dbPath);
365+
this.connection = await this.instance.connect();
366+
}
379367
return this.connection;
380368
}
381369

382370
private async exec(sqlText: string): Promise<void> {
383-
await new Promise<void>((resolve, reject) => {
384-
this.getConnection().run(sqlText, (err) =>
385-
err ? reject(err) : resolve(),
386-
);
387-
});
371+
await (await this.getConnection()).run(sqlText);
388372
}
389373

390374
private async all<T = Record<string, unknown>>(
391375
sqlText: string,
392376
): Promise<T[]> {
393-
return new Promise<T[]>((resolve, reject) => {
394-
this.getConnection().all<T>(sqlText, (err, rows) =>
395-
err ? reject(err) : resolve(rows),
396-
);
397-
});
377+
const reader = await (await this.getConnection()).runAndReadAll(sqlText);
378+
return reader.getRowObjectsJS() as T[];
398379
}
399380
}
400381

@@ -474,12 +455,6 @@ function isScoreSource(
474455
return value === "API" || value === "EVAL" || value === "ANNOTATION";
475456
}
476457

477-
function isAlreadyClosedConnectionError(error: Error): boolean {
478-
return error.message.includes(
479-
"Connection was never established or has been closed already",
480-
);
481-
}
482-
483458
function scoreValue(
484459
value: unknown,
485460
declaredDataType: string | undefined,

0 commit comments

Comments
 (0)