@hivemagnus/ardent 2.3.0 → 3.0.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/README.md CHANGED
@@ -45,8 +45,14 @@ isolated provider acceptance, and verifies an actual old-runtime rollback.
45
45
 
46
46
  ## Install
47
47
 
48
- Ardent needs Node.js 24.22.1+ or 26.13.0+ (`better-sqlite3` is a native
49
- dependency).
48
+ Ardent needs Node.js 24.22.1+ or 26.13.0+. Its pinned `@photostructure/sqlite`
49
+ driver bundles SQLite 3.54.1 and stable Node-API binaries for supported x64/arm64
50
+ platforms. Existing profile databases keep their format and journal history.
51
+ Node.js 26 is recommended for its patched built-in libraries.
52
+
53
+ Version 3 replaces the low-level `TaskStore.db` driver surface with the application's
54
+ storage boundary. Code that used better-sqlite3-specific methods must migrate;
55
+ the management API, CLI and plugin hooks retain their existing contracts.
50
56
 
51
57
  ```bash
52
58
  npm i -g @hivemagnus/ardent
@@ -486,3 +492,19 @@ See [AGENTS.md](AGENTS.md) for contributor guidance.
486
492
 
487
493
  Apache-2.0. The vendored A2A protocol definition in `protocol/` carries its own
488
494
  license, [`protocol/LICENSE-A2A.txt`](protocol/LICENSE-A2A.txt).
495
+
496
+ ### Interoperability checks
497
+
498
+ Run `npm run interop` from this standalone checkout. The runner installs pinned
499
+ Python A2A SDKs and checks out an exact public Hermes revision in an ignored
500
+ cache; Python is used only for these tests. Both supported Node versions run
501
+ this suite in CI.
502
+
503
+ The suite exercises the real Python SDK and Hermes wire adapter in both
504
+ client/server directions. Team missions, lifecycle and child-budget transactions
505
+ use independent Python reference peers in `test/fixtures/team_reference.py`.
506
+ They implement the published Ardent wire contract; they do not load an external
507
+ Hermes team plugin or require a sibling Magnus checkout. The compatibility probe
508
+ explicitly enables `hermes_compat` and allows its combined functional workload
509
+ through the fixture's rate buckets. Default throttling remains covered by the
510
+ separate rate-limit tests.
@@ -1,15 +1,15 @@
1
1
  import { Message, type SendMessageRequest, type StreamResponse, type Task } from '@a2a-js/sdk';
2
2
  import { DefaultRequestHandler, type ServerCallContext } from '@a2a-js/sdk/server';
3
- import type Database from 'better-sqlite3';
3
+ import type Database from './sqlite.js';
4
4
  import type { PeerTaskGate } from './a2a-rate-limit.js';
5
5
  import type { SqliteA2ATaskStore } from './a2a-store.js';
6
6
  /** Binds transport retries to the original task before invoking the executor. */
7
7
  export declare class IdempotentA2AHandler extends DefaultRequestHandler {
8
8
  #private;
9
- readonly db: Database.Database;
9
+ readonly db: Database;
10
10
  readonly durableStore: SqliteA2ATaskStore;
11
11
  readonly taskGate: PeerTaskGate;
12
- constructor(db: Database.Database, durableStore: SqliteA2ATaskStore, taskGate: PeerTaskGate, ...args: ConstructorParameters<typeof DefaultRequestHandler>);
12
+ constructor(db: Database, durableStore: SqliteA2ATaskStore, taskGate: PeerTaskGate, ...args: ConstructorParameters<typeof DefaultRequestHandler>);
13
13
  sendMessage(params: SendMessageRequest, context: ServerCallContext): Promise<Task | Message>;
14
14
  sendMessageStream(params: SendMessageRequest, context: ServerCallContext): AsyncGenerator<StreamResponse, void, undefined>;
15
15
  }
@@ -1,4 +1,4 @@
1
- import type Database from 'better-sqlite3';
1
+ import type Database from './sqlite.js';
2
2
  import { type StreamResponse } from '@a2a-js/sdk';
3
3
  import { z } from 'zod';
4
4
  import type { PeerConfig } from './a2a-peers.js';
@@ -8,10 +8,10 @@ declare const Outbound: z.ZodObject<{
8
8
  task_id: z.ZodNullable<z.ZodString>;
9
9
  }, z.core.$strip>;
10
10
  export declare class A2APushInbox {
11
- readonly db: Database.Database;
11
+ readonly db: Database;
12
12
  readonly peers: PeerConfig[];
13
13
  readonly publicUrl: string;
14
- constructor(db: Database.Database, peers: PeerConfig[], publicUrl: string);
14
+ constructor(db: Database, peers: PeerConfig[], publicUrl: string);
15
15
  register(peerId: string, messageId: string): {
16
16
  id: string;
17
17
  token: string;
@@ -1,11 +1,11 @@
1
- import type Database from 'better-sqlite3';
1
+ import type Database from './sqlite.js';
2
2
  import { type StreamResponse, type Task, type TaskPushNotificationConfig } from '@a2a-js/sdk';
3
3
  import type { PushNotificationSender, PushNotificationStore, ServerCallContext, StoredPushNotificationConfig } from '@a2a-js/sdk/server';
4
4
  import type { PeerConfig } from './a2a-peers.js';
5
5
  export declare class SqliteA2APushStore implements PushNotificationStore {
6
- readonly db: Database.Database;
6
+ readonly db: Database;
7
7
  readonly peers: PeerConfig[];
8
- constructor(db: Database.Database, peers: PeerConfig[]);
8
+ constructor(db: Database, peers: PeerConfig[]);
9
9
  save(taskId: string, context: ServerCallContext, config: TaskPushNotificationConfig): Promise<void>;
10
10
  load(taskId: string, context: ServerCallContext): Promise<TaskPushNotificationConfig[]>;
11
11
  loadWithMetadata(taskId: string, context: ServerCallContext): Promise<StoredPushNotificationConfig[]>;
@@ -1,9 +1,9 @@
1
1
  import { type ListTasksRequest, type ListTasksResponse, type Task } from '@a2a-js/sdk';
2
2
  import type { ServerCallContext, TaskStore as A2ATaskStore } from '@a2a-js/sdk/server';
3
- import type Database from 'better-sqlite3';
3
+ import type Database from './sqlite.js';
4
4
  export declare class SqliteA2ATaskStore implements A2ATaskStore {
5
- readonly db: Database.Database;
6
- constructor(db: Database.Database);
5
+ readonly db: Database;
6
+ constructor(db: Database);
7
7
  save(task: Task, context: ServerCallContext): Promise<void>;
8
8
  load(taskId: string, context: ServerCallContext): Promise<Task | undefined>;
9
9
  list(params: ListTasksRequest, context: ServerCallContext): Promise<ListTasksResponse>;
package/dist/cli.js CHANGED
@@ -20,7 +20,7 @@ import { CodexAppServer, assertCodexProtocol, compactWithCodex } from './codex.j
20
20
  import { LlamaCppBackend } from './llamacpp.js';
21
21
  import { toJsonSchema } from './json-schema.js';
22
22
  import { hermesTeamCard } from './hermes-compat.js';
23
- import Database from 'better-sqlite3';
23
+ import Database from './sqlite.js';
24
24
  import { JobEngine, validateJobDefinitions } from './job-engine.js';
25
25
  import { composeOwnershipChecks } from './job-ownership.js';
26
26
  import { BUILTIN_JOB_VALIDATION_REGISTRY, builtinJobHandlers } from './job-news-handlers.js';
@@ -1,4 +1,4 @@
1
- import Database from 'better-sqlite3';
1
+ import { Database } from './sqlite.js';
2
2
  import { z } from 'zod';
3
3
  import { type CompactionCall } from './context-checkpoints.js';
4
4
  import { TaskStore } from './store.js';
@@ -13,9 +13,9 @@ declare const snapshotSchema: z.ZodObject<{
13
13
  }, z.core.$strict>>;
14
14
  }, z.core.$strict>;
15
15
  export type ContextSnapshot = z.infer<typeof snapshotSchema>;
16
- export declare function snapshotContext(database: Database.Database): ContextSnapshot;
17
- export declare function verifyContextSnapshot(database: Database.Database, input: unknown): void;
18
- export declare function assertContextIdle(database: Database.Database): void;
16
+ export declare function snapshotContext(database: Database): ContextSnapshot;
17
+ export declare function verifyContextSnapshot(database: Database, input: unknown): void;
18
+ export declare function assertContextIdle(database: Database): void;
19
19
  export declare function exerciseContext(store: TaskStore, summarize: CompactionCall, loaded: NonNullable<Awaited<ReturnType<typeof loadModelPolicy>>>, previousModule: string, continueContext: (messages: unknown) => Promise<string>): Promise<Record<string, unknown>>;
20
20
  export declare function contextMaintenance(input: unknown): Promise<Record<string, unknown>>;
21
21
  export {};
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
2
2
  import { lstat, mkdir, open, readFile, writeFile } from 'node:fs/promises';
3
3
  import { dirname, join, resolve } from 'node:path';
4
4
  import { pathToFileURL } from 'node:url';
5
- import Database from 'better-sqlite3';
5
+ import { Database } from './sqlite.js';
6
6
  import { parse } from 'dotenv';
7
7
  import { z } from 'zod';
8
8
  import { ContextCheckpoints } from './context-checkpoints.js';
@@ -1,4 +1,4 @@
1
- import type Database from 'better-sqlite3';
1
+ import type Database from './sqlite.js';
2
2
  import { z } from 'zod';
3
3
  declare const definition: z.ZodObject<{
4
4
  id: z.ZodString;
@@ -175,14 +175,14 @@ export declare function validateJobDefinitions(raw: unknown, registry: JobRegist
175
175
  /** A profile-local SQLite scheduler. No work is admitted without a fresh ownership check. */
176
176
  export declare class JobEngine {
177
177
  #private;
178
- readonly db: Database.Database;
178
+ readonly db: Database;
179
179
  readonly profileDir: string;
180
180
  readonly profile: string;
181
181
  readonly registry: JobRegistry;
182
182
  readonly ownershipCheck: OwnershipCheck;
183
183
  readonly clock: () => number;
184
184
  /** `clock` measures elapsed time within a tick; the injected tick time stays the timeline origin. */
185
- constructor(db: Database.Database, profileDir: string, profile: string, registry: JobRegistry, ownershipCheck: OwnershipCheck, clock?: () => number);
185
+ constructor(db: Database, profileDir: string, profile: string, registry: JobRegistry, ownershipCheck: OwnershipCheck, clock?: () => number);
186
186
  load(): Promise<{
187
187
  definitions: JobDefinitions;
188
188
  sha256: string;
package/dist/news.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { lookup } from 'node:dns/promises';
3
3
  import { BlockList, isIP } from 'node:net';
4
+ import { parse } from 'parse5';
4
5
  import { z } from 'zod';
5
6
  import { resolveReference } from './config.js';
6
7
  import { ArtifactSchema } from './artifacts.js';
@@ -173,14 +174,29 @@ export function newsStructuredPublicationTime(html, sourceUrl) {
173
174
  dates.add(new Date(published).toISOString());
174
175
  date ??= published;
175
176
  };
176
- const scripts = /<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi;
177
- for (let count = 0, match; count < 32 && (match = scripts.exec(html)); count++) {
178
- if (!/\btype\s*=\s*["']application\/ld\+json["']/i.test(match[1]) || Buffer.byteLength(match[2]) > 65_536)
179
- continue;
180
- try {
181
- visit(JSON.parse(match[2]), 0);
177
+ // Parse actual HTML elements: comments, raw text and lookalike attributes
178
+ // must not become publisher evidence. Walk iteratively to bound call depth.
179
+ const pending = [parse(html, { sourceCodeLocationInfo: true })];
180
+ let scripts = 0;
181
+ while (pending.length && scripts < 32) {
182
+ const node = pending.pop();
183
+ if ('tagName' in node && node.tagName === 'script') {
184
+ scripts++;
185
+ if (node.namespaceURI !== 'http://www.w3.org/1999/xhtml' || !node.sourceCodeLocation?.endTag ||
186
+ node.attrs.find(attr => attr.name === 'type')?.value.toLowerCase() !== 'application/ld+json')
187
+ continue;
188
+ const text = node.childNodes.map(child => 'value' in child ? child.value : '').join('');
189
+ if (Buffer.byteLength(text) > 65_536)
190
+ continue;
191
+ try {
192
+ visit(JSON.parse(text), 0);
193
+ }
194
+ catch { /* Malformed publisher data remains unknown. */ }
195
+ }
196
+ else if ('childNodes' in node) {
197
+ for (let index = node.childNodes.length - 1; index >= 0; index--)
198
+ pending.push(node.childNodes[index]);
182
199
  }
183
- catch { /* Malformed publisher data remains unknown. */ }
184
200
  }
185
201
  return nodes <= 64 && dates.size === 1 ? date : null;
186
202
  }
@@ -0,0 +1,31 @@
1
+ import { StatementSync } from '@photostructure/sqlite';
2
+ type Options = {
3
+ readonly?: boolean;
4
+ fileMustExist?: boolean;
5
+ timeout?: number;
6
+ };
7
+ export declare function assertPatchedSqliteVersion(version: unknown): void;
8
+ /** Application storage boundary. Keep transaction ownership on the same connection. */
9
+ declare class Statement {
10
+ private readonly statement;
11
+ constructor(statement: StatementSync);
12
+ run(...parameters: unknown[]): ReturnType<StatementSync['run']>;
13
+ get(...parameters: unknown[]): unknown;
14
+ all(...parameters: unknown[]): unknown[];
15
+ iterate(...parameters: unknown[]): IterableIterator<unknown>;
16
+ }
17
+ export declare class Database {
18
+ #private;
19
+ constructor(path: string, options?: Options);
20
+ get inTransaction(): boolean;
21
+ get open(): boolean;
22
+ prepare(sql: string): Statement;
23
+ exec(sql: string): this;
24
+ pragma(sql: string, options?: {
25
+ simple?: boolean;
26
+ }): unknown;
27
+ transaction<F extends (...args: never[]) => unknown>(fn: F): import("@photostructure/sqlite").TransactionFunction<F>;
28
+ backup(destination: string): Promise<void>;
29
+ close(): void;
30
+ }
31
+ export default Database;
package/dist/sqlite.js ADDED
@@ -0,0 +1,73 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ // The native module bundles patched SQLite independently of the host Node version.
3
+ import { DatabaseSync, backup, enhance } from '@photostructure/sqlite';
4
+ function sqliteOperation(action) {
5
+ try {
6
+ return action();
7
+ }
8
+ catch (error) {
9
+ if (error instanceof Error && 'sqliteCodeName' in error && typeof error.sqliteCodeName === 'string') {
10
+ // Preserve native numeric details while keeping existing busy/locked retry behavior.
11
+ Object.assign(error, { code: error.sqliteCodeName });
12
+ }
13
+ throw error;
14
+ }
15
+ }
16
+ export function assertPatchedSqliteVersion(version) {
17
+ const match = typeof version === 'string' ? /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.exec(version) : null;
18
+ if (!match)
19
+ throw new Error('Cannot verify embedded SQLite version');
20
+ const [major, minor, patch] = match.slice(1).map(Number);
21
+ if (major === undefined || minor === undefined || patch === undefined ||
22
+ !(major > 3 || (major === 3 && (minor > 54 || (minor === 54 && patch >= 1))))) {
23
+ throw new Error('Embedded SQLite 3.54.1 or later is required');
24
+ }
25
+ }
26
+ /** Application storage boundary. Keep transaction ownership on the same connection. */
27
+ class Statement {
28
+ statement;
29
+ constructor(statement) {
30
+ this.statement = statement;
31
+ }
32
+ run(...parameters) { return sqliteOperation(() => this.statement.run(...parameters)); }
33
+ get(...parameters) { return sqliteOperation(() => this.statement.get(...parameters)); }
34
+ all(...parameters) { return sqliteOperation(() => this.statement.all(...parameters)); }
35
+ iterate(...parameters) { return this.statement.iterate(...parameters); }
36
+ }
37
+ export class Database {
38
+ #database;
39
+ constructor(path, options = {}) {
40
+ let location = path;
41
+ if (options.fileMustExist) {
42
+ if (path === ':memory:')
43
+ throw new Error('An existing on-disk database is required');
44
+ const uri = pathToFileURL(path);
45
+ uri.searchParams.set('mode', options.readonly ? 'ro' : 'rw');
46
+ location = uri;
47
+ }
48
+ this.#database = enhance(new DatabaseSync(location, {
49
+ readOnly: options.readonly ?? false,
50
+ timeout: options.timeout ?? 5000,
51
+ }));
52
+ try {
53
+ const row = this.#database.prepare('SELECT sqlite_version() AS version').get();
54
+ assertPatchedSqliteVersion(row !== null && typeof row === 'object' && 'version' in row ? row.version : undefined);
55
+ }
56
+ catch (error) {
57
+ this.#database.close();
58
+ throw error;
59
+ }
60
+ }
61
+ get inTransaction() { return this.#database.isTransaction; }
62
+ get open() { return this.#database.isOpen; }
63
+ prepare(sql) { return new Statement(sqliteOperation(() => this.#database.prepare(sql))); }
64
+ exec(sql) { sqliteOperation(() => this.#database.exec(sql)); return this; }
65
+ pragma(sql, options) { return sqliteOperation(() => this.#database.pragma(sql, options)); }
66
+ transaction(fn) {
67
+ return this.#database.transaction(fn);
68
+ }
69
+ async backup(destination) { await backup(this.#database, destination); }
70
+ close() { if (this.#database.isOpen)
71
+ this.#database.close(); }
72
+ }
73
+ export default Database;
package/dist/store.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import Database from 'better-sqlite3';
1
+ import Database from './sqlite.js';
2
2
  import { z } from 'zod';
3
3
  export declare const TaskState: z.ZodEnum<{
4
4
  unknown: "unknown";
@@ -91,7 +91,7 @@ export declare const EventSchema: z.ZodObject<{
91
91
  }, z.core.$strip>;
92
92
  export type TaskEvent = z.infer<typeof EventSchema>;
93
93
  export declare class TaskStore {
94
- readonly db: Database.Database;
94
+ readonly db: Database;
95
95
  constructor(path: string);
96
96
  close(): void;
97
97
  admissionFence(): {
package/dist/store.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
2
2
  import { mkdirSync } from 'node:fs';
3
3
  import { dirname } from 'node:path';
4
- import Database from 'better-sqlite3';
4
+ import Database from './sqlite.js';
5
5
  import { z } from 'zod';
6
6
  export const TaskState = z.enum(['queued', 'running', 'input_required', 'completed', 'partial', 'failed', 'cancelled', 'unknown']);
7
7
  /** Execution scope of a task. It selects tools and memory; a session belongs to exactly one context. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hivemagnus/ardent",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "Headless TypeScript agent runtime with A2A, scheduled jobs, skills, chat channels, and a plugin API",
5
5
  "keywords": [
6
6
  "agent",
@@ -73,22 +73,22 @@
73
73
  "@a2a-js/sdk": "1.3.0",
74
74
  "@bufbuild/protobuf": "2.16.0",
75
75
  "@grpc/grpc-js": "1.14.7",
76
- "@hivemagnus/canvas-word-codec": "1.0.0",
76
+ "@hivemagnus/canvas-word-codec": "1.1.0",
77
77
  "@hivemagnus/emberfold": "0.1.0",
78
78
  "@hono/node-server": "^2.1.5",
79
- "better-sqlite3": "^13.0.3",
80
79
  "dotenv": "^18.0.9",
81
80
  "express": "5.3.0",
82
81
  "hono": "^4.13.16",
83
82
  "marked": "18.1.1",
83
+ "parse5": "8.1.1",
84
84
  "pdfmake": "0.3.13",
85
85
  "ws": "^8.22.0",
86
86
  "yaml": "2.9.1",
87
- "zod": "^4.6.7"
87
+ "zod": "^4.6.7",
88
+ "@photostructure/sqlite": "3.3.1"
88
89
  },
89
90
  "devDependencies": {
90
91
  "@apidevtools/swagger-parser": "^13.1.0",
91
- "@types/better-sqlite3": "^9.6.0",
92
92
  "@types/express": "5.0.6",
93
93
  "@types/node": "^24.19.2",
94
94
  "@types/pdfmake": "0.3.3",
@@ -110,8 +110,8 @@
110
110
  }
111
111
  },
112
112
  "allowScripts": {
113
- "better-sqlite3@13.0.3": true,
114
113
  "esbuild@0.28.2": true,
115
- "protobufjs@7.6.6": true
114
+ "protobufjs@7.6.6": true,
115
+ "@photostructure/sqlite@3.3.1": true
116
116
  }
117
117
  }