@hivemagnus/ardent 2.3.1 → 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 +8 -2
- package/dist/a2a-idempotency.d.ts +3 -3
- package/dist/a2a-push-inbox.d.ts +3 -3
- package/dist/a2a-push.d.ts +3 -3
- package/dist/a2a-store.d.ts +3 -3
- package/dist/cli.js +1 -1
- package/dist/context-maintenance.d.ts +4 -4
- package/dist/context-maintenance.js +1 -1
- package/dist/job-engine.d.ts +3 -3
- package/dist/sqlite.d.ts +31 -0
- package/dist/sqlite.js +73 -0
- package/dist/store.d.ts +2 -2
- package/dist/store.js +1 -1
- package/package.json +5 -6
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
|
|
49
|
-
|
|
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
|
|
@@ -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 '
|
|
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
|
|
9
|
+
readonly db: Database;
|
|
10
10
|
readonly durableStore: SqliteA2ATaskStore;
|
|
11
11
|
readonly taskGate: PeerTaskGate;
|
|
12
|
-
constructor(db: Database
|
|
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
|
}
|
package/dist/a2a-push-inbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Database from '
|
|
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
|
|
11
|
+
readonly db: Database;
|
|
12
12
|
readonly peers: PeerConfig[];
|
|
13
13
|
readonly publicUrl: string;
|
|
14
|
-
constructor(db: Database
|
|
14
|
+
constructor(db: Database, peers: PeerConfig[], publicUrl: string);
|
|
15
15
|
register(peerId: string, messageId: string): {
|
|
16
16
|
id: string;
|
|
17
17
|
token: string;
|
package/dist/a2a-push.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type Database from '
|
|
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
|
|
6
|
+
readonly db: Database;
|
|
7
7
|
readonly peers: PeerConfig[];
|
|
8
|
-
constructor(db: Database
|
|
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[]>;
|
package/dist/a2a-store.d.ts
CHANGED
|
@@ -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 '
|
|
3
|
+
import type Database from './sqlite.js';
|
|
4
4
|
export declare class SqliteA2ATaskStore implements A2ATaskStore {
|
|
5
|
-
readonly db: Database
|
|
6
|
-
constructor(db: 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 '
|
|
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 '
|
|
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
|
|
17
|
-
export declare function verifyContextSnapshot(database: Database
|
|
18
|
-
export declare function assertContextIdle(database: Database
|
|
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 '
|
|
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';
|
package/dist/job-engine.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Database from '
|
|
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
|
|
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
|
|
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/sqlite.d.ts
ADDED
|
@@ -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 '
|
|
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
|
|
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 '
|
|
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": "
|
|
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",
|
|
@@ -76,7 +76,6 @@
|
|
|
76
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",
|
|
@@ -85,11 +84,11 @@
|
|
|
85
84
|
"pdfmake": "0.3.13",
|
|
86
85
|
"ws": "^8.22.0",
|
|
87
86
|
"yaml": "2.9.1",
|
|
88
|
-
"zod": "^4.6.7"
|
|
87
|
+
"zod": "^4.6.7",
|
|
88
|
+
"@photostructure/sqlite": "3.3.1"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@apidevtools/swagger-parser": "^13.1.0",
|
|
92
|
-
"@types/better-sqlite3": "^9.6.0",
|
|
93
92
|
"@types/express": "5.0.6",
|
|
94
93
|
"@types/node": "^24.19.2",
|
|
95
94
|
"@types/pdfmake": "0.3.3",
|
|
@@ -111,8 +110,8 @@
|
|
|
111
110
|
}
|
|
112
111
|
},
|
|
113
112
|
"allowScripts": {
|
|
114
|
-
"better-sqlite3@13.0.3": true,
|
|
115
113
|
"esbuild@0.28.2": true,
|
|
116
|
-
"protobufjs@7.6.6": true
|
|
114
|
+
"protobufjs@7.6.6": true,
|
|
115
|
+
"@photostructure/sqlite@3.3.1": true
|
|
117
116
|
}
|
|
118
117
|
}
|