@hivemagnus/ardent-client 0.0.0-stage → 3.2.1

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ Ardent client
2
+ Copyright 2026 ChefTaco and contributors
3
+
4
+ This product includes software developed by ChefTaco and contributors
5
+ (https://github.com/ChefTaco/Ardent).
package/README.md CHANGED
@@ -1,3 +1,266 @@
1
- # Temporary Holding Version
1
+ # @hivemagnus/ardent-client
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The supported remote client for [Ardent](https://github.com/ChefTaco/Ardent)
4
+ profiles. It submits and follows tasks, reconnects dropped or rotated task
5
+ streams from their cursor, cancels, pauses and resumes tasks, drives execution
6
+ recovery decisions, reads lineage, and downloads artifacts with resumable,
7
+ digest-verified transfers.
8
+
9
+ It talks to a standalone Ardent management API directly, or to a
10
+ Magnus-managed profile through the Magnus Control API. It runs in Node.js 24+
11
+ and in modern browsers. It has no framework coupling, and its only runtime
12
+ dependency is [`@hivemagnus/hive-common`](https://www.npmjs.com/package/@hivemagnus/hive-common).
13
+
14
+ The client is versioned and released with Ardent: `@hivemagnus/ardent-client`
15
+ X.Y.Z matches the management API of `@hivemagnus/ardent` X.Y.Z. Its types are
16
+ generated from Ardent's OpenAPI document.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @hivemagnus/ardent-client
22
+ ```
23
+
24
+ ## Quick start
25
+
26
+ ```ts
27
+ import { createArdentClient, direct } from '@hivemagnus/ardent-client';
28
+
29
+ const ardent = createArdentClient({
30
+ transport: direct({ baseUrl: 'http://127.0.0.1:9910', getToken: () => process.env.ARDENT_TOKEN! }),
31
+ });
32
+
33
+ const { task_id } = await ardent.tasks.submit({ prompt: 'Summarize the release notes', idempotencyKey: 'notes-2026-11-24' });
34
+ const task = await ardent.tasks.follow(task_id, {
35
+ onEvent: event => console.log(event.sequence, event.kind),
36
+ onText: text => process.stdout.write(text.kind === 'delta' ? text.text : `\n${text.text}`),
37
+ });
38
+ console.log(task.state, task.result);
39
+ ```
40
+
41
+ Through Magnus, name the node and profile, and authenticate to Magnus:
42
+
43
+ ```ts
44
+ import { createArdentClient, viaMagnus } from '@hivemagnus/ardent-client';
45
+
46
+ const ardent = createArdentClient({
47
+ transport: viaMagnus({ baseUrl: 'https://magnus.example.com', nodeId: 'node-1', profile: 'assistant', getToken: () => session.token }),
48
+ });
49
+ ```
50
+
51
+ `baseUrl` is the Magnus origin; the client adds `/api/v1`. Behind a proxy that
52
+ serves Magnus's `/api/v1` under another path, such as a Hive console's
53
+ `/api/magnus`, give that path as `apiBase` instead (exactly one of the two):
54
+
55
+ ```ts
56
+ viaMagnus({ apiBase: 'https://console.example.com/api/magnus', nodeId: 'node-1', profile: 'assistant', getToken: () => session.token });
57
+ ```
58
+
59
+ `client/examples/cli.mjs` in the Ardent repository runs submit, follow and
60
+ download end to end:
61
+
62
+ ```bash
63
+ ARDENT_TOKEN=... node examples/cli.mjs --url http://127.0.0.1:9910 --prompt "Write the report" --out ./downloads
64
+ MAGNUS_TOKEN=... node examples/cli.mjs --magnus https://magnus.example.com --node node-1 --profile assistant --prompt "Write the report"
65
+ MAGNUS_TOKEN=... node examples/cli.mjs --magnus-api https://console.example.com/api/magnus --node node-1 --profile assistant --prompt "Write the report"
66
+ ```
67
+
68
+ ## API
69
+
70
+ ```ts
71
+ createArdentClient({ transport, execution?, signal?, retryPolicy? }): ArdentClient
72
+ direct({ baseUrl, getToken, headers?, fetch? }): ArdentTransport
73
+ viaMagnus({ baseUrl | apiBase, nodeId, profile, getToken, headers?, fetch? }): ArdentTransport
74
+
75
+ ardent.tasks.submit({ prompt, idempotencyKey?, sessionId?, execution?, signal? }): Promise<TaskAccepted>
76
+ ardent.tasks.get(id, { signal? }): Promise<Task>
77
+ ardent.tasks.list({ limit?, signal? }): Promise<Task[]>
78
+ ardent.tasks.events(id, { after?, signal? }): Promise<TaskEvent[]>
79
+ ardent.tasks.cancel(id, { signal? }): Promise<Task>
80
+ ardent.tasks.pause(id, { signal? }) / resume(id, { signal? }): Promise<TaskAdmission>
81
+ ardent.tasks.follow(id, { after?, onEvent?, onText?, onConnect?, signal? }): Promise<Task>
82
+
83
+ ardent.sessions.list({ context?, signal? }): Promise<Session[]>
84
+ ardent.sessions.open(key, { context?, reset?, signal? }): Promise<Session>
85
+ ardent.sessions.messages(id, { signal? }): Promise<SessionMessage[]>
86
+
87
+ ardent.recovery.get(id, { signal? }): Promise<Recovery | null>
88
+ ardent.recovery.decide(id, { action, callId?, result?, note?, deadlineSeconds? }, { signal? }): Promise<Recovery>
89
+ ardent.lineage(id, { signal? }): Promise<Lineage>
90
+
91
+ ardent.artifacts.list(taskId, { signal? }): Promise<ArtifactRecord[]>
92
+ ardent.artifacts.manifest(sha, { v2?, signal? }): Promise<ArtifactRecord | ArtifactRecordV2>
93
+ ardent.artifacts.renditions(sha, { signal? }): Promise<ArtifactRendition[]>
94
+ ardent.artifacts.download(sha, { rendition?, resumeFrom?, onProgress?, signal?, maxResumes? }): Promise<ArtifactDownload>
95
+ ardent.artifacts.import({ peer_id, a2a_task_id, artifact_id, task_id? }, { signal? }): Promise<{ import_id }>
96
+ ardent.artifacts.imports({ limit?, signal? }) / importStatus(id, { signal? })
97
+
98
+ ardent.status({ signal? }): Promise<OperationalStatus>
99
+ ardent.capabilities({ signal? }): Promise<ArdentCapabilities>
100
+ ```
101
+
102
+ Response types (`Task`, `Recovery`, `Lineage`, `ArtifactRecord` and the rest)
103
+ are the documented response bodies, and `paths`, `operations` and
104
+ `components` are exported for anything else in the API.
105
+
106
+ ### Following a task
107
+
108
+ `tasks.follow` reads `GET /api/v1/tasks/{id}/stream` until `task.done` and then
109
+ returns the task. Ardent closes a stream after 60 seconds, and networks drop
110
+ connections; the client reconnects with the last event sequence (`after` and
111
+ `Last-Event-ID`), so every journaled event reaches `onEvent` once and in order.
112
+ Live reply text (`onText`) is not journaled: after a reconnect a `text`
113
+ snapshot of the current step replaces what the `delta`s built up. To resume a
114
+ follow later, pass the last `event.sequence` you handled as `after`.
115
+
116
+ ### Downloads
117
+
118
+ `artifacts.download(sha)` returns `{ stream, sha256, size, offset, mime, filename }`.
119
+ The stream pulls `GET /api/v1/artifacts/{sha256}/content` with bounded memory
120
+ and hashes the bytes as they pass. When the connection drops it resumes with
121
+ `Range` and `If-Range` (up to `maxResumes`, default 5). It closes only after
122
+ the whole file hashed to the artifact's SHA-256; otherwise it errors with
123
+ `DigestMismatchError`, and you must discard the bytes.
124
+
125
+ To continue a download that an earlier process or page started, pass the
126
+ bytes you kept as `resumeFrom` (a `Blob`, `ArrayBuffer`, typed array,
127
+ `ReadableStream` or async iterable). They are hashed again as a stream, and the
128
+ transfer continues after them, so the final check still covers the whole file.
129
+ The stream then yields only the remaining bytes, starting at `offset`.
130
+
131
+ ```ts
132
+ // Node: write to a partial file and keep it only once the stream closed verified.
133
+ import { createWriteStream } from 'node:fs';
134
+ import { rename } from 'node:fs/promises';
135
+ import { Writable } from 'node:stream';
136
+
137
+ const download = await ardent.artifacts.download(sha, { onProgress: p => console.log(p.received, '/', p.total) });
138
+ await download.stream.pipeTo(Writable.toWeb(createWriteStream('report.pdf.partial')));
139
+ await rename('report.pdf.partial', 'report.pdf');
140
+ ```
141
+
142
+ ```ts
143
+ // Browser: collect into a Blob and hand it to the user.
144
+ const download = await ardent.artifacts.download(sha);
145
+ const blob = await new Response(download.stream).blob();
146
+ ```
147
+
148
+ `rendition: { purpose: 'display' | 'model_input' | 'download', maxBytes?, acceptMime?, needsAlpha? }`
149
+ picks a preview or model-input rendition with HiveCommon's `selectRendition`;
150
+ `download` always resolves to the original.
151
+
152
+ ### Recovery decisions
153
+
154
+ A task interrupted with an unsettled external effect is held `unknown` with a
155
+ recovery status `awaiting_decision`. `recovery.get(id)` returns it (or `null`
156
+ for a task that was never interrupted), and `recovery.decide(id, { action })`
157
+ records `mark_applied`, `mark_not_applied`, `retry_with_new_deadline` or
158
+ `abandon`. The work continues as a linked continuation task:
159
+
160
+ ```ts
161
+ const recovery = await ardent.recovery.get(id);
162
+ if (recovery?.status === 'awaiting_decision') {
163
+ const decided = await ardent.recovery.decide(id, { action: 'mark_applied', result: { written: true }, note: 'Checked the target system' });
164
+ await ardent.tasks.follow(decided.continuation_task_id!);
165
+ }
166
+ ```
167
+
168
+ Repeating a decision returns the same outcome; a different decision raises
169
+ `ConflictError`.
170
+
171
+ ### Execution context
172
+
173
+ `execution` (an execution context v1 from `@hivemagnus/hive-common/execution`)
174
+ is sent with every submission, on the client or per `submit`. It is attribution
175
+ only and never grants access. Ardent records it as the task's parent; through
176
+ Magnus it is passed on only when Magnus advertises it, and otherwise dropped,
177
+ never failing the submission.
178
+
179
+ ## Authentication, retries and cancellation
180
+
181
+ - `getToken({ refresh })` is called for every request. After a `401` it is
182
+ called once more with `refresh: true`; a second `401` raises
183
+ `UnauthorizedError`. Cache the token yourself if fetching it is expensive.
184
+ - Reads, and direct submissions, cancels, pauses, resumes and recovery
185
+ decisions (which Ardent makes idempotent), are repeated on network errors,
186
+ `408`, `425`, `429` and `5xx`, honouring `Retry-After`, `x-hive-retry:
187
+ exhausted` and the execution context's `deadline_ms`. `retryPolicy` tunes
188
+ it. Actions through Magnus are never repeated automatically: Magnus
189
+ requires an unconfirmed outcome to be inspected first.
190
+ - A submission without `idempotencyKey` gets a random one, so its retries are
191
+ safe. Magnus accepts only UUID keys; through Magnus another key is replaced
192
+ by a stable UUID derived from it.
193
+ - Every call takes an `AbortSignal`; the client's `signal` aborts them all.
194
+
195
+ ## Errors
196
+
197
+ Every error is an `ArdentClientError`, which extends HiveCommon's `HiveError`
198
+ (`status`, `code`, `details`, `requestId`).
199
+
200
+ | Error | When |
201
+ |---|---|
202
+ | `UnauthorizedError` | The token was refused, also after a refresh |
203
+ | `NotFoundError` | The task, session, artifact or import does not exist |
204
+ | `ConflictError` | The task's state refuses the request (a finished task cannot pause, a recovery was decided differently); `idempotency: true` when the idempotency key was used for different content |
205
+ | `UnsupportedCapabilityError` | The route is not available through this transport (`capability`, and `requiredVersion` / `installedVersion` when Magnus says) |
206
+ | `TransportError` | A network failure, a stream or download that could not be resumed, `502`/`503`/`504`, or a response that is not what the API documents |
207
+ | `DigestMismatchError` | The downloaded bytes do not hash to the artifact's SHA-256 (`expected`, `actual`) |
208
+
209
+ ## Node and browsers
210
+
211
+ | | Node.js 24+ | Modern browsers |
212
+ |---|---|---|
213
+ | Tasks, sessions, recovery, lineage, status | Yes | Yes |
214
+ | Task streams with reconnect (`fetch` + web streams, so headers carry the token) | Yes | Yes |
215
+ | Downloads: streaming, `Range` resume, SHA-256 verification | Yes | Yes |
216
+ | Resuming a download in a later process or page (`resumeFrom`) | Yes, from the partial file | Yes, from bytes you kept (for example a `Blob`); the client stores nothing across reloads |
217
+ | Writing to disk | With `node:fs` (see above) | Through your own `Blob` or File System Access code |
218
+
219
+ The default entry imports no Node built-ins. Cross-origin browser use needs the
220
+ server (or Magnus) to allow the origin with CORS, including the
221
+ `Authorization`, `Range`, `If-Range`, `Last-Event-ID` and `x-hive-execution`
222
+ request headers and the `Content-Range`, `ETag`, `Repr-Digest`,
223
+ `X-Content-SHA256` and `Content-Disposition` response headers.
224
+
225
+ ## Direct and through Magnus
226
+
227
+ Directly, every route is available. Through Magnus, only the routes Magnus
228
+ allows; the others raise `UnsupportedCapabilityError`. `capabilities()` reports
229
+ what is available, from the profile's `/status` and Magnus's installation
230
+ report.
231
+
232
+ | Client call | Ardent route | Through Magnus |
233
+ |---|---|---|
234
+ | `tasks.submit` | `POST /api/v1/tasks` | action `task-submit` (`execution` top level when Magnus advertises `lineage`) |
235
+ | `tasks.get`, `list`, `events` | `GET /api/v1/tasks[/{id}[/events]]` | read `tasks[/{id}[/events]]` |
236
+ | `tasks.cancel`, `pause`, `resume` | `POST /api/v1/tasks/{id}/cancel\|pause\|resume` | actions `task-cancel`, `task-pause`, `task-resume` (target: task ID) |
237
+ | `tasks.follow` | `GET /api/v1/tasks/{id}/stream` | `GET …/tasks/{id}/stream` relay |
238
+ | `sessions.list`, `messages` | `GET /api/v1/sessions[/{id}/messages]` | read `sessions[/{id}/messages]` |
239
+ | `sessions.open` | `POST /api/v1/sessions` | action `session-open` |
240
+ | `artifacts.list`, `manifest` | `GET /api/v1/tasks/{id}/artifacts`, `/api/v1/artifacts/{sha}/manifest` | reads |
241
+ | `recovery.get`, `lineage` | `GET /api/v1/tasks/{id}/recovery\|lineage` | reads, from Magnus 3.3.0 |
242
+ | `recovery.decide` | `POST /api/v1/tasks/{id}/recovery` | action `task-recovery` (target: task ID, body: the decision), from Magnus 3.3.0 |
243
+ | `artifacts.download` | `GET /api/v1/artifacts/{sha}/content` | `GET …/artifacts/{sha}/content` with Range, from Magnus 3.3.0 |
244
+ | `artifacts.renditions`, `manifest({ v2: true })`, `imports`, `importStatus` | `GET /api/v1/artifacts/{sha}/renditions\|manifest/v2`, `/api/v1/artifacts/imports[/{id}]` | reads, from Magnus 3.3.0 |
245
+ | `artifacts.import` | `POST /api/v1/artifacts/imports` | action `artifact-import`, from Magnus 3.3.0 |
246
+ | `status`, `capabilities` | `GET /api/v1/status` | read `status`, plus `GET /api/v1/ardent/installations/{nodeId}` |
247
+
248
+ Magnus reads are `GET {apiBase}/ardent/installations/{nodeId}/profiles/{profile}/{route}`
249
+ (`apiBase` is `{baseUrl}/api/v1` when `baseUrl` is given)
250
+ and actions `POST …/action` with `{ action, target?, body? }`; the client
251
+ unwraps Magnus's `{ success, data }` envelope. A route Magnus refuses (`403`,
252
+ `404`, or `400` for an action it does not know, while it does not advertise the
253
+ capability) and Magnus's `409 unsupported_capability` or `AGENT_UPGRADE_REQUIRED`
254
+ become `UnsupportedCapabilityError`. A linked service identity may need an
255
+ `x-acting-subject` header for some actions; pass it in `headers`.
256
+
257
+ ## Out of scope
258
+
259
+ The A2A protocol (peer agents calling Ardent's A2A surface) is out of scope; use
260
+ an A2A SDK such as `@a2a-js/sdk` for peer calls. Configuration, identity,
261
+ skills, peers, missions and previews are management concerns that Magnus and
262
+ the Ardent CLI handle; their routes are in the exported `paths` types.
263
+
264
+ ## License
265
+
266
+ Apache-2.0. See LICENSE and NOTICE.
@@ -0,0 +1,125 @@
1
+ import type { ExecutionContext } from '@hivemagnus/hive-common/execution';
2
+ import type { RetryPolicy } from '@hivemagnus/hive-common/retry';
3
+ import { type ArdentTransport } from './transport.js';
4
+ import { type FollowOptions } from './follow.js';
5
+ import { type ArtifactDownload, type DownloadOptions } from './download.js';
6
+ import type { ArtifactImport, ArtifactImportAccepted, ArtifactImportRequest, ArtifactRecord, ArtifactRecordV2, ArtifactRendition, Lineage, OperationalStatus, Recovery, RecoveryAction, Session, SessionContext, SessionMessage, Task, TaskAccepted, TaskAdmission, TaskEvent } from './types.js';
7
+ export interface ArdentClientOptions {
8
+ /** `direct({ baseUrl, getToken })` or `viaMagnus({ baseUrl | apiBase, nodeId, profile, getToken })`. */
9
+ readonly transport: ArdentTransport;
10
+ /** Execution context v1 sent with every submission (attribution only; it never grants access). */
11
+ readonly execution?: ExecutionContext;
12
+ /** Aborts every request of this client. */
13
+ readonly signal?: AbortSignal;
14
+ /** Retries of safe requests and reconnects of streams. Default: 3 attempts, 250 ms to 4 s. */
15
+ readonly retryPolicy?: RetryPolicy;
16
+ }
17
+ export interface CallOptions {
18
+ readonly signal?: AbortSignal;
19
+ }
20
+ export interface SubmitInput {
21
+ readonly prompt: string;
22
+ /**
23
+ * Makes the submission safe to repeat: the same key returns the same task. One is generated
24
+ * when omitted. Magnus accepts only UUID keys, so through Magnus another key is replaced by
25
+ * a stable UUID derived from it.
26
+ */
27
+ readonly idempotencyKey?: string;
28
+ readonly sessionId?: string;
29
+ /** Overrides the client's execution context for this task. */
30
+ readonly execution?: ExecutionContext;
31
+ readonly signal?: AbortSignal;
32
+ }
33
+ export interface RecoveryDecision {
34
+ readonly action: RecoveryAction;
35
+ /** The pending tool call the decision is about, when the task has more than one. */
36
+ readonly callId?: string;
37
+ /** With `mark_applied`: the tool's result, which must match its output schema. */
38
+ readonly result?: unknown;
39
+ readonly note?: string;
40
+ /** With `retry_with_new_deadline`. */
41
+ readonly deadlineSeconds?: number;
42
+ }
43
+ export interface FollowTaskOptions extends FollowOptions {
44
+ }
45
+ /** What a profile offers through this transport. */
46
+ export interface ArdentCapabilities {
47
+ readonly transport: 'direct' | 'magnus';
48
+ readonly version: string;
49
+ readonly profile: string;
50
+ readonly backend: string;
51
+ /** 2 when the profile serves artifact transfer v2 (Range, renditions, imports), else 1. */
52
+ readonly artifactTransfer: number;
53
+ /** Routes available through this transport. */
54
+ readonly features: {
55
+ readonly recovery: boolean;
56
+ readonly lineage: boolean;
57
+ /** The execution context reaches the profile on submissions. */
58
+ readonly execution: boolean;
59
+ readonly artifactContent: boolean;
60
+ readonly renditions: boolean;
61
+ readonly imports: boolean;
62
+ };
63
+ /** The Magnus installation report, when the transport is Magnus and it could be read. */
64
+ readonly magnus?: {
65
+ readonly capabilities: Readonly<Record<string, unknown>>;
66
+ readonly installedVersion: string | undefined;
67
+ };
68
+ }
69
+ export interface ArdentClient {
70
+ readonly tasks: {
71
+ submit(input: SubmitInput): Promise<TaskAccepted>;
72
+ get(id: string, options?: CallOptions): Promise<Task>;
73
+ list(options?: CallOptions & {
74
+ readonly limit?: number;
75
+ }): Promise<Task[]>;
76
+ events(id: string, options?: CallOptions & {
77
+ readonly after?: number;
78
+ }): Promise<TaskEvent[]>;
79
+ cancel(id: string, options?: CallOptions): Promise<Task>;
80
+ pause(id: string, options?: CallOptions): Promise<TaskAdmission>;
81
+ resume(id: string, options?: CallOptions): Promise<TaskAdmission>;
82
+ /** Follow the task's events until it finishes, across the 60 s stream rotation and dropped connections, and return the final task. */
83
+ follow(id: string, options?: FollowTaskOptions): Promise<Task>;
84
+ };
85
+ readonly sessions: {
86
+ list(options?: CallOptions & {
87
+ readonly context?: SessionContext;
88
+ }): Promise<Session[]>;
89
+ open(key: string, options?: CallOptions & {
90
+ readonly context?: SessionContext;
91
+ readonly reset?: boolean;
92
+ }): Promise<Session>;
93
+ messages(id: string, options?: CallOptions): Promise<SessionMessage[]>;
94
+ };
95
+ readonly recovery: {
96
+ /** The recovery status, or null for a task that was never interrupted. */
97
+ get(id: string, options?: CallOptions): Promise<Recovery | null>;
98
+ /** Decide a held task. The work continues as a linked continuation task (`continuation_task_id`). Repeating a decision returns the same outcome. */
99
+ decide(id: string, decision: RecoveryDecision, options?: CallOptions): Promise<Recovery>;
100
+ };
101
+ lineage(id: string, options?: CallOptions): Promise<Lineage>;
102
+ readonly artifacts: {
103
+ list(taskId: string, options?: CallOptions): Promise<ArtifactRecord[]>;
104
+ /** The manifest 1.0 record; `{ v2: true }` returns the 1.1 view with renditions and execution provenance. */
105
+ manifest(sha: string, options?: CallOptions & {
106
+ readonly v2?: false;
107
+ }): Promise<ArtifactRecord>;
108
+ manifest(sha: string, options: CallOptions & {
109
+ readonly v2: true;
110
+ }): Promise<ArtifactRecordV2>;
111
+ renditions(sha: string, options?: CallOptions): Promise<ArtifactRendition[]>;
112
+ download(sha: string, options?: DownloadOptions): Promise<ArtifactDownload>;
113
+ import(request: ArtifactImportRequest, options?: CallOptions): Promise<ArtifactImportAccepted>;
114
+ imports(options?: CallOptions & {
115
+ readonly limit?: number;
116
+ }): Promise<ArtifactImport[]>;
117
+ importStatus(id: string, options?: CallOptions): Promise<ArtifactImport>;
118
+ };
119
+ /** `GET /api/v1/status` of the profile. */
120
+ status(options?: CallOptions): Promise<OperationalStatus>;
121
+ /** What the profile offers through this transport, from its status and (through Magnus) the installation report. */
122
+ capabilities(options?: CallOptions): Promise<ArdentCapabilities>;
123
+ }
124
+ /** Create a client for one Ardent profile. */
125
+ export declare function createArdentClient(options: ArdentClientOptions): ArdentClient;