@hivemagnus/ardent 3.1.1 → 3.1.3
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 +1 -1
- package/dist/artifacts.js +3 -2
- package/dist/llamacpp.js +3 -0
- package/dist/mattermost.d.ts +5 -0
- package/dist/mattermost.js +12 -4
- package/dist/telegram.js +5 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ isolated provider acceptance, and verifies an actual old-runtime rollback.
|
|
|
45
45
|
|
|
46
46
|
## Install
|
|
47
47
|
|
|
48
|
-
Ardent needs Node.js 24.22.
|
|
48
|
+
Ardent needs Node.js 24.22.3+ or 26.13.1+. Its pinned `@photostructure/sqlite`
|
|
49
49
|
driver bundles SQLite 3.54.1 and stable Node-API binaries for supported x64/arm64
|
|
50
50
|
platforms. Existing profile databases keep their format and journal history.
|
|
51
51
|
Node.js 26 is recommended for its patched built-in libraries.
|
package/dist/artifacts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
2
|
import { constants } from 'node:fs';
|
|
3
3
|
import { mkdir, open, rename, unlink, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
@@ -27,7 +27,8 @@ export class ArtifactStore {
|
|
|
27
27
|
throw new Error(`Artifact exceeds ${formatBytes(this.maxBytes)}`);
|
|
28
28
|
const digest = createHash('sha256').update(bytes).digest('hex');
|
|
29
29
|
await mkdir(this.directory, { recursive: true, mode: 0o700 });
|
|
30
|
-
|
|
30
|
+
// Unique per call: two tasks may store identical bytes at the same instant.
|
|
31
|
+
const temporary = join(this.directory, `.${digest}.${randomUUID()}.tmp`);
|
|
31
32
|
await writeFile(temporary, bytes, { mode: 0o600, flag: 'wx' });
|
|
32
33
|
await rename(temporary, join(this.directory, digest));
|
|
33
34
|
return { id: digest, sha256: digest, bytes: bytes.length, media_type: mediaType, name };
|
package/dist/llamacpp.js
CHANGED
|
@@ -39,6 +39,9 @@ export async function* sseData(stream) {
|
|
|
39
39
|
throw new Error('Incomplete SSE event');
|
|
40
40
|
}
|
|
41
41
|
finally {
|
|
42
|
+
// A consumer that stops early (a malformed event, [DONE]) must end the
|
|
43
|
+
// response, or the server keeps generating into an unread stream.
|
|
44
|
+
await reader.cancel().catch(() => { });
|
|
42
45
|
reader.releaseLock();
|
|
43
46
|
}
|
|
44
47
|
}
|
package/dist/mattermost.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ArdentRuntime } from './runtime.js';
|
|
2
2
|
import type { JobEngine } from './job-engine.js';
|
|
3
3
|
type MattermostConfig = ArdentRuntime['config']['channels']['mattermost'];
|
|
4
|
+
/**
|
|
5
|
+
* Matches `@username` as a whole mention. Trailing punctuation ("@bot:", "@bot.")
|
|
6
|
+
* still mentions the bot, while a longer name ("@bot.helper", "@bot-two") does not.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mentionPattern(username: string): RegExp;
|
|
4
9
|
export declare class MattermostAdapter {
|
|
5
10
|
#private;
|
|
6
11
|
readonly runtime: ArdentRuntime;
|
package/dist/mattermost.js
CHANGED
|
@@ -28,9 +28,15 @@ function splitMessage(text) {
|
|
|
28
28
|
}
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
/** The longest message text a channel event carries; longer posts are cut, as the task prompt is. */
|
|
32
|
+
const MAX_EVENT_TEXT = 16_000;
|
|
33
|
+
/**
|
|
34
|
+
* Matches `@username` as a whole mention. Trailing punctuation ("@bot:", "@bot.")
|
|
35
|
+
* still mentions the bot, while a longer name ("@bot.helper", "@bot-two") does not.
|
|
36
|
+
*/
|
|
37
|
+
export function mentionPattern(username) {
|
|
32
38
|
const escaped = username.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
33
|
-
return new RegExp(`(
|
|
39
|
+
return new RegExp(`(^|[^A-Za-z0-9_.@-])@${escaped}(?![A-Za-z0-9_-]|\\.[A-Za-z0-9_-])`, 'i');
|
|
34
40
|
}
|
|
35
41
|
export class MattermostAdapter {
|
|
36
42
|
runtime;
|
|
@@ -118,7 +124,9 @@ export class MattermostAdapter {
|
|
|
118
124
|
return;
|
|
119
125
|
const cursorKey = `mattermost:${me.id}:${post.channel_id}:last_ms`;
|
|
120
126
|
const previous = Number(this.runtime.store.cursor(cursorKey) ?? '0');
|
|
121
|
-
|
|
127
|
+
// A post may be longer than one channel event. Cut it here: a rejected event
|
|
128
|
+
// would fail every later reconciliation that still lists the post.
|
|
129
|
+
const text = (isDm ? post.message : post.message.replace(mentionPattern(me.username), '$1').trim()).slice(0, MAX_EVENT_TEXT);
|
|
122
130
|
const event = { platform: 'mattermost', channel_type: isDm ? 'mattermost_dm' : 'mattermost_channel',
|
|
123
131
|
account: me.id, user: post.user_id, conversation: post.channel_id, thread: post.root_id || null, update_id: post.id, reply_to: post.id, text, attachments, authorized: true, bot_message: false };
|
|
124
132
|
const operation = this.#core.handle(event, async (reply) => this.#deliver(post, channelType, reply)).catch(error => {
|
|
@@ -229,7 +237,7 @@ export class MattermostAdapter {
|
|
|
229
237
|
};
|
|
230
238
|
socket.on('message', onMessage);
|
|
231
239
|
socket.once('close', () => { clearTimeout(timer); reject(new Error('Mattermost WebSocket closed before authentication')); });
|
|
232
|
-
});
|
|
240
|
+
}).catch((error) => { socket.terminate(); throw error; }); // A refused socket must not stay open.
|
|
233
241
|
const polling = new AbortController();
|
|
234
242
|
socket.on('message', data => {
|
|
235
243
|
try {
|
package/dist/telegram.js
CHANGED
|
@@ -218,8 +218,11 @@ export class TelegramAdapter {
|
|
|
218
218
|
const doc = message.document;
|
|
219
219
|
const attachment = { name: doc.file_name.slice(0, 128), media_type: doc.mime_type.slice(0, 100), external_id: doc.file_id.slice(0, 256) };
|
|
220
220
|
if ((doc.file_size ?? Number.POSITIVE_INFINITY) <= 2 * 1024 * 1024 && ['text/plain', 'text/markdown', 'application/json'].includes(doc.mime_type)) {
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
// A refused file (expired or unavailable) stays metadata only. Failing the
|
|
222
|
+
// update instead would refetch it on every poll and stop all later intake.
|
|
223
|
+
const file = await this.#call('getFile', { file_id: doc.file_id }, signal).then(value => z.object({ file_path: z.string() }).passthrough().parse(value), (error) => { if (error instanceof DeliveryRejectedError)
|
|
224
|
+
return undefined; throw error; });
|
|
225
|
+
if (file && /^[A-Za-z0-9_./-]{1,512}$/.test(file.file_path) && !file.file_path.split('/').includes('..')) {
|
|
223
226
|
const response = await fetch(`${this.#base}/file/bot${this.#token}/${file.file_path}`, { ...(signal ? { signal } : {}), redirect: 'error' });
|
|
224
227
|
if (response.ok) {
|
|
225
228
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hivemagnus/ardent",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Headless TypeScript agent runtime with A2A, scheduled jobs, skills, chat channels, and a plugin API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": "^24.22.
|
|
42
|
+
"node": "^24.22.3 || ^26.13.1"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@hono/node-server": "^2.1.5",
|
|
83
83
|
"dotenv": "^18.0.9",
|
|
84
84
|
"express": "5.3.0",
|
|
85
|
-
"hono": "^4.13.
|
|
85
|
+
"hono": "^4.13.18",
|
|
86
86
|
"marked": "18.1.1",
|
|
87
87
|
"parse5": "8.1.1",
|
|
88
88
|
"pdfmake": "0.3.13",
|