@hivemagnus/ardent 3.1.2 → 3.1.4
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 +30 -13
- 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 +2 -2
package/README.md
CHANGED
|
@@ -81,6 +81,23 @@ ardent gateway run # management API, A2A, channels, jobs
|
|
|
81
81
|
|
|
82
82
|
`ardent help` lists every command.
|
|
83
83
|
|
|
84
|
+
### Under Magnus and in the Hive suite
|
|
85
|
+
|
|
86
|
+
Each [Magnus](https://github.com/ChefTaco/magnus) release is built and tested
|
|
87
|
+
against one pinned Ardent version: Magnus 3.1.1 pins Ardent 3.1.3. Every Ardent
|
|
88
|
+
release is followed by a Magnus release that moves the pin, regenerates its
|
|
89
|
+
Ardent contract and updates the node agent; until then, managed nodes keep the
|
|
90
|
+
pinned version.
|
|
91
|
+
|
|
92
|
+
Magnus installs that pinned package on a node and creates profiles with its
|
|
93
|
+
**New Agent** workflow, which always enables HiveMem. In a
|
|
94
|
+
[Hive](https://github.com/ChefTaco/hive) suite installation, run
|
|
95
|
+
`./hive.sh ardent setup` after enrolling the host agent: it creates an
|
|
96
|
+
`assistant` profile through Magnus and tests a real model response. See Hive's
|
|
97
|
+
[Create an Ardent assistant](https://github.com/ChefTaco/hive/blob/main/deployment/FULL.md#create-an-ardent-assistant)
|
|
98
|
+
and Magnus's [Ardent guide](https://github.com/ChefTaco/magnus/blob/main/docs/ARDENT.md).
|
|
99
|
+
Ardent Project Studio and the UI reach those profiles only through Magnus.
|
|
100
|
+
|
|
84
101
|
### Native suite artifact
|
|
85
102
|
|
|
86
103
|
Build this repository's `Dockerfile` from the repository root, then select that
|
|
@@ -514,6 +531,13 @@ share a bounded per-plugin rate bucket (600/minute, burst 120), applied before
|
|
|
514
531
|
handler authentication and parsing. Wildcard routes and middleware mounts are
|
|
515
532
|
refused so an extension cannot intercept unrelated core requests.
|
|
516
533
|
|
|
534
|
+
HTTP mounts may set `rateLimit: { perMinute, burst }` for their authentication
|
|
535
|
+
boundary. Defaults are 600 requests per minute and a burst of 120. Limits must be
|
|
536
|
+
positive integers no greater than 6000 and 1200 respectively. All mounts from one
|
|
537
|
+
plugin in the same boundary must agree; management and independent ingress retain
|
|
538
|
+
separate buckets. This capacity is trusted plugin policy and grants no authentication
|
|
539
|
+
or task authority. The one MiB body limit remains in force.
|
|
540
|
+
|
|
517
541
|
Offline job-validation contexts expose `runtimeAvailable: false`; their runtime
|
|
518
542
|
and tool registry getters throw. CLI extensions receive `rawArgs` for their own
|
|
519
543
|
option grammar, declare `valueOptions` to recognize values before the command, and can use `matches(invocation)` to select one subcommand while
|
|
@@ -557,13 +581,6 @@ npm run pack:check # packs, installs, and smoke-tests the tarball
|
|
|
557
581
|
npm run verify # every gate CI runs, in order
|
|
558
582
|
```
|
|
559
583
|
|
|
560
|
-
See [AGENTS.md](AGENTS.md) for contributor guidance.
|
|
561
|
-
|
|
562
|
-
## License
|
|
563
|
-
|
|
564
|
-
Apache-2.0. The vendored A2A protocol definition in `protocol/` carries its own
|
|
565
|
-
license, [`protocol/LICENSE-A2A.txt`](protocol/LICENSE-A2A.txt).
|
|
566
|
-
|
|
567
584
|
### Interoperability checks
|
|
568
585
|
|
|
569
586
|
Run `npm run interop` from this standalone checkout. The runner installs pinned
|
|
@@ -580,9 +597,9 @@ explicitly enables `hermes_compat` and allows its combined functional workload
|
|
|
580
597
|
through the fixture's rate buckets. Default throttling remains covered by the
|
|
581
598
|
separate rate-limit tests.
|
|
582
599
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
600
|
+
See [AGENTS.md](AGENTS.md) for contributor guidance.
|
|
601
|
+
|
|
602
|
+
## License
|
|
603
|
+
|
|
604
|
+
Apache-2.0. The vendored A2A protocol definition in `protocol/` carries its own
|
|
605
|
+
license, [`protocol/LICENSE-A2A.txt`](protocol/LICENSE-A2A.txt).
|
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.4",
|
|
4
4
|
"description": "Headless TypeScript agent runtime with A2A, scheduled jobs, skills, chat channels, and a plugin API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@grpc/grpc-js": "1.14.7",
|
|
80
80
|
"@hivemagnus/canvas-word-codec": "1.1.0",
|
|
81
81
|
"@hivemagnus/emberfold": "0.1.0",
|
|
82
|
-
"@hono/node-server": "^2.1.
|
|
82
|
+
"@hono/node-server": "^2.1.6",
|
|
83
83
|
"dotenv": "^18.0.9",
|
|
84
84
|
"express": "5.3.0",
|
|
85
85
|
"hono": "^4.13.18",
|