@hivemagnus/ardent 2.0.0 → 2.1.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/README.md CHANGED
@@ -73,6 +73,37 @@ ardent gateway run # management API, A2A, channels, jobs
73
73
 
74
74
  `ardent help` lists every command.
75
75
 
76
+ ### Native suite artifact
77
+
78
+ Build `packages/ardent/Dockerfile` from the repository root, then select that
79
+ reviewed immutable image ID or digest:
80
+
81
+ ```bash
82
+ npm run build:native-agent -- --product ardent --image PINNED_IMAGE --output NEW_DIRECTORY
83
+ ```
84
+
85
+ The archive includes the exact Node binary, the public Ardent package, locked
86
+ production dependencies and their licenses. It contains no inference runtime or
87
+ models. The descriptor supplies literal launch arguments, an exact version
88
+ preflight and a read-only acceptance command for Hive's signed release matrix.
89
+ Local export does not publish or certify an artifact.
90
+
91
+ Select an existing profile explicitly with `--profile-path` and keep credentials
92
+ in an owned, mode `0600` environment file selected with `--env-file`. The native
93
+ launcher loads that file before Node starts, including `NODE_EXTRA_CA_CERTS`
94
+ when a private CA is required. It never evaluates the file as shell code.
95
+ Profile initialization is a separate operator action and refuses an existing
96
+ profile. Provider sign-in remains explicit.
97
+
98
+ `ardent --env-file FILE --profile-path DIR acceptance` checks the running
99
+ gateway's authenticated status, exact version, profile, backend and dependency
100
+ readiness. It returns bounded JSON without credentials or upstream diagnostics.
101
+ The default target is the profile's loopback management listener; an optional
102
+ `ARDENT_ACCEPTANCE_URL` must be an HTTPS origin, with an optional protected
103
+ `ARDENT_ACCEPTANCE_CA_FILE`. Redirects and nonlocal cleartext are refused.
104
+ Acceptance executes no model generation or tools. Verify scoped inference,
105
+ memory, skills and channel workflows separately before enabling consumers.
106
+
76
107
  ## Configuration
77
108
 
78
109
  `config.yaml` (schema 1) is validated strictly; unknown keys are rejected. A
@@ -0,0 +1,14 @@
1
+ import type { ArdentConfig } from './config.js';
2
+ /** Explicit installer files must be private, local and owned; values never leave the process. */
3
+ export declare function readProtectedFile(path: string): Promise<Buffer>;
4
+ /** Read-only check. Provider generation and effectful tools require separate explicit acceptance. */
5
+ export declare function acceptRuntime(config: ArdentConfig, env: NodeJS.ProcessEnv): Promise<{
6
+ ok: true;
7
+ version: string;
8
+ profile: string;
9
+ backend: string;
10
+ } | {
11
+ ok: false;
12
+ version: string;
13
+ reason: string;
14
+ }>;
@@ -0,0 +1,72 @@
1
+ import { request as httpRequest } from 'node:http';
2
+ import { request as httpsRequest } from 'node:https';
3
+ import { lstat, readFile } from 'node:fs/promises';
4
+ import { z } from 'zod';
5
+ import { ARDENT_VERSION } from './version.js';
6
+ /** Explicit installer files must be private, local and owned; values never leave the process. */
7
+ export async function readProtectedFile(path) {
8
+ const stat = await lstat(path);
9
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.uid !== process.getuid?.() ||
10
+ (stat.mode & 0o077) !== 0 || stat.size > 1024 * 1024)
11
+ throw new Error('Protected runtime file must be an owned private regular file');
12
+ return readFile(path);
13
+ }
14
+ const Status = z.object({ version: z.literal(ARDENT_VERSION), profile: z.string(),
15
+ backend: z.enum(['llamacpp', 'codex']) });
16
+ const Readiness = z.object({ status: z.literal('ready'), problems: z.array(z.string()).length(0) });
17
+ async function json(url, headers, ca) {
18
+ return new Promise((resolve, reject) => {
19
+ const request = (url.protocol === 'https:' ? httpsRequest : httpRequest)(url, { headers, ...(ca ? { ca } : {}), timeout: 5000 }, response => {
20
+ if (response.statusCode !== 200) {
21
+ response.resume();
22
+ reject(new Error('Acceptance endpoint refused the request'));
23
+ return;
24
+ }
25
+ const chunks = [];
26
+ let bytes = 0;
27
+ response.on('data', (chunk) => {
28
+ bytes += chunk.length;
29
+ if (bytes > 1024 * 1024) {
30
+ response.destroy();
31
+ reject(new Error('Acceptance response exceeds its bound'));
32
+ }
33
+ else
34
+ chunks.push(chunk);
35
+ });
36
+ response.on('error', reject);
37
+ response.on('end', () => {
38
+ try {
39
+ resolve(JSON.parse(Buffer.concat(chunks).toString()));
40
+ }
41
+ catch {
42
+ reject(new Error('Acceptance endpoint returned invalid JSON'));
43
+ }
44
+ });
45
+ });
46
+ request.on('timeout', () => request.destroy(new Error('Acceptance endpoint timed out')));
47
+ request.on('error', reject);
48
+ request.end();
49
+ });
50
+ }
51
+ /** Read-only check. Provider generation and effectful tools require separate explicit acceptance. */
52
+ export async function acceptRuntime(config, env) {
53
+ try {
54
+ const host = config.api.host === '::1' ? '[::1]' : config.api.host;
55
+ const endpoint = new URL(env.ARDENT_ACCEPTANCE_URL ?? `http://${host}:${config.api.port}`);
56
+ if (endpoint.username || endpoint.password || endpoint.search || endpoint.hash || endpoint.pathname !== '/' ||
57
+ (endpoint.protocol !== 'https:' && !(endpoint.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(endpoint.hostname))))
58
+ throw new Error('Acceptance requires verified HTTPS or the local loopback management listener');
59
+ const token = env[config.api.token_env];
60
+ if (!token || /[\r\n]/.test(token))
61
+ throw new Error('Management authentication is missing');
62
+ const ca = env.ARDENT_ACCEPTANCE_CA_FILE ? await readProtectedFile(env.ARDENT_ACCEPTANCE_CA_FILE) : undefined;
63
+ const status = Status.parse(await json(new URL('/api/v1/status', endpoint), { Authorization: `Bearer ${token}` }, ca));
64
+ if (status.profile !== config.profile || status.backend !== config.execution.backend)
65
+ throw new Error('Selected profile differs from the running gateway');
66
+ Readiness.parse(await json(new URL('/health/ready', endpoint), {}, ca));
67
+ return { ok: true, version: ARDENT_VERSION, profile: status.profile, backend: status.backend };
68
+ }
69
+ catch {
70
+ return { ok: false, version: ARDENT_VERSION, reason: 'Runtime authentication, version, profile or dependency readiness did not pass' };
71
+ }
72
+ }
package/dist/api.js CHANGED
@@ -78,7 +78,7 @@ export function ardentOpenApi() {
78
78
  '/api/v1/tasks/{id}/stream': { get: { operationId: 'streamTaskEvents', security: [{ bearerAuth: [] }], parameters: [{ in: 'path', name: 'id', required: true, schema: { type: 'string' } }, { in: 'query', name: 'after', schema: { type: 'integer', minimum: 0 } }, { in: 'header', name: 'Last-Event-ID', description: 'Resume after a journal sequence', schema: { type: 'integer', minimum: 0 } }], responses: { '200': { description: 'SSE task.event carries TaskEvent JSON; task.done carries Task JSON', content: { 'text/event-stream': { schema: { type: 'string' }, example: sseExample } } }, '404': { description: 'Task absent' } } } },
79
79
  '/api/v1/tasks/{id}/cancel': { post: { operationId: 'cancelTask', security: [{ bearerAuth: [] }], parameters: [{ in: 'path', name: 'id', required: true, schema: { type: 'string' } }], responses: { '200': { description: 'Cancellation requested' } } } },
80
80
  '/api/v1/artifacts/{id}': { get: { operationId: 'getArtifact', security: [{ bearerAuth: [] }], parameters: [{ in: 'path', name: 'id', required: true, schema: { type: 'string' } }], responses: { '200': { description: 'Artifact bytes' }, '404': { description: 'Artifact absent' } } } },
81
- '/api/v1/status': { get: { operationId: 'getOperationalStatus', security: [{ bearerAuth: [] }], responses: { '200': jsonResponse('Active profile summary', z.object({ profile: z.string(), backend: z.enum(['llamacpp', 'codex']), tasks: z.number().int() })) } } },
81
+ '/api/v1/status': { get: { operationId: 'getOperationalStatus', security: [{ bearerAuth: [] }], responses: { '200': jsonResponse('Active profile summary', z.object({ version: z.string(), profile: z.string(), backend: z.enum(['llamacpp', 'codex']), tasks: z.number().int() })) } } },
82
82
  '/api/v1/jobs/definitions/status': { get: { operationId: 'getJobDefinitionsStatus', security: [{ bearerAuth: [] }], responses: { '200': { description: 'Active profile job definition revision, digest, and redacted window status' }, '503': { description: 'Job engine unavailable' } } } },
83
83
  '/api/v1/profile': { get: { operationId: 'getProfile', security: [{ bearerAuth: [] }], responses: { '200': jsonResponse('Profile identity and path', z.object({ profile: z.string(), name: z.string(), product: z.string(), timezone: z.string(), path: z.string() })) } } },
84
84
  '/api/v1/config': { get: { operationId: 'getConfig', security: [{ bearerAuth: [] }], responses: { '200': jsonResponse('Raw YAML and revision; secrets remain references', z.object({ revision: z.string(), text: z.string() })) } }, put: { operationId: 'saveConfig', security: [{ bearerAuth: [] }], requestBody: { required: true, content: { 'application/json': { schema: jsonSchema(ConfigEdit) } } }, responses: { '200': jsonResponse('Saved; activation required', z.object({ revision: z.string(), activation_required: z.boolean() })), '409': { description: 'Revision conflict' } } } },
@@ -177,7 +177,7 @@ export function createArdentApi(runtime, loaded, env = process.env, jobEngine) {
177
177
  return c.json({ error: { code: 'UNAUTHORIZED', message: 'Bearer token required' } }, 401);
178
178
  return next();
179
179
  });
180
- app.get('/api/v1/status', c => c.json({ profile: runtime.config.profile, backend: runtime.config.execution.backend, tasks: runtime.store.list(10).length }));
180
+ app.get('/api/v1/status', c => c.json({ version: ARDENT_VERSION, profile: runtime.config.profile, backend: runtime.config.execution.backend, tasks: runtime.store.list(10).length }));
181
181
  app.get('/api/v1/jobs/definitions/status', async (c) => {
182
182
  if (!jobEngine)
183
183
  throw new Error('Job engine is unavailable');
package/dist/cli.js CHANGED
@@ -29,10 +29,12 @@ import { acquireGatewayLock, createLockFile } from './gateway-lock.js';
29
29
  import { ContextCheckpoints } from './context-checkpoints.js';
30
30
  import { loadModelPolicy } from './model-policy.js';
31
31
  import { loadPlugins, pluginContext, pluginJobHandlers, validationContext } from './plugins.js';
32
+ import { ARDENT_VERSION } from './version.js';
33
+ import { acceptRuntime, readProtectedFile } from './acceptance.js';
32
34
  function args(argv) {
33
35
  const words = [];
34
36
  const options = new Map();
35
- const valued = new Set(['profile', 'profile-path', 'api-port', 'template', 'prompt', 'prompt-file', 'idempotency-key', 'session-id', 'login-id', 'source', 'schedule-id', 'window-key', 'release-id', 'caller', 'context', 'expected-head', 'expected-policy-revision']);
37
+ const valued = new Set(['env-file', 'profile', 'profile-path', 'api-port', 'template', 'prompt', 'prompt-file', 'idempotency-key', 'session-id', 'login-id', 'source', 'schedule-id', 'window-key', 'release-id', 'caller', 'context', 'expected-head', 'expected-policy-revision']);
36
38
  for (let i = 0; i < argv.length; i++) {
37
39
  const arg = argv[i];
38
40
  if (!arg)
@@ -62,16 +64,16 @@ function value(options, name) {
62
64
  const found = options.get(name);
63
65
  return typeof found === 'string' ? found : undefined;
64
66
  }
65
- async function environment(dir) {
67
+ async function environment(dir, explicitFile) {
66
68
  const env = { ...process.env };
67
69
  try {
68
- const data = parse(await readFile(join(dir, '.env')));
70
+ const data = parse(explicitFile ? await readProtectedFile(explicitFile) : await readFile(join(dir, '.env')));
69
71
  for (const [name, val] of Object.entries(data))
70
72
  if (env[name] === undefined)
71
73
  env[name] = val;
72
74
  }
73
75
  catch (error) {
74
- if (!(error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT'))
76
+ if (explicitFile || !(error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT'))
75
77
  throw error;
76
78
  }
77
79
  return env;
@@ -98,9 +100,11 @@ async function assertNoGateway(dir) {
98
100
  throw error;
99
101
  }
100
102
  }
101
- const USAGE = `Usage: ardent [--profile NAME | --profile-path DIR] <command>
103
+ const USAGE = `Usage: ardent [--env-file FILE] [--profile NAME | --profile-path DIR] <command>
102
104
 
103
105
  Commands:
106
+ --version Print the independent product version
107
+ acceptance Verify the authenticated running gateway
104
108
  init --non-interactive [--api-port N] Create a profile from the bundled template
105
109
  profile list | profile show List profiles / show the selected profile
106
110
  config validate | show | schema Inspect configuration
@@ -123,6 +127,10 @@ Commands:
123
127
  async function main() {
124
128
  const parsed = args(process.argv.slice(2));
125
129
  const [command, subcommand, id] = parsed.words;
130
+ if (parsed.options.has('version')) {
131
+ stdout.write(`${ARDENT_VERSION}\n`);
132
+ return;
133
+ }
126
134
  if (!command || command === 'help' || parsed.options.has('help')) {
127
135
  stdout.write(`${USAGE}\n`);
128
136
  return;
@@ -144,7 +152,14 @@ async function main() {
144
152
  return;
145
153
  }
146
154
  const loaded = await loadConfig(dir);
147
- const env = await environment(dir);
155
+ const env = await environment(dir, value(parsed.options, 'env-file'));
156
+ if (command === 'acceptance') {
157
+ const result = await acceptRuntime(loaded.config, env);
158
+ print(result);
159
+ if (!result.ok)
160
+ process.exitCode = 1;
161
+ return;
162
+ }
148
163
  const plugins = await loadPlugins(loaded.config, dir);
149
164
  for (const plugin of plugins) {
150
165
  const pluginCommand = command ? plugin.cliCommands?.[command] : undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ // Bootstrap the native runtime with the protected environment before Node reads
2
+ // startup-only settings such as NODE_EXTRA_CA_CERTS. No shell evaluation.
3
+ import { spawn } from 'node:child_process';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { parse } from 'dotenv';
6
+ import { readProtectedFile } from './acceptance.js';
7
+ try {
8
+ const args = process.argv.slice(2);
9
+ const index = args.indexOf('--env-file');
10
+ const env = { ...process.env };
11
+ if (index >= 0) {
12
+ const file = args[index + 1];
13
+ if (!file)
14
+ throw new Error('A protected environment file is required');
15
+ for (const [name, value] of Object.entries(parse(await readProtectedFile(file))))
16
+ if (env[name] === undefined)
17
+ env[name] = value;
18
+ }
19
+ const child = spawn(process.execPath, [fileURLToPath(new URL('./cli.js', import.meta.url)), ...args], { env, stdio: 'inherit' });
20
+ const forward = (signal) => { child.kill(signal); };
21
+ process.on('SIGINT', forward);
22
+ process.on('SIGTERM', forward);
23
+ child.on('error', () => { process.stderr.write('Ardent native process could not start\n'); process.exitCode = 1; });
24
+ child.on('close', (code) => {
25
+ process.off('SIGINT', forward);
26
+ process.off('SIGTERM', forward);
27
+ process.exitCode = code ?? 1;
28
+ });
29
+ }
30
+ catch {
31
+ process.stderr.write('Ardent native environment could not be loaded from an owned private file\n');
32
+ process.exitCode = 1;
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hivemagnus/ardent",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Headless TypeScript agent runtime with A2A, scheduled jobs, skills, chat channels, and a plugin API",
5
5
  "keywords": [
6
6
  "agent",