@hivemagnus/ardent 3.1.3 → 3.2.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 +504 -16
- package/dist/a2a-client.d.ts +26 -4
- package/dist/a2a-client.js +91 -23
- package/dist/a2a-push-inbox.d.ts +2 -0
- package/dist/a2a-push-inbox.js +7 -0
- package/dist/a2a-push.d.ts +1 -1
- package/dist/a2a-push.js +26 -18
- package/dist/a2a-server.d.ts +17 -0
- package/dist/a2a-server.js +91 -14
- package/dist/a2a.d.ts +19 -1
- package/dist/a2a.js +197 -27
- package/dist/api.d.ts +2 -0
- package/dist/api.js +160 -22
- package/dist/artifact-manifests.d.ts +344 -5
- package/dist/artifact-manifests.js +413 -20
- package/dist/artifact-transfer.d.ts +113 -0
- package/dist/artifact-transfer.js +517 -0
- package/dist/artifacts.d.ts +86 -0
- package/dist/artifacts.js +249 -1
- package/dist/backend-events.d.ts +2 -1
- package/dist/backend-events.js +1 -1
- package/dist/channel-catchup.d.ts +67 -0
- package/dist/channel-catchup.js +108 -0
- package/dist/channels.d.ts +35 -0
- package/dist/channels.js +152 -4
- package/dist/cli.js +28 -3
- package/dist/codex-protocol.d.ts +22 -0
- package/dist/codex-protocol.js +19 -0
- package/dist/codex.d.ts +32 -3
- package/dist/codex.js +91 -17
- package/dist/config.d.ts +25 -2
- package/dist/config.js +41 -4
- package/dist/development.d.ts +6 -6
- package/dist/execution-state.d.ts +245 -0
- package/dist/execution-state.js +236 -0
- package/dist/execution.d.ts +135 -0
- package/dist/execution.js +178 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +5 -3
- package/dist/job-engine.d.ts +2 -1
- package/dist/job-engine.js +33 -4
- package/dist/lineage.d.ts +106 -0
- package/dist/lineage.js +145 -0
- package/dist/llamacpp.d.ts +32 -2
- package/dist/llamacpp.js +69 -33
- package/dist/mattermost.d.ts +8 -0
- package/dist/mattermost.js +250 -36
- package/dist/mission-tools.js +41 -5
- package/dist/missions.d.ts +5 -1
- package/dist/missions.js +10 -5
- package/dist/plugin-evidence.js +2 -1
- package/dist/plugin-sdk.d.ts +3 -0
- package/dist/plugin-sdk.js +3 -0
- package/dist/plugins.d.ts +108 -2
- package/dist/plugins.js +131 -1
- package/dist/preview.d.ts +1 -0
- package/dist/preview.js +4 -1
- package/dist/recovery.d.ts +155 -0
- package/dist/recovery.js +216 -0
- package/dist/research.d.ts +1 -1
- package/dist/retry.d.ts +143 -0
- package/dist/retry.js +127 -0
- package/dist/runtime.d.ts +56 -4
- package/dist/runtime.js +727 -125
- package/dist/store.d.ts +62 -7
- package/dist/store.js +86 -15
- package/dist/team-artifacts.d.ts +130 -112
- package/dist/team-artifacts.js +123 -151
- package/dist/team-child.d.ts +4 -1
- package/dist/team-child.js +21 -2
- package/dist/team-contract.d.ts +1 -1
- package/dist/telegram.d.ts +2 -0
- package/dist/telegram.js +83 -47
- package/dist/tool-scheduler.d.ts +84 -0
- package/dist/tool-scheduler.js +226 -0
- package/dist/tools.d.ts +78 -4
- package/dist/tools.js +34 -7
- package/package.json +16 -9
- package/profiles/assistant/config.yaml +2 -1
package/README.md
CHANGED
|
@@ -16,6 +16,10 @@ What you get:
|
|
|
16
16
|
the reply text as the model writes it. The
|
|
17
17
|
OpenAPI document is served at `/openapi.json` and pinned in
|
|
18
18
|
[`openapi/ardent.json`](openapi/ardent.json).
|
|
19
|
+
- **Remote client** [`@hivemagnus/ardent-client`](client/README.md), released
|
|
20
|
+
with Ardent, for Node.js and browsers: submit and follow tasks across stream
|
|
21
|
+
reconnects, drive recovery decisions, read lineage, and download artifacts
|
|
22
|
+
with resumable, digest-verified transfers, directly or through Magnus.
|
|
19
23
|
- **A2A protocol 1.0** server and client over JSON-RPC, HTTP+JSON, and gRPC,
|
|
20
24
|
with authenticated peers, push notifications, and bounded "team missions"
|
|
21
25
|
that scope which tools a peer may reach.
|
|
@@ -81,6 +85,23 @@ ardent gateway run # management API, A2A, channels, jobs
|
|
|
81
85
|
|
|
82
86
|
`ardent help` lists every command.
|
|
83
87
|
|
|
88
|
+
### Under Magnus and in the Hive suite
|
|
89
|
+
|
|
90
|
+
Each [Magnus](https://github.com/ChefTaco/magnus) release is built and tested
|
|
91
|
+
against one pinned Ardent version: Magnus 3.1.1 pins Ardent 3.1.3. Every Ardent
|
|
92
|
+
release is followed by a Magnus release that moves the pin, regenerates its
|
|
93
|
+
Ardent contract and updates the node agent; until then, managed nodes keep the
|
|
94
|
+
pinned version.
|
|
95
|
+
|
|
96
|
+
Magnus installs that pinned package on a node and creates profiles with its
|
|
97
|
+
**New Agent** workflow, which always enables HiveMem. In a
|
|
98
|
+
[Hive](https://github.com/ChefTaco/hive) suite installation, run
|
|
99
|
+
`./hive.sh ardent setup` after enrolling the host agent: it creates an
|
|
100
|
+
`assistant` profile through Magnus and tests a real model response. See Hive's
|
|
101
|
+
[Create an Ardent assistant](https://github.com/ChefTaco/hive/blob/main/deployment/FULL.md#create-an-ardent-assistant)
|
|
102
|
+
and Magnus's [Ardent guide](https://github.com/ChefTaco/magnus/blob/main/docs/ARDENT.md).
|
|
103
|
+
Ardent Project Studio and the UI reach those profiles only through Magnus.
|
|
104
|
+
|
|
84
105
|
### Native suite artifact
|
|
85
106
|
|
|
86
107
|
Build this repository's `Dockerfile` from the repository root, then select that
|
|
@@ -126,22 +147,83 @@ only the *names* of the environment variables that hold them.
|
|
|
126
147
|
| `product` | `Ardent` | Shown in the profile summary. |
|
|
127
148
|
| `timezone` | host zone, else `UTC` | IANA zone used for dates shown to the model. Job schedules carry their own zone. |
|
|
128
149
|
| `identity.soul_file`, `identity.identity_file` | `SOUL.md`, `IDENTITY.md` | Persona files in the profile. |
|
|
129
|
-
| `execution` | required | `backend: llamacpp \| codex`, step, tool-call, parallelism, and deadline limits. |
|
|
150
|
+
| `execution` | required | `backend: llamacpp \| codex`, step, tool-call, parallelism, and deadline limits. See [Tool scheduling](#tool-scheduling). |
|
|
151
|
+
| `execution.recovery.enabled` | `true` | Resume tasks interrupted by a crash or restart. `false` holds them as `unknown`, as before. See [Execution recovery](#execution-recovery). |
|
|
152
|
+
| `execution.recovery_max_new_deadline_seconds` | `deadline_seconds` | Longest deadline an operator may give `retry_with_new_deadline`, 1-86400. |
|
|
130
153
|
| `providers.llamacpp` | required | `base_url`, `model`, `api_key_env`, `request_timeout_seconds`, optional `context_window_tokens`, `max_output_tokens`, `reasoning_effort`. |
|
|
131
|
-
| `providers.codex` | required | `command`, `model`, `auth_mode: chatgpt \| api_key` (default `chatgpt`); `approval_policy: never` and `sandbox: read-only` are fixed. |
|
|
154
|
+
| `providers.codex` | required | `command`, `model`, `auth_mode: chatgpt \| api_key` (default `chatgpt`), `durable_threads` (default `true`: task threads are not ephemeral and their ids are recorded for recovery); `approval_policy: never` and `sandbox: read-only` are fixed. |
|
|
132
155
|
| `memory` | `{ provider: none }` | See [HiveMem](#hivemem-memory). |
|
|
133
156
|
| `research` | disabled | `enabled`, `searxng_url`, `firecrawl_url`, `firecrawl_token_env`. Enables the `news_search`, `news_article`, `news_collect`, and `news_capabilities` tools. |
|
|
134
157
|
| `skills` | `directories: [skills]`, `enabled: []` | Only enabled skills are shown to the model. |
|
|
135
158
|
| `a2a` | disabled | See [A2A](#a2a). |
|
|
136
159
|
| `channels.telegram`, `channels.mattermost` | disabled | See [Chat channels](#chat-channels). |
|
|
137
160
|
| `integrations.magnus_control` | disabled | See [Magnus Control tools](#magnus-control-tools). |
|
|
138
|
-
| `artifacts.max_bytes` | `2097152` (2 MiB) | Largest artifact a task may store, up to 64 MiB. See [
|
|
161
|
+
| `artifacts.max_bytes` | `2097152` (2 MiB) | Largest artifact a task may store, export to a peer or import, up to 64 MiB. See [Artifact transfer v2](#artifact-transfer-v2-and-renditions). |
|
|
139
162
|
| `plugins` | `[]` | See [Plugins](#plugins). |
|
|
140
163
|
| `api` | `127.0.0.1:9910`, `ARDENT_API_TOKEN` | Management listener and the env var holding its bearer token. A non-loopback host is refused; put a TLS proxy in front instead. |
|
|
141
164
|
|
|
142
165
|
`ardent config schema` prints the full JSON Schema, and `ardent config
|
|
143
166
|
validate` checks a profile without starting it.
|
|
144
167
|
|
|
168
|
+
A few settings come from the environment rather than `config.yaml`:
|
|
169
|
+
|
|
170
|
+
| Variable | Default | Notes |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `ARDENT_HOME` | `~/.ardent` | Root of the profiles directory and the shared model policy. |
|
|
173
|
+
| `ARDENT_API_TOKEN` | — | Management API bearer token (the name is `api.token_env`). |
|
|
174
|
+
| `ARDENT_INSTANCE_REF` | `local.<profile>` | The instance part of this runtime's qualified execution references (`hx1:ardent:<instance>:...`). Magnus sets `<node id>.<profile>`. 1 to 96 characters of `A-Z a-z 0-9 . _ -`; any other value stops the runtime from starting and is listed by `ardent config validate`. See [Execution ancestry](#execution-ancestry). |
|
|
175
|
+
|
|
176
|
+
### Tool scheduling
|
|
177
|
+
|
|
178
|
+
Task concurrency and tool concurrency are separate settings:
|
|
179
|
+
|
|
180
|
+
| Key | Default | Notes |
|
|
181
|
+
|---|---|---|
|
|
182
|
+
| `execution.max_parallel_tasks` | `3` | Tasks running at once, 1-16. The runtime runs at most 4. |
|
|
183
|
+
| `execution.max_parallel_tool_calls` | `4` | Tool calls from one model turn in flight at once, 1-16. |
|
|
184
|
+
| `execution.max_parallel_tools` | none | Deprecated. Despite its name it limits tasks. It is used only when `max_parallel_tasks` is absent, and `ardent config validate` and `ardent doctor` then report the notice `execution.max_parallel_tools is deprecated: it limits tasks; set max_parallel_tasks`. A notice never makes the profile unready. |
|
|
185
|
+
|
|
186
|
+
The llama.cpp and Codex backends dispatch tool calls through the same scheduler:
|
|
187
|
+
|
|
188
|
+
- A call is *parallel-eligible* when its tool is a `read` tool that does not
|
|
189
|
+
declare `concurrency: 'serial'`, or any tool that declares
|
|
190
|
+
`concurrency: 'parallel'`. Every other call, including an unknown tool and
|
|
191
|
+
`team_ask_user`, is serial.
|
|
192
|
+
- Calls are admitted in the order the model emitted them (for Codex, the order
|
|
193
|
+
the calls arrive). Consecutive parallel-eligible calls overlap, at most
|
|
194
|
+
`max_parallel_tool_calls` at a time. A serial call is a barrier: it starts
|
|
195
|
+
after every earlier call has settled, and later calls wait for it. A write
|
|
196
|
+
therefore never overlaps anything unless its tool opts in.
|
|
197
|
+
- Each dispatch waits while the task is paused, checks `max_tool_calls` (for the
|
|
198
|
+
whole task), journals `tool_attempt`, waits for team admission, runs plugin
|
|
199
|
+
`beforeToolCall` hooks, invokes the tool, journals `tool_result` with the call
|
|
200
|
+
`id`, and then runs `afterToolCall` hooks.
|
|
201
|
+
- llama.cpp receives the results in the order it emitted the calls, each bound
|
|
202
|
+
to its call id. Codex binds each result to its own RPC request, and its
|
|
203
|
+
follow-up turn lists results in completion order.
|
|
204
|
+
- On cancellation, calls that were not dispatched settle as
|
|
205
|
+
`{ ok: false, code: 'CANCELLED', effect: 'none' }` and are journaled as
|
|
206
|
+
`tool_not_dispatched` (with a `reason`). A call already started keeps its
|
|
207
|
+
uncertainty, so a cancelled task with a started call that may have had an
|
|
208
|
+
effect (not a `read`, and not settled without effect, for example denied by a
|
|
209
|
+
plugin) is `unknown`, never `cancelled`. A call that would exceed
|
|
210
|
+
`max_tool_calls` is not dispatched and fails the task.
|
|
211
|
+
|
|
212
|
+
Each tool receives `ctx.idempotencyKey`, `sha256("<task id>:<call id>")` in
|
|
213
|
+
hex, as the third `invoke` argument (`defineTool` handlers receive it as their
|
|
214
|
+
third argument). A tool may forward it to its service so that a repeated
|
|
215
|
+
dispatch of the same model call is harmless. A tool can also declare
|
|
216
|
+
`idempotent: true` (repeating it with identical arguments and key is safe) and a
|
|
217
|
+
`reconcile(input, ctx, signal)` hook that asks its service what happened to an
|
|
218
|
+
interrupted call. [Execution recovery](#execution-recovery) re-dispatches an
|
|
219
|
+
interrupted idempotent call under the same key and asks `reconcile` before it
|
|
220
|
+
resumes a task; a tool that declares neither is held for an operator when one of
|
|
221
|
+
its calls is interrupted. `artifact_write` and `document_render` are idempotent
|
|
222
|
+
(a repeat under the same key returns the same registration) and reconcile from
|
|
223
|
+
their manifest row; `team_handoff`, `team_ask_user`, `team_propose_decision` and
|
|
224
|
+
`development_note` reconcile against their local journal rows. HiveMem writes
|
|
225
|
+
and `news_collect` declare neither, so they are held.
|
|
226
|
+
|
|
145
227
|
### HiveMem memory
|
|
146
228
|
|
|
147
229
|
Memory is off by default. To use a HiveMem server:
|
|
@@ -185,6 +267,9 @@ channels:
|
|
|
185
267
|
allowed_user_ids: [user-id]
|
|
186
268
|
require_mention: true
|
|
187
269
|
reply_mode: thread # thread | flat
|
|
270
|
+
catchup: # optional; these are the defaults
|
|
271
|
+
max_posts: 2000 # 1-10000 posts from others per walk
|
|
272
|
+
max_age_hours: 24 # older missed posts are skipped, not answered
|
|
188
273
|
```
|
|
189
274
|
|
|
190
275
|
Telegram uses long polling; Mattermost uses its v4 REST and WebSocket APIs.
|
|
@@ -192,6 +277,37 @@ Both support `/help`, `/new`, `/status`, `/jobs`, `/model`, `/stop`, `/tasks`,
|
|
|
192
277
|
and `/sources`. Each inbound message and outbound reply is journaled, so a
|
|
193
278
|
restart never sends the same reply twice.
|
|
194
279
|
|
|
280
|
+
**Mattermost catch-up.** Posts missed while Ardent was stopped or its
|
|
281
|
+
WebSocket was down are recovered from history. Ardent keeps a boundary per
|
|
282
|
+
channel (the newest post up to which everything older is settled). On start,
|
|
283
|
+
after every reconnect, and every 30 seconds, it walks back from the newest post
|
|
284
|
+
to that boundary in pages of 200 (`before=<post id>`), then handles the posts
|
|
285
|
+
oldest first. This works with Mattermost and ChatterMost alike.
|
|
286
|
+
|
|
287
|
+
| Key | Default | Meaning |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| `catchup.max_posts` | `2000` (at most `10000`) | Posts from others that one walk reads. The bot's own posts do not count, but a walk reads at most `2 × max_posts / 200` pages. |
|
|
290
|
+
| `catchup.max_age_hours` | `24` | A missed post older than this is claimed as `skipped_stale` and not answered. |
|
|
291
|
+
|
|
292
|
+
Every eligible post in the walk ends in exactly one of four ways:
|
|
293
|
+
|
|
294
|
+
- **Answered.** It goes through the normal channel path: an atomic claim, then the task, then the reply.
|
|
295
|
+
- **Already claimed.** A live event, an earlier walk or an earlier run claimed it. It is never answered again, so a reply whose outcome is unknown is never replayed.
|
|
296
|
+
- **Skipped as stale.** The claim is recorded with `disposition` `skipped_stale`.
|
|
297
|
+
- **Lost to a permanent gap.** The gap is recorded as a row with `walk_bound` when the walk reached its bound before the boundary, or `retention` when the server no longer holds the history (for example, the `before` pivot disappeared).
|
|
298
|
+
|
|
299
|
+
The boundary moves only past posts settled in order, so an interrupted walk
|
|
300
|
+
resumes where it stopped. A channel seen for the first time is seeded without
|
|
301
|
+
answering its history.
|
|
302
|
+
|
|
303
|
+
Replies that the server rate-limits (`429`) wait out `Retry-After` under the
|
|
304
|
+
`mattermost` retry policy (see [Retries](#retries)). `GET /api/v1/status` reports the latest walk of each channel under
|
|
305
|
+
`channels.mattermost.catchup`:
|
|
306
|
+
|
|
307
|
+
- `state`: `idle`, `catching_up`, `complete` or `gap`.
|
|
308
|
+
- Counters: `recovered`, `skipped_stale`, `already_claimed` and `pages`.
|
|
309
|
+
- Gaps: the gap count and `last_gap`.
|
|
310
|
+
|
|
195
311
|
### A2A
|
|
196
312
|
|
|
197
313
|
```yaml
|
|
@@ -269,6 +385,37 @@ before you install it; `ardent jobs definitions status` and
|
|
|
269
385
|
windows. The built-in handler is `news.collect` (requires `research`); plugins
|
|
270
386
|
add more.
|
|
271
387
|
|
|
388
|
+
A window that asks to retry with `effect_status: "none"` waits
|
|
389
|
+
`retry_backoff_seconds · 2^(attempt-1)` with equal jitter (a random delay
|
|
390
|
+
between half and all of it), and only while the next attempt would start
|
|
391
|
+
before the job's next window is due; otherwise it ends `failed` with
|
|
392
|
+
`RETRY_DEADLINE`.
|
|
393
|
+
|
|
394
|
+
### Retries
|
|
395
|
+
|
|
396
|
+
Every retry site in Ardent names a policy in [`src/retry.ts`](src/retry.ts),
|
|
397
|
+
built on the shared `@hivemagnus/hive-common/retry` helpers:
|
|
398
|
+
|
|
399
|
+
| Site | Attempts | Backoff | Repeated when |
|
|
400
|
+
|---|---|---|---|
|
|
401
|
+
| llama.cpp completion and token count | 3 | 250 ms → 4 s, equal jitter; `Retry-After` (seconds or HTTP date) up to 10 s | transport error or 408/425/429/5xx before any response byte is read |
|
|
402
|
+
| A2A Agent Card, Hermes team card, `getTask`, `listTasks`, extended card | 3 | 500 ms → 5 s, equal jitter | transport error or 408/425/429/5xx over HTTP |
|
|
403
|
+
| A2A `SendMessage` | 3 | 500 ms → 5 s, equal jitter | as above, always with the same `messageId` |
|
|
404
|
+
| A2A push delivery | 3 | `Retry-After` clamped to 1–5 s | 408/425/429/5xx (the callback did not accept the event) |
|
|
405
|
+
| Telegram Bot API | 4 | Telegram's `retry_after`, capped at 60 s | 429 with `retry_after` |
|
|
406
|
+
| Mattermost/ChatterMost REST | 3 | `Retry-After` up to 60 s (1 s without one) | 429 only (the request was not processed) |
|
|
407
|
+
| Artifact transfer pull (import) | 5 | 500 ms → 8 s, equal jitter; `Retry-After` up to 30 s | transport error, a dropped response or 408/425/429/5xx; each attempt resumes from the retained bytes with `Range` and `If-Range` |
|
|
408
|
+
| Codex turns, tools with a possible effect | 1 | — | never |
|
|
409
|
+
|
|
410
|
+
Nothing is repeated once its effect is uncertain, after any response byte was
|
|
411
|
+
consumed (a stream that fails mid-way is not restarted), past the deadline
|
|
412
|
+
(`RETRY_DEADLINE`; for model calls the task deadline and the request timeout),
|
|
413
|
+
or when the response carries `x-hive-retry: exhausted` (the gateway already
|
|
414
|
+
retried). Cancelling during a backoff wait ends the call at once. Model
|
|
415
|
+
retries are journaled as `model_retry` task events
|
|
416
|
+
(`{ step, operation, attempt, reason, delay_ms }`); A2A outbound calls,
|
|
417
|
+
push deliveries and Telegram deliveries record `attempts` on their rows.
|
|
418
|
+
|
|
272
419
|
### Model policy
|
|
273
420
|
|
|
274
421
|
An optional, owner-only `$ARDENT_HOME/model-policy/active.json` selects the
|
|
@@ -288,6 +435,8 @@ is a starting point; compaction is disabled until you enable it.
|
|
|
288
435
|
| `task.done` | The finished task | Its `result` is the authoritative answer |
|
|
289
436
|
|
|
290
437
|
The stream closes after 60 seconds; reconnect to continue.
|
|
438
|
+
[`@hivemagnus/ardent-client`](client/README.md) does this for you
|
|
439
|
+
(`tasks.follow`).
|
|
291
440
|
|
|
292
441
|
Live text works the same for every backend and caller:
|
|
293
442
|
- It holds only what a user would see. Structured output, such as tool or research JSON, is never streamed.
|
|
@@ -370,6 +519,74 @@ a new artifact a revision of an earlier one. `GET /api/v1/tasks/{id}/artifacts`
|
|
|
370
519
|
lists a task's manifests and `GET /api/v1/artifacts/{sha256}/manifest` returns
|
|
371
520
|
the newest manifest for a digest; the bytes stay at `GET /api/v1/artifacts/{id}`.
|
|
372
521
|
|
|
522
|
+
### Artifact transfer v2 and renditions
|
|
523
|
+
|
|
524
|
+
Artifacts up to `artifacts.max_bytes` (at most 64 MiB) move between agents
|
|
525
|
+
without inline task payloads, with bounded memory: every path streams. A
|
|
526
|
+
profile advertises `urn:hive:artifact-transfer:2` on its Agent Card
|
|
527
|
+
(`capabilities.extensions`, params `{max_bytes, range: true, renditions: true}`)
|
|
528
|
+
and `capabilities.artifact_transfer: 2` in `GET /api/v1/status`.
|
|
529
|
+
|
|
530
|
+
Manifest 1.1 is a strict superset of 1.0. It may add `rendition` (`role`
|
|
531
|
+
`original | preview | model_input`, `of_sha256`, `purpose`, `transform {name,
|
|
532
|
+
version, params}`) and `provenance.execution` (`root`, `task`, `step`, attribution
|
|
533
|
+
only). It is as immutable as 1.0 and is shown only to v2 consumers: the existing
|
|
534
|
+
manifest routes and the v1 descriptor still return 1.0, and stored 1.0 records
|
|
535
|
+
are never rewritten.
|
|
536
|
+
|
|
537
|
+
| Route | Purpose |
|
|
538
|
+
| --- | --- |
|
|
539
|
+
| `GET /api/v1/artifacts/{sha256}/content` | The bytes with `Accept-Ranges: bytes`, `ETag: "<sha256>"`, `Repr-Digest: sha-256=:<base64>:`, `X-Content-SHA256`, the manifest media type and `Content-Disposition: attachment; filename="<name>"`. One `Range` returns `206`, an unsatisfiable one `416`; an `If-Range` other than the ETag returns the whole artifact. |
|
|
540
|
+
| `GET /api/v1/artifacts/{sha256}/renditions` | `{renditions: [{sha256, role, mime, size, purpose, width?, height?, has_alpha?}]}`, the original first, the same for the original or any rendition. Pick one with HiveCommon `selectRendition`; `download` always means the original. |
|
|
541
|
+
| `GET /api/v1/artifacts/{sha256}/manifest/v2` | The newest manifest as 1.1. |
|
|
542
|
+
| `POST /api/v1/artifacts/imports {peer_id, a2a_task_id, artifact_id, task_id?}` | `202 {import_id}`: pull an artifact a configured peer exported from one of its completed tasks. |
|
|
543
|
+
| `GET /api/v1/artifacts/imports[/{id}]` | `{state: queued \| transferring \| verifying \| completed \| failed, received_bytes, size, attempts, error?}` |
|
|
544
|
+
|
|
545
|
+
An import resolves the peer's descriptor, negotiates `min(peer max_bytes, local
|
|
546
|
+
max_bytes)`, and appends to `<profile>/artifacts/.partial/<import id>`, committing
|
|
547
|
+
`received_bytes` after an fsync every 4 MiB. After an interruption or restart it
|
|
548
|
+
re-hashes the retained bytes as a stream and asks for the rest with `Range` and
|
|
549
|
+
`If-Range`; the gateway resumes unfinished imports when it starts. Transport
|
|
550
|
+
failures are retried under the `artifact_transfer` policy (see [Retries](#retries))
|
|
551
|
+
within the import's deadline; `attempts` counts runs and retries. The final
|
|
552
|
+
SHA-256 and size are verified: on `DIGEST_MISMATCH` the partial file is deleted,
|
|
553
|
+
nothing is registered and nothing is retried until an operator reissues the
|
|
554
|
+
import (`POST` again). The verified file is renamed into the content store (an
|
|
555
|
+
existing digest is kept) and registered with a manifest 1.1 whose lineage adds
|
|
556
|
+
the peer hop. Without `task_id`, the import records its own completed task.
|
|
557
|
+
`ardent artifact import --peer <id> --task <a2a task> --artifact <id>` runs one
|
|
558
|
+
from the command line and `ardent artifact imports` lists them.
|
|
559
|
+
|
|
560
|
+
A team export to a peer is limited by `artifacts.max_bytes`. Each export emits a
|
|
561
|
+
`Team artifact export v2` A2A artifact with one data part of media type
|
|
562
|
+
`application/vnd.hive.artifact-transfer.v2+json` carrying `{manifest_1_1,
|
|
563
|
+
content_path, renditions_path, size, sha256}`. Up to 2 MiB, the unchanged v1 text
|
|
564
|
+
descriptor (`Team artifact export`) is still emitted; above it, a v1 consumer gets
|
|
565
|
+
an explicit `TRANSFER_REQUIRES_V2` result that names the capability, and an
|
|
566
|
+
importer facing a peer without the URN fails the same way. On the A2A listener,
|
|
567
|
+
`/team/artifacts/{id}` serves the v1 full response without `Range` (verified as
|
|
568
|
+
it streams) and gains `Range` and the headers above; `/team/artifacts/{id}/manifest`
|
|
569
|
+
returns the 1.1 manifest and `/team/artifacts/{id}/renditions` the exported forms
|
|
570
|
+
with their export IDs. Renditions of an exported original are exported with it.
|
|
571
|
+
|
|
572
|
+
Plugins reach the same primitives through `ctx.runtime` (and types from
|
|
573
|
+
`@hivemagnus/ardent/plugin-sdk`):
|
|
574
|
+
|
|
575
|
+
- `ctx.runtime.artifacts.putStream(readable, {name, mediaType, expectedSha256?,
|
|
576
|
+
expectedSize?, maxBytes?, inspect?, signal?})` stores a stream (temporary file,
|
|
577
|
+
incremental SHA-256, size bound, fsync, rename) and returns the `Artifact`;
|
|
578
|
+
`openRead(sha256, {start?, end?}, {verify?})` returns `{stream, size, sha256,
|
|
579
|
+
start, end}`; `stat(sha256)` returns `{size}` or undefined.
|
|
580
|
+
- `ctx.runtime.artifactManifests.registerStream({taskId, name, mime, stream,
|
|
581
|
+
source, expectedSha256?, expectedSize?, revisesSha256?, ttlSeconds?, execution?})`
|
|
582
|
+
stores and registers an original with a manifest 1.1, checking its content as it
|
|
583
|
+
streams.
|
|
584
|
+
- `ctx.runtime.artifactManifests.registerRendition({originalSha256, role: preview |
|
|
585
|
+
model_input, purpose, transform, mime, bytes | stream, name?, width?, height?,
|
|
586
|
+
has_alpha?, producer?})` registers a separate rendition artifact linked to its
|
|
587
|
+
original; the original is never changed. `renditions(sha256)` lists the forms
|
|
588
|
+
and `manifestV2(sha256)` returns the 1.1 record.
|
|
589
|
+
|
|
373
590
|
`development_note` stores an append-only development record: the agent's own
|
|
374
591
|
note about how it works (`epistemic: agent_reported`).
|
|
375
592
|
|
|
@@ -414,6 +631,223 @@ It merges:
|
|
|
414
631
|
`agent_ref` is the profile name. `ardent development list [--after CURSOR]
|
|
415
632
|
[--limit N] [--kind KIND]` prints the same pages.
|
|
416
633
|
|
|
634
|
+
### Execution recovery
|
|
635
|
+
|
|
636
|
+
After a crash or restart, every task that was `running` is evaluated before any
|
|
637
|
+
queued work starts. **A write is never repeated merely because execution
|
|
638
|
+
resumed**: an unknown effect needs reconciliation, never a retry. Each task is:
|
|
639
|
+
|
|
640
|
+
- **resumed under the same id**: it stays `running`, continues at the next
|
|
641
|
+
unfinished model step, and reuses completed model replies and settled tool
|
|
642
|
+
results;
|
|
643
|
+
- **reconciled first**: an interrupted tool call whose tool has a `reconcile`
|
|
644
|
+
hook is asked what happened before the task continues; or
|
|
645
|
+
- **held** as `unknown` (still terminal) with a recovery status and an
|
|
646
|
+
actionable reason, waiting for an operator decision or marked unsupported.
|
|
647
|
+
|
|
648
|
+
`TaskState` does not change. Tasks carry an optional `recovery` object (task
|
|
649
|
+
`GET` and list, and `GET /api/v1/tasks/{id}/recovery`), so older clients see
|
|
650
|
+
`running → completed` for a resumed task and `unknown` for a held one:
|
|
651
|
+
|
|
652
|
+
```json
|
|
653
|
+
{"status": "awaiting_decision", "attempt": 1,
|
|
654
|
+
"reason": {"code": "UNSETTLED_EXTERNAL_WRITE", "message": "A tool call with a possible external effect was dispatched ..."},
|
|
655
|
+
"checkpoint": {"step": 0, "completed_calls": 1,
|
|
656
|
+
"pending_calls": [{"call_id": "call-1", "tool": "news_collect", "effect": "artifact-write", "dispatched_at": "2026-11-23T12:00:00.000Z", "reconcilable": false}]},
|
|
657
|
+
"actions": ["mark_applied", "mark_not_applied", "retry_with_new_deadline", "abandon"]}
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
`status` is `ready` or `reconciling` (resuming), `resumed` (running again),
|
|
661
|
+
`awaiting_decision`, `unsupported`, or `resolved` (settled at startup, or
|
|
662
|
+
decided). `actions` lists only the decisions valid now. `GET /api/v1/status`
|
|
663
|
+
reports `recovery: { ready, reconciling, awaiting_decision, unsupported }`.
|
|
664
|
+
|
|
665
|
+
**How a task is planned.** Rules apply in order:
|
|
666
|
+
|
|
667
|
+
| Condition | Outcome | `reason.code` |
|
|
668
|
+
|---|---|---|
|
|
669
|
+
| Cancellation was requested | `cancelled`, or held when an effect is uncertain | `CANCELLED_DURING_OUTAGE` / `CANCELLED_WITH_UNSETTLED_EFFECT` |
|
|
670
|
+
| The deadline passed while stopped | `failed`, or held when an effect is uncertain; never extended | `DEADLINE_ELAPSED_DURING_OUTAGE` |
|
|
671
|
+
| `execution.recovery.enabled: false` | held, unsupported | `RECOVERY_DISABLED` |
|
|
672
|
+
| An extension `taskExecutor` with a possible effect ran, or a preview task | held, unsupported | `EXTENSION_EXECUTION_NOT_RESUMABLE` / `PREVIEW_NOT_RESUMABLE` |
|
|
673
|
+
| Codex | see the backend matrix | `CODEX_*` |
|
|
674
|
+
| llama.cpp, no checkpoint, no effectful tool dispatched | `ready`: restart from the beginning | `RESTART_NO_EFFECT` |
|
|
675
|
+
| llama.cpp, no checkpoint, an effectful tool dispatched (for example, from before this release) | held, unsupported | `NO_EXECUTION_CHECKPOINT` |
|
|
676
|
+
| A checkpoint fails its digest | held, unsupported | `CHECKPOINT_INVALID` |
|
|
677
|
+
| Every dispatched call settled, or the unsettled ones are reads or idempotent | `ready`: resume at the next step; unsettled reads and idempotent calls are dispatched again under the same idempotency key | `RESUME_FROM_CHECKPOINT` |
|
|
678
|
+
| An unsettled call whose tool can reconcile | `reconciling`: `applied` settles it with the service's result; `not_applied` tells the model it was not applied (it is not retried); `unknown` holds the task | `RECONCILE_INTERRUPTED_CALL` / `RECONCILIATION_INCONCLUSIVE` |
|
|
679
|
+
| Any other unsettled call with a possible effect | held, awaiting a decision | `UNSETTLED_EXTERNAL_WRITE` |
|
|
680
|
+
|
|
681
|
+
A call is *uncertain* when it was dispatched without a recorded outcome and is
|
|
682
|
+
not a `read`, or settled with an unknown effect. A call a plugin denied, that
|
|
683
|
+
settled without effect, or that was never dispatched leaves nothing uncertain.
|
|
684
|
+
Until the gateway knows a task's tools (plugins load after the journal opens),
|
|
685
|
+
a call that needs that check reports `reconciling` with `TOOL_CHECK_PENDING`;
|
|
686
|
+
the check runs before any queued work is admitted.
|
|
687
|
+
|
|
688
|
+
**Resuming.** A resumed task skips the queue transition, journals
|
|
689
|
+
`execution_resumed { attempt, from_step, reused_calls, redispatched_calls, mode }`,
|
|
690
|
+
reloads its transcript, evidence and tool-call count from its checkpoint, and
|
|
691
|
+
continues at the next step, ahead of queued work but still one task per caller
|
|
692
|
+
at a time. Tools, mission scope, memory grants, caller, context, ownership and
|
|
693
|
+
plugin task contexts are re-derived from their owning stores; the checkpoint
|
|
694
|
+
never supplies them, and the system prompt is rebuilt so policy and model
|
|
695
|
+
changes apply. A paused task stays paused and waits at its first boundary. The
|
|
696
|
+
deadline timer is re-armed from the stored deadline. Interrupted work does not
|
|
697
|
+
start again while admission is fenced for a rollback. A task the gateway's
|
|
698
|
+
shutdown deadline stops with nothing uncertain stays `running`
|
|
699
|
+
(`execution_suspended`) and resumes on the next start.
|
|
700
|
+
|
|
701
|
+
**Operator decisions.** `POST /api/v1/tasks/{id}/recovery`
|
|
702
|
+
`{ action, call_id?, result?, note?, deadline_seconds? }` resolves a task held
|
|
703
|
+
`awaiting_decision`. It is idempotent per task, attempt and action, and returns
|
|
704
|
+
the recovery object:
|
|
705
|
+
|
|
706
|
+
| Action | Effect |
|
|
707
|
+
|---|---|
|
|
708
|
+
| `mark_applied` | The pending call is settled `operator_applied` with `result` (at most 64 KiB, checked against the tool's output schema) or "result unavailable"; the work continues without dispatching it. |
|
|
709
|
+
| `mark_not_applied` | The pending call is settled `operator_not_applied`; the model is told it was not applied. |
|
|
710
|
+
| `retry_with_new_deadline` | The pending call is dispatched again under its original idempotency key, with a new deadline from now (`deadline_seconds`, at most `execution.recovery_max_new_deadline_seconds`). The only way to get a new deadline. |
|
|
711
|
+
| `abandon` | Records the decision; nothing continues. |
|
|
712
|
+
|
|
713
|
+
Because `unknown` is terminal, the first three create a **continuation task**:
|
|
714
|
+
the same caller, context, session and prompt (not added to the session again),
|
|
715
|
+
idempotency key `recovery:<original id>:<attempt + 1>`, an execution context
|
|
716
|
+
whose parent is the original task (`source: continuation`, listed in the
|
|
717
|
+
original's lineage `continuations`), and the original's checkpoint with the
|
|
718
|
+
pending call settled as decided. A mission continuation copies the mission and
|
|
719
|
+
its `TeamResult` names the continuation as `task_id` and lists the operator
|
|
720
|
+
decisions in `uncertain_effects`. The original's recovery becomes `resolved`
|
|
721
|
+
with `continuation_task_id`; the journals record `recovery_continued` and
|
|
722
|
+
`recovery_continuation_of`. `mark_*` keep the original deadline, so they are
|
|
723
|
+
offered only while it has not passed. A task held after a cancellation
|
|
724
|
+
request is never continued: a decision only records what the operator
|
|
725
|
+
established.
|
|
726
|
+
|
|
727
|
+
**Backends.**
|
|
728
|
+
|
|
729
|
+
| Backend | Recovery |
|
|
730
|
+
|---|---|
|
|
731
|
+
| llama.cpp | Full: checkpoints at every model reply and tool boundary, per the table above. |
|
|
732
|
+
| Codex | With `providers.codex.durable_threads` (default), thread and turn ids are recorded. (a) When no effectful call is unsettled, the protocol lock verifies thread recovery for the installed CLI, and `thread/read` lists every dynamic tool call in the thread with a settled invocation, the thread is resumed (`CODEX_THREAD_RESUME`). (b) When no effectful tool was ever dispatched, the task restarts on a fresh thread (`CODEX_RESTART_NO_EFFECT`). (c) Otherwise it is held unsupported (`CODEX_THREAD_NOT_VERIFIABLE`). `codex-protocol.lock.json` records `thread_resume_verified` and `thread_read_items_verified`; both are `false` for the observed CLI, so (a) is disabled and the reason says so. |
|
|
733
|
+
| Extension `taskExecutor` | Not resumable; held (`EXTENSION_EXECUTION_NOT_RESUMABLE`) when its effect is `possible`. |
|
|
734
|
+
| Preview | Not resumable (`PREVIEW_NOT_RESUMABLE`). |
|
|
735
|
+
|
|
736
|
+
**Never retried automatically:** a dispatched call with a possible effect and no
|
|
737
|
+
recorded outcome, unless its tool is idempotent or its own service reconciles
|
|
738
|
+
it; HiveMem writes; `news_collect`; extension executors; and anything after the
|
|
739
|
+
original deadline. A settled call is never dispatched again.
|
|
740
|
+
|
|
741
|
+
**State.** Three additive SQLite tables, written in the same transaction as the
|
|
742
|
+
journal event of each boundary: `execution_state` (the model transcript after
|
|
743
|
+
the last boundary, evidence, tool-call count and Codex thread ids, with a
|
|
744
|
+
digest), `tool_invocations` (one row per call: `dispatched` before invocation,
|
|
745
|
+
then settled with its result; compacted arguments, so file bytes stay in the
|
|
746
|
+
artifact store), and `task_recovery`. `model_result` events also carry `calls`
|
|
747
|
+
(id, name, compacted arguments). Execution checkpoints are separate from
|
|
748
|
+
context checkpoints; neither reads the other. Rolling back to 3.1.x ignores the
|
|
749
|
+
new tables and holds interrupted tasks as `unknown`.
|
|
750
|
+
|
|
751
|
+
**Channels.** A recovered task has no in-process handler waiting for it, so the
|
|
752
|
+
Telegram and Mattermost adapters answer its update themselves: at start and
|
|
753
|
+
whenever a task settles they find updates bound to a recovered task with no
|
|
754
|
+
recorded delivery, wait for the resumed task (or for the continuation an
|
|
755
|
+
operator decision creates), and reply through the usual record-before-send path.
|
|
756
|
+
The reply target (conversation, thread, message replied to) is stored with each
|
|
757
|
+
inbound claim (`channel_inbound.reply_target_json`). An update that already has
|
|
758
|
+
a delivery (queued, sent, failed or unknown) is never sent again, and a task
|
|
759
|
+
held awaiting a decision is not answered until its continuation finishes.
|
|
760
|
+
Updates claimed before this release have no stored target and are not answered.
|
|
761
|
+
|
|
762
|
+
**A2A peers.** The A2A surface publishes the outcome of a peer task whose
|
|
763
|
+
operation was recovered, through the same task store (GetTask, ListTasks) and
|
|
764
|
+
push sender as a live request:
|
|
765
|
+
|
|
766
|
+
| Operation | Peer task |
|
|
767
|
+
|---|---|
|
|
768
|
+
| Resumed, then completed | Answer, artifacts and `completed` (or `input_required`), as live. |
|
|
769
|
+
| Settled at startup (`failed`, `cancelled`) | `failed` or `canceled`. |
|
|
770
|
+
| Held `awaiting_decision` | Stays `working`; a status message gives the reason, and task metadata `ardentRecovery: { status, reason_code }`. |
|
|
771
|
+
| Continued after a decision | Follows the continuation: its answer and final state are published for the peer's original task, the A2A operation binding moves to the continuation, and `ardentRecovery.continuation_task_id` names it. |
|
|
772
|
+
| Held `unsupported`, or abandoned | `failed` with "Execution outcome is unknown: ...", as an interrupted task with an uncertain effect reports today. |
|
|
773
|
+
|
|
774
|
+
Each final state is claimed in `a2a_recovery_publications` before it is
|
|
775
|
+
published, so it and its push notification are sent at most once.
|
|
776
|
+
|
|
777
|
+
### Execution ancestry
|
|
778
|
+
|
|
779
|
+
Every task accepted by this version has an execution context (execution
|
|
780
|
+
context v1 from `@hivemagnus/hive-common/execution`): the causal tree it
|
|
781
|
+
belongs to, across products. It is **attribution only**: tools, memory scope,
|
|
782
|
+
mission scope, team-child admission and artifacts are never selected from it.
|
|
783
|
+
|
|
784
|
+
```json
|
|
785
|
+
{"v": 1, "request_id": "req-1", "root": "hx1:studio:inst-1:request:r-1",
|
|
786
|
+
"parent": "hx1:studio:inst-1:node:n-1", "self": "hx1:ardent:node-a.assistant:task:<task id>",
|
|
787
|
+
"deadline_ms": 1790431800000}
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
- **Where it comes from.** `POST /api/v1/tasks`, `POST /api/v1/missions` and
|
|
791
|
+
`POST /api/v1/preview/tasks` take an optional `execution` field (else the
|
|
792
|
+
`x-hive-execution` header); an A2A message carries it as
|
|
793
|
+
`metadata.hiveExecution`. The task keeps the caller's `root` and
|
|
794
|
+
`request_id`, takes the caller's `self` as its `parent`, and its `self` is
|
|
795
|
+
always `hx1:ardent:<instance>:task:<task id>`, where the instance is
|
|
796
|
+
`ARDENT_INSTANCE_REF`. A missing, malformed or unknown-version value is
|
|
797
|
+
never rejected: the task gets a new root at its own reference. The context
|
|
798
|
+
is not part of the idempotency digest. `deadline_ms` is the earlier of the
|
|
799
|
+
caller's and the task's deadline; it does not change the task deadline.
|
|
800
|
+
- **Where it is kept.** The `task_execution` table (`self_ref`, `root_ref`,
|
|
801
|
+
`parent_ref`, `inputs_json`, `context_json` with the task's W3C trace,
|
|
802
|
+
`source`: `caller`, `a2a`, `minted` or `continuation`), written in the same
|
|
803
|
+
transaction as the task, and the `accepted` event's `execution`. A team
|
|
804
|
+
child's context is also stored next to its retained grant, outside the
|
|
805
|
+
grant's digest.
|
|
806
|
+
- **Where it goes.** Every llama.cpp request carries a new `x-request-id`, a
|
|
807
|
+
`traceparent` that is a child span of the task trace, and `x-hive-execution`
|
|
808
|
+
with `self` `hx1:ardent:<instance>:attempt:<task id>/<step>/<n>`, `attempt`
|
|
809
|
+
`n` and the deadline. `model_started` events journal `attempt`, `ref`,
|
|
810
|
+
`request_id` and `traceparent`, so a gateway's request log links back to the
|
|
811
|
+
task. `ArdentA2AClient.sendWithReceipt` / `send` / `sendStreaming` take
|
|
812
|
+
`{ execution }` and send it as `metadata.hiveExecution`, so the receiving
|
|
813
|
+
agent's task keeps the root and has the delegating task as its parent.
|
|
814
|
+
Tools receive it as `ctx.execution`, and plugin hooks as `execution` on the
|
|
815
|
+
task context and tool calls. `tool_attempt` events now record the tool's
|
|
816
|
+
`effect`.
|
|
817
|
+
- **Artifacts.** An artifact a task registers (`artifact_write`,
|
|
818
|
+
`document_render`, preview research briefs, plugin `register` /
|
|
819
|
+
`registerStream` calls, imports) is stored as manifest 1.1 with
|
|
820
|
+
`provenance.execution: {root, task, step?}`: the task's root, its task
|
|
821
|
+
reference and, while the task runs, the model step
|
|
822
|
+
(`hx1:ardent:<instance>:step:<task id>/<step>`). An imported artifact keeps
|
|
823
|
+
its producer's `execution`, and its import task takes the producer task as
|
|
824
|
+
parent. Every 1.0 view is unchanged, and a task without a context still
|
|
825
|
+
stores manifest 1.0. `ArtifactManifests.executionProvenance(taskId)` returns
|
|
826
|
+
the value.
|
|
827
|
+
- **Reading it.** Task responses (`GET /api/v1/tasks`, `GET /api/v1/tasks/{id}`)
|
|
828
|
+
include `execution` when the task has one. `GET /api/v1/tasks/{id}/lineage`
|
|
829
|
+
rebuilds what this profile knows:
|
|
830
|
+
|
|
831
|
+
```json
|
|
832
|
+
{"task_id": "...", "execution": {"v": 1, "root": "...", "self": "..."}, "source": "caller",
|
|
833
|
+
"traceparent": "00-...-...-01", "parent": {"ref": "...", "local_task_id": "..."},
|
|
834
|
+
"children": [{"ref": "...", "local_task_id": "...", "source": "a2a", "created_ms": 0}],
|
|
835
|
+
"continuations": [],
|
|
836
|
+
"model_attempts": [{"step": 0, "attempt": 1, "backend": "llamacpp", "request_id": "...", "ref": "hx1:ardent:...:attempt:<id>/0/1", "started_ms": 0, "usage": null}],
|
|
837
|
+
"tools": [{"call_id": "call-1", "name": "artifact_write", "effect": "artifact-write", "state": "succeeded"}],
|
|
838
|
+
"artifacts": [{"sha256": "...", "name": "map.md", "mime": "text/markdown", "size": 12, "artifact_id": "...", "source": "manifest", "created_ms": 0,
|
|
839
|
+
"schema_version": "1.1", "execution": {"root": "...", "task": "...", "step": "..."}}]}
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
`parent.local_task_id` is set when the parent is a task of this instance.
|
|
843
|
+
Tool `state` is `attempted`, `succeeded`, `failed`, `denied` or
|
|
844
|
+
`not_dispatched`. Artifacts come from the manifest table (`source:
|
|
845
|
+
manifest`, with renditions as `rendition_of`) and, for artifacts with no
|
|
846
|
+
manifest, the `artifact_registered` and `research_artifacts` events. Everything comes from SQLite, so lineage survives a
|
|
847
|
+
restart; a task accepted before this version has no `execution`, `parent`
|
|
848
|
+
or `children`, but still lists its model attempts, tools and artifacts.
|
|
849
|
+
The `/stream` events are unchanged apart from `accepted`.
|
|
850
|
+
|
|
417
851
|
## Plugins
|
|
418
852
|
|
|
419
853
|
A plugin is an ES module whose default export (or named `plugin` export) is an
|
|
@@ -497,6 +931,55 @@ Additional hooks support extensions that retain an existing workflow contract:
|
|
|
497
931
|
| `channelAdapter` | Replaces one enabled built-in channel consumer. Multiple owners are refused. Intake and delivery receive separate abort signals. |
|
|
498
932
|
| `httpRoutes` | Adds explicit compatibility paths; overlapping core routes and authentication-boundary changes are refused. |
|
|
499
933
|
|
|
934
|
+
### Lifecycle hooks
|
|
935
|
+
|
|
936
|
+
Message and tool lifecycle hooks let one extension follow a channel message
|
|
937
|
+
from receipt to delivery, and a tool call from invocation to its result or
|
|
938
|
+
cancellation, without replacing a channel adapter. Every hook is optional and
|
|
939
|
+
may be asynchronous. Each one gets a frozen copy of what it observes, and each
|
|
940
|
+
must settle within 5 seconds.
|
|
941
|
+
|
|
942
|
+
| Hook | When | Permitted | On a throw, rejection or timeout |
|
|
943
|
+
| --- | --- | --- | --- |
|
|
944
|
+
| `messageReceived(ctx, message)` | A built-in Telegram or Mattermost consumer has claimed a new, authenticated message, before command or task handling | Observe | Recorded; handling continues |
|
|
945
|
+
| `messagePersisted(ctx, message, task)` | The message's task is accepted and bound to it, before it runs | Observe | Recorded; the task runs |
|
|
946
|
+
| `transformOutbound(ctx, delivery)` | A reply is recorded for delivery, before it is sent | Return `{ text }` (1 byte to 64 KiB, not blank) to replace the text; return nothing to keep it. Transformations chain. When the text changes, the task journal records `outbound_transformed` with the sent text | The **original** text is sent, discarding every transformation; recorded |
|
|
947
|
+
| `messageDelivered(ctx, delivery, outcome)` | The delivery is recorded `sent`, `failed` or `unknown` | Observe | Recorded |
|
|
948
|
+
| `beforeToolCall(ctx, call)` | After context scoping, argument validation, the `tool_attempt` journal entry and team admission, before the tool is invoked | Return `{ deny: { code, message } }` to deny; the result is `{ ok: false, code, message, effect: 'none' }` and the journal records `tool_denied_by_plugin`. Anything else is ignored | The call is denied (`TOOL_DENIED_BY_PLUGIN`); recorded |
|
|
949
|
+
| `afterToolCall(ctx, call, result)` | The result is journaled, successful or not | Observe | Recorded; the task continues |
|
|
950
|
+
| `toolCallCancelled(ctx, call, { dispatched, effect })` | On cancellation, for calls not yet dispatched (`dispatched: false`, `effect: 'none'`) and calls in flight (`dispatched: true`; `effect: 'unknown'` unless the tool is `read`). Runs before `taskSettled` | Clean up | Recorded |
|
|
951
|
+
|
|
952
|
+
`message` is `{ platform, account, update_id, channel_type, caller, session_key,
|
|
953
|
+
received_ms, execution? }` and carries no message text. `delivery` is
|
|
954
|
+
`{ delivery_id, task_id, platform, account, update_id, text, attempt }`.
|
|
955
|
+
`call` is `{ task_id, call_id, name, arguments, effect, idempotency_key,
|
|
956
|
+
execution? }` with the validated arguments. `ctx.execution` and `execution` are
|
|
957
|
+
attribution for the causal tree a task belongs to (see
|
|
958
|
+
[Execution ancestry](#execution-ancestry)); they never grant access. They are
|
|
959
|
+
set for every task accepted by this version, and absent for older tasks and for
|
|
960
|
+
a channel `message`, which has no task yet.
|
|
961
|
+
|
|
962
|
+
Order: `before*` and `transform*` hooks run in plugin registration order, and
|
|
963
|
+
the first denial wins. Observers also run in registration order. Cleanup hooks
|
|
964
|
+
(`toolCallCancelled`, `taskSettled`, `drain`, `close`) run in reverse
|
|
965
|
+
registration order.
|
|
966
|
+
|
|
967
|
+
A failed hook is recorded as a `plugin_hook_failed` task event `{ plugin, hook }`.
|
|
968
|
+
For a message that never creates a task (a command such as `/help`), the
|
|
969
|
+
failure is recorded against the message's identity instead
|
|
970
|
+
(`runtime.store.pluginHookFailures(platform, account, update_id)`). An observer
|
|
971
|
+
failure never fails the task or the delivery. This includes
|
|
972
|
+
`observeToolResult`: a throwing `observeToolResult` is recorded and no longer
|
|
973
|
+
fails the task.
|
|
974
|
+
|
|
975
|
+
The hooks cannot widen authority. Context and mission scoping, plugin
|
|
976
|
+
`taskTools` and `filterTool`, and argument validation all happen before
|
|
977
|
+
`beforeToolCall`, which can only deny. A hook cannot change the arguments, the
|
|
978
|
+
result, the declared effect or the effect accounting, and `transformOutbound`
|
|
979
|
+
can change only the text of a reply that Ardent already decided to send.
|
|
980
|
+
Message hooks run for the built-in consumers; a plugin `channelAdapter` that
|
|
981
|
+
replaces one owns its own intake.
|
|
982
|
+
|
|
500
983
|
An envelope extension uses `mission.extensions[plugin.name]` and action names
|
|
501
984
|
`extension:<plugin-name>:<action>`. No extension is accepted without its configured
|
|
502
985
|
validator. A codec may retain an old wire action while translating it into its
|
|
@@ -514,6 +997,13 @@ share a bounded per-plugin rate bucket (600/minute, burst 120), applied before
|
|
|
514
997
|
handler authentication and parsing. Wildcard routes and middleware mounts are
|
|
515
998
|
refused so an extension cannot intercept unrelated core requests.
|
|
516
999
|
|
|
1000
|
+
HTTP mounts may set `rateLimit: { perMinute, burst }` for their authentication
|
|
1001
|
+
boundary. Defaults are 600 requests per minute and a burst of 120. Limits must be
|
|
1002
|
+
positive integers no greater than 6000 and 1200 respectively. All mounts from one
|
|
1003
|
+
plugin in the same boundary must agree; management and independent ingress retain
|
|
1004
|
+
separate buckets. This capacity is trusted plugin policy and grants no authentication
|
|
1005
|
+
or task authority. The one MiB body limit remains in force.
|
|
1006
|
+
|
|
517
1007
|
Offline job-validation contexts expose `runtimeAvailable: false`; their runtime
|
|
518
1008
|
and tool registry getters throw. CLI extensions receive `rawArgs` for their own
|
|
519
1009
|
option grammar, declare `valueOptions` to recognize values before the command, and can use `matches(invocation)` to select one subcommand while
|
|
@@ -553,16 +1043,14 @@ npm run lint
|
|
|
553
1043
|
npm test
|
|
554
1044
|
npm run build
|
|
555
1045
|
npm run openapi:check
|
|
556
|
-
npm run pack:check # packs, installs, and smoke-tests
|
|
1046
|
+
npm run pack:check # packs, installs, and smoke-tests both tarballs
|
|
557
1047
|
npm run verify # every gate CI runs, in order
|
|
558
1048
|
```
|
|
559
1049
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
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).
|
|
1050
|
+
The repository is an npm workspace: `client/` is `@hivemagnus/ardent-client`,
|
|
1051
|
+
which carries Ardent's version. `npm run release:version -- X.Y.Z` bumps both,
|
|
1052
|
+
and `npm run version:check` (part of verify) fails when they differ. One
|
|
1053
|
+
`vX.Y.Z` tag publishes the runtime and then the client.
|
|
566
1054
|
|
|
567
1055
|
### Interoperability checks
|
|
568
1056
|
|
|
@@ -580,9 +1068,9 @@ explicitly enables `hermes_compat` and allows its combined functional workload
|
|
|
580
1068
|
through the fixture's rate buckets. Default throttling remains covered by the
|
|
581
1069
|
separate rate-limit tests.
|
|
582
1070
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
1071
|
+
See [AGENTS.md](AGENTS.md) for contributor guidance.
|
|
1072
|
+
|
|
1073
|
+
## License
|
|
1074
|
+
|
|
1075
|
+
Apache-2.0. The vendored A2A protocol definition in `protocol/` carries its own
|
|
1076
|
+
license, [`protocol/LICENSE-A2A.txt`](protocol/LICENSE-A2A.txt).
|