@vaernjs/vaern 0.0.0-stage → 0.0.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 +21 -0
- package/README.md +106 -2
- package/bin/vaern.cjs +209 -0
- package/index.d.ts +18 -0
- package/index.js +64 -0
- package/package.json +61 -4
- package/scripts/postinstall.cjs +89 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DEVLOGIX TECHNOLOGY (PRIVATE) LIMITED
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,107 @@
|
|
|
1
|
-
#
|
|
1
|
+
# vaern
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**An agent-native JavaScript & TypeScript runtime** — capability sandboxing, tool-calling, MCP, deterministic replay and sovereignty enforcement built into the engine, not bolted on as a library.
|
|
4
|
+
|
|
5
|
+
A DevLogix project · licensed MIT
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
> ### Status: pre-release placeholder (v0.0.1)
|
|
10
|
+
>
|
|
11
|
+
> This version reserves the name and provides a working CLI entry point.
|
|
12
|
+
>
|
|
13
|
+
> Running `vaern` today prints the roadmap. That is expected, not a bug. Run `vaern doctor` for install diagnostics.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g @vaernjs/vaern # global CLI
|
|
21
|
+
npx @vaernjs/vaern --version # without installing
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
From **v0.1.0** this pulls a single prebuilt binary for your platform via
|
|
25
|
+
`optionalDependencies`, the same way `bun` and `esbuild` do. Nothing is
|
|
26
|
+
downloaded in a `postinstall` script; the platform packages are ordinary npm
|
|
27
|
+
packages gated by `os` and `cpu`.
|
|
28
|
+
|
|
29
|
+
Supported platforms (v0.1.0+):
|
|
30
|
+
|
|
31
|
+
| Platform | Package |
|
|
32
|
+
|---|---|
|
|
33
|
+
| Linux x86_64 | `vaern-linux-x64` |
|
|
34
|
+
| Linux arm64 | `vaern-linux-arm64` |
|
|
35
|
+
| macOS arm64 | `vaern-darwin-arm64` |
|
|
36
|
+
| macOS x86_64 | `vaern-darwin-x64` |
|
|
37
|
+
| Windows x86_64 | `vaern-win32-x64` |
|
|
38
|
+
|
|
39
|
+
Install with `--no-optional` or on an unsupported platform and you get the JS
|
|
40
|
+
fallback, which explains itself instead of failing silently.
|
|
41
|
+
|
|
42
|
+
## What vaern will do
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// courier.ts
|
|
46
|
+
import { agent, tool } from "vaern:agent";
|
|
47
|
+
|
|
48
|
+
const traffic = tool({
|
|
49
|
+
name: "traffic",
|
|
50
|
+
schema: { city: "string", at: "string" },
|
|
51
|
+
run: async ({ city, at }) =>
|
|
52
|
+
(await fetch(`https://api.example.pk/v2/${city}?at=${at}`)).json(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const courier = agent({
|
|
56
|
+
name: "courier-copilot",
|
|
57
|
+
model: "any-openai-compatible-endpoint",
|
|
58
|
+
tools: [traffic],
|
|
59
|
+
sandbox: "vaern.toml", // capability policy, enforced by the engine
|
|
60
|
+
replay: "deterministic", // every effect journalled at the engine boundary
|
|
61
|
+
budget: { tokens: 250_000, usd: 5 }, // hard stop — not an alert
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log(await courier.run("Reroute today's Lahore deliveries around the fog."));
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
vaern run courier.ts
|
|
69
|
+
vaern audit export --run 7f3a --format sbp --sign
|
|
70
|
+
vaern replay 7f3a --diff
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Programmatic use
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
const { binaryPath, hasNativeBinary, vaern } = require("@vaernjs/vaern");
|
|
77
|
+
|
|
78
|
+
if (hasNativeBinary()) vaern(["run", "app.ts"]);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Roadmap
|
|
82
|
+
|
|
83
|
+
| | Milestone |
|
|
84
|
+
|---|---|
|
|
85
|
+
| **M1** | `vaern run hello.ts` — TypeScript, `fetch`, timers, `console`, HTTP server |
|
|
86
|
+
| **M2** | capability enforcer + `vaern.toml`; `node:fs` / `node:http` / `node:path` subset |
|
|
87
|
+
| **M3** | `agent()`, `tool()`, MCP client/server, budgets, effect journal, `vaern replay` |
|
|
88
|
+
| **M4** | residency egress guard, hash-chained audit, PK-PKI signing, `ur-PK` i18n |
|
|
89
|
+
| **M5** | honest public benchmarks (including losses), docs site, external production users |
|
|
90
|
+
|
|
91
|
+
We publish benchmarks we lose. A runtime that hides a benchmark is hiding something else.
|
|
92
|
+
|
|
93
|
+
## Licence
|
|
94
|
+
|
|
95
|
+
MIT License. Copyright (c) 2026 DEVLOGIX TECHNOLOGY (PRIVATE) LIMITED.
|
|
96
|
+
See [`LICENSE`](./LICENSE).
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
git clone https://github.com/vaernjs/vaern.git && cd vaern
|
|
102
|
+
npm install
|
|
103
|
+
npm run check # pre-publish validation
|
|
104
|
+
npm run pack:dry # inspect exactly what would be published
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Issues and pull requests welcome — we would rather be corrected now than wrong later.
|
package/bin/vaern.cjs
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* vaern — CLI entry point.
|
|
6
|
+
*
|
|
7
|
+
* Two modes, chosen at runtime:
|
|
8
|
+
*
|
|
9
|
+
* NATIVE A platform package (vaern-<os>-<arch>) shipped a real binary.
|
|
10
|
+
* We exec it and get out of the way, forwarding stdio, signals
|
|
11
|
+
* and the exit code. This is the normal path from v0.1.0.
|
|
12
|
+
*
|
|
13
|
+
* FALLBACK No binary for this platform yet (the v0.0.x placeholder
|
|
14
|
+
* releases, an unsupported platform, or `npm i --no-optional`).
|
|
15
|
+
* We serve a small built-in CLI so the command never dies with
|
|
16
|
+
* "command not found".
|
|
17
|
+
*
|
|
18
|
+
* Resolution order for the native binary:
|
|
19
|
+
* 1. $VAERN_BINARY (explicit override — used by CI and by `cargo run` during dev)
|
|
20
|
+
* 2. vaern-<os>-<arch> package (the normal npm install path)
|
|
21
|
+
* 3. ../vendor/vaern (repo-local build dropped in by `just build`)
|
|
22
|
+
* 4. FALLBACK
|
|
23
|
+
*
|
|
24
|
+
* NOTE ON STARTUP COST: this file is a Node script, so it costs ~40-70ms of
|
|
25
|
+
* interpreter startup before the native binary runs. `scripts/postinstall.cjs`
|
|
26
|
+
* removes that cost by re-pointing the bin link straight at the native binary
|
|
27
|
+
* when npm allows scripts to run. Both paths must stay working.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const { spawn } = require("node:child_process");
|
|
31
|
+
const fs = require("node:fs");
|
|
32
|
+
const path = require("node:path");
|
|
33
|
+
const { createRequire } = require("node:module");
|
|
34
|
+
|
|
35
|
+
const require_ = createRequire(__filename);
|
|
36
|
+
const pkg = require_("../package.json");
|
|
37
|
+
|
|
38
|
+
const EXE = process.platform === "win32" ? ".exe" : "";
|
|
39
|
+
const PLATFORM_PKG = `vaern-${process.platform}-${process.arch}`;
|
|
40
|
+
|
|
41
|
+
/* ------------------------------------------------------------------ */
|
|
42
|
+
/* native binary resolution */
|
|
43
|
+
/* ------------------------------------------------------------------ */
|
|
44
|
+
|
|
45
|
+
function firstExisting(candidates) {
|
|
46
|
+
for (const c of candidates) {
|
|
47
|
+
try {
|
|
48
|
+
if (c && fs.statSync(c).isFile()) return c;
|
|
49
|
+
} catch {
|
|
50
|
+
/* not there, keep looking */
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolveNativeBinary() {
|
|
57
|
+
// 1. explicit override
|
|
58
|
+
if (process.env.VAERN_BINARY) {
|
|
59
|
+
const p = path.resolve(process.env.VAERN_BINARY);
|
|
60
|
+
if (fs.existsSync(p)) return p;
|
|
61
|
+
process.stderr.write(
|
|
62
|
+
`vaern: $VAERN_BINARY is set but does not exist: ${p}\n`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 2. platform package installed by npm as an optionalDependency
|
|
67
|
+
try {
|
|
68
|
+
const manifest = require_.resolve(`${PLATFORM_PKG}/package.json`);
|
|
69
|
+
const dir = path.dirname(manifest);
|
|
70
|
+
const declared = require_(manifest).bin;
|
|
71
|
+
const rel =
|
|
72
|
+
typeof declared === "string"
|
|
73
|
+
? declared
|
|
74
|
+
: declared && (declared.vaern || Object.values(declared)[0]);
|
|
75
|
+
const found = firstExisting([
|
|
76
|
+
rel ? path.join(dir, rel) : null,
|
|
77
|
+
path.join(dir, "bin", `vaern${EXE}`),
|
|
78
|
+
path.join(dir, `vaern${EXE}`),
|
|
79
|
+
]);
|
|
80
|
+
if (found) return found;
|
|
81
|
+
} catch {
|
|
82
|
+
/* platform package not installed */
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 3. repo-local build (developer convenience)
|
|
86
|
+
return firstExisting([
|
|
87
|
+
path.join(__dirname, "..", "vendor", `vaern${EXE}`),
|
|
88
|
+
path.join(__dirname, "..", "..", "..", "target", "release", `vaern${EXE}`),
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* ------------------------------------------------------------------ */
|
|
93
|
+
/* native mode */
|
|
94
|
+
/* ------------------------------------------------------------------ */
|
|
95
|
+
|
|
96
|
+
function execNative(binary, args) {
|
|
97
|
+
const child = spawn(binary, args, {
|
|
98
|
+
stdio: "inherit",
|
|
99
|
+
// Never let Node inject anything into the child's environment.
|
|
100
|
+
env: process.env,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Forward termination signals so `vaern serve` shuts down cleanly on Ctrl-C.
|
|
104
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT", "SIGUSR1", "SIGUSR2"];
|
|
105
|
+
for (const sig of signals) {
|
|
106
|
+
if (sig in require("node:os").constants.signals || process.platform !== "win32") {
|
|
107
|
+
process.on(sig, () => {
|
|
108
|
+
try {
|
|
109
|
+
child.kill(sig);
|
|
110
|
+
} catch {
|
|
111
|
+
/* child already gone */
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
child.on("error", (err) => {
|
|
118
|
+
process.stderr.write(`vaern: failed to execute ${binary}: ${err.message}\n`);
|
|
119
|
+
process.exit(127);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
child.on("close", (code, signal) => {
|
|
123
|
+
if (signal) {
|
|
124
|
+
// Die the way the child died so shells and CI see the right cause.
|
|
125
|
+
try {
|
|
126
|
+
process.kill(process.pid, signal);
|
|
127
|
+
} catch {
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
process.exit(code === null ? 1 : code);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ------------------------------------------------------------------ */
|
|
137
|
+
/* fallback mode */
|
|
138
|
+
/* ------------------------------------------------------------------ */
|
|
139
|
+
|
|
140
|
+
const BANNER = `vaern ${pkg.version} — an agent-native JavaScript & TypeScript runtime
|
|
141
|
+
A DevLogix project · licensed MIT
|
|
142
|
+
`;
|
|
143
|
+
|
|
144
|
+
const ROADMAP = `
|
|
145
|
+
vaern is in active development.
|
|
146
|
+
|
|
147
|
+
M1 weeks 3-6 vaern run hello.ts — TypeScript, fetch, timers, console, HTTP server
|
|
148
|
+
M2 weeks 7-10 capability enforcer + vaern.toml (deny by default)
|
|
149
|
+
M3 weeks 11-14 agent(), tool(), MCP client/server, budgets, effect journal, vaern replay
|
|
150
|
+
M4 weeks 15-20 sovereignty: residency guard, hash-chained audit, PK-PKI signing, ur-PK i18n
|
|
151
|
+
M5 weeks 21-26 honest public benchmarks, docs, first external production users
|
|
152
|
+
|
|
153
|
+
Manifesto: https://github.com/vaernjs/vaern
|
|
154
|
+
Repository: ${pkg.repository ? String(pkg.repository.url).replace(/^git\+/, "") : "https://github.com/vaernjs/vaern"}
|
|
155
|
+
Issues: ${pkg.bugs ? pkg.bugs.url : ""}
|
|
156
|
+
|
|
157
|
+
This placeholder release exists to reserve the name on npm and to give the CLI
|
|
158
|
+
a working entry point. The native runtime binary lands in M1 (v0.1.0).
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
function fallback(args) {
|
|
162
|
+
const a = args[0];
|
|
163
|
+
|
|
164
|
+
if (a === undefined || a === "--help" || a === "-h" || a === "help") {
|
|
165
|
+
process.stdout.write(`${BANNER}\nUsage: vaern <command> [options]\n${ROADMAP}`);
|
|
166
|
+
process.exit(0);
|
|
167
|
+
}
|
|
168
|
+
if (a === "--version" || a === "-v" || a === "-V" || a === "version") {
|
|
169
|
+
process.stdout.write(`${pkg.version}\n`);
|
|
170
|
+
process.exit(0);
|
|
171
|
+
}
|
|
172
|
+
if (a === "roadmap") {
|
|
173
|
+
process.stdout.write(ROADMAP);
|
|
174
|
+
process.exit(0);
|
|
175
|
+
}
|
|
176
|
+
if (a === "doctor") {
|
|
177
|
+
process.stdout.write(`${BANNER}
|
|
178
|
+
platform: ${process.platform}-${process.arch}
|
|
179
|
+
expected package: ${PLATFORM_PKG}
|
|
180
|
+
node: ${process.version}
|
|
181
|
+
native binary: NOT PRESENT (placeholder release)
|
|
182
|
+
$VAERN_BINARY: ${process.env.VAERN_BINARY || "(unset)"}
|
|
183
|
+
|
|
184
|
+
Nothing is wrong. The native binary ships in v0.1.0 (milestone M1).
|
|
185
|
+
Until then, install is expected to fall back to this message.
|
|
186
|
+
`);
|
|
187
|
+
process.exit(0);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
process.stderr.write(
|
|
191
|
+
`${BANNER}
|
|
192
|
+
vaern: unknown command '${a}'
|
|
193
|
+
|
|
194
|
+
The native runtime binary is not available for ${process.platform}-${process.arch}
|
|
195
|
+
in this release. Expected platform package: ${PLATFORM_PKG}.
|
|
196
|
+
|
|
197
|
+
Try: vaern doctor show install diagnostics
|
|
198
|
+
vaern roadmap what is being built and when
|
|
199
|
+
vaern --help usage
|
|
200
|
+
`
|
|
201
|
+
);
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* ------------------------------------------------------------------ */
|
|
206
|
+
|
|
207
|
+
const binary = resolveNativeBinary();
|
|
208
|
+
if (binary) execNative(binary, process.argv.slice(2));
|
|
209
|
+
else fallback(process.argv.slice(2));
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChildProcess, SpawnOptions } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
/** Package version, e.g. "0.0.1". */
|
|
4
|
+
export declare const version: string;
|
|
5
|
+
|
|
6
|
+
/** Name of the platform package that carries the binary for this host, e.g. "vaern-linux-x64". */
|
|
7
|
+
export declare const platformPackage: string;
|
|
8
|
+
|
|
9
|
+
/** Absolute path to the native vaern binary, or null when this release has none. */
|
|
10
|
+
export declare function binaryPath(): string | null;
|
|
11
|
+
|
|
12
|
+
/** True when a native binary is available for the current platform. */
|
|
13
|
+
export declare function hasNativeBinary(): boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Spawn the vaern binary. Throws if no native binary is present for this platform.
|
|
17
|
+
*/
|
|
18
|
+
export declare function vaern(args?: string[], options?: SpawnOptions): ChildProcess;
|
package/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Programmatic API (minimal by design for v0).
|
|
5
|
+
*
|
|
6
|
+
* Most consumers want the CLI. This module exists so tools, editors and CI can
|
|
7
|
+
* locate the native binary without re-implementing the resolution logic.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require("node:fs");
|
|
11
|
+
const path = require("node:path");
|
|
12
|
+
const { spawn } = require("node:child_process");
|
|
13
|
+
const { createRequire } = require("node:module");
|
|
14
|
+
|
|
15
|
+
const require_ = createRequire(__filename);
|
|
16
|
+
const pkg = require_("./package.json");
|
|
17
|
+
|
|
18
|
+
const EXE = process.platform === "win32" ? ".exe" : "";
|
|
19
|
+
const PLATFORM_PKG = `vaern-${process.platform}-${process.arch}`;
|
|
20
|
+
|
|
21
|
+
/** Package name that should carry the binary for this platform, e.g. `vaern-linux-x64`. */
|
|
22
|
+
const platformPackage = PLATFORM_PKG;
|
|
23
|
+
|
|
24
|
+
/** Absolute path to the native binary, or null if this release has none. */
|
|
25
|
+
function binaryPath() {
|
|
26
|
+
if (process.env.VAERN_BINARY && fs.existsSync(process.env.VAERN_BINARY)) {
|
|
27
|
+
return path.resolve(process.env.VAERN_BINARY);
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const manifest = require_.resolve(`${PLATFORM_PKG}/package.json`);
|
|
31
|
+
const dir = path.dirname(manifest);
|
|
32
|
+
const declared = require_(manifest).bin;
|
|
33
|
+
const rel =
|
|
34
|
+
typeof declared === "string"
|
|
35
|
+
? declared
|
|
36
|
+
: declared && (declared.vaern || Object.values(declared)[0]);
|
|
37
|
+
const candidate = rel ? path.join(dir, rel) : path.join(dir, "bin", `vaern${EXE}`);
|
|
38
|
+
return fs.existsSync(candidate) ? candidate : null;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** True when a native binary is available for this platform. */
|
|
45
|
+
function hasNativeBinary() {
|
|
46
|
+
return binaryPath() !== null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Spawn the vaern binary. Returns the ChildProcess so callers control stdio.
|
|
51
|
+
* Throws if no native binary is present.
|
|
52
|
+
*/
|
|
53
|
+
function vaern(args = [], options = {}) {
|
|
54
|
+
const bin = binaryPath();
|
|
55
|
+
if (!bin) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`vaern: no native binary for ${process.platform}-${process.arch}. ` +
|
|
58
|
+
`Install the optional platform package \`${PLATFORM_PKG}\`, or set $VAERN_BINARY.`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return spawn(bin, args, { stdio: "inherit", ...options });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = { version: pkg.version, platformPackage, binaryPath, hasNativeBinary, vaern };
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaernjs/vaern",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Vaern — an agent-native JavaScript & TypeScript runtime with capability sandboxing, deterministic replay and sovereignty enforcement.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"runtime",
|
|
7
|
+
"javascript",
|
|
8
|
+
"typescript",
|
|
9
|
+
"agent",
|
|
10
|
+
"agents",
|
|
11
|
+
"mcp",
|
|
12
|
+
"sandbox",
|
|
13
|
+
"cli",
|
|
14
|
+
"vaern",
|
|
15
|
+
"devlogix"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "DEVLOGIX TECHNOLOGY (PRIVATE) LIMITED"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/vaernjs/vaern.git",
|
|
24
|
+
"directory": "packages/vaern"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/vaernjs/vaern/issues"
|
|
28
|
+
},
|
|
29
|
+
"type": "commonjs",
|
|
30
|
+
"main": "./index.js",
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./index.d.ts",
|
|
35
|
+
"default": "./index.js"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"bin": {
|
|
40
|
+
"vaern": "bin/vaern.cjs"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"bin/",
|
|
44
|
+
"index.js",
|
|
45
|
+
"index.d.ts",
|
|
46
|
+
"scripts/postinstall.cjs",
|
|
47
|
+
"README.md",
|
|
48
|
+
"LICENSE"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"postinstall": "node scripts/postinstall.cjs",
|
|
52
|
+
"prepublishOnly": "node ../../scripts/check-publish.mjs"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18.0.0"
|
|
56
|
+
},
|
|
57
|
+
"sideEffects": false,
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public",
|
|
60
|
+
"registry": "https://registry.npmjs.org/",
|
|
61
|
+
"tag": "latest"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* postinstall — OPTIONAL fast path. Never fails the install.
|
|
5
|
+
*
|
|
6
|
+
* npm links `bin/vaern` to our Node shim, which costs ~40-70ms of interpreter
|
|
7
|
+
* startup before the native binary runs. For a runtime CLI that is a real tax.
|
|
8
|
+
*
|
|
9
|
+
* When npm permits scripts to run, we re-point the bin link directly at the
|
|
10
|
+
* native binary so `vaern` starts at native speed. When scripts are disabled
|
|
11
|
+
* (`npm i --ignore-scripts`), nothing happens and the shim path still works.
|
|
12
|
+
*
|
|
13
|
+
* Guarantees:
|
|
14
|
+
* - exits 0 no matter what. A failed postinstall breaks the user's install.
|
|
15
|
+
* - POSIX only (symlink replacement). Windows keeps the shim; creating
|
|
16
|
+
* symlinks there needs privileges we will not assume.
|
|
17
|
+
* - opt out with VAERN_NO_LINK=1
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const fs = require("node:fs");
|
|
21
|
+
const path = require("node:path");
|
|
22
|
+
const { createRequire } = require("node:module");
|
|
23
|
+
|
|
24
|
+
function done(reason) {
|
|
25
|
+
if (process.env.VAERN_DEBUG_INSTALL) {
|
|
26
|
+
process.stdout.write(`vaern postinstall: ${reason}\n`);
|
|
27
|
+
}
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function main() {
|
|
32
|
+
if (process.env.VAERN_NO_LINK === "1") return done("disabled via VAERN_NO_LINK");
|
|
33
|
+
if (process.platform === "win32") return done("windows — keeping the JS shim");
|
|
34
|
+
|
|
35
|
+
const require_ = createRequire(__filename);
|
|
36
|
+
const platformPkg = `vaern-${process.platform}-${process.arch}`;
|
|
37
|
+
|
|
38
|
+
let binary;
|
|
39
|
+
try {
|
|
40
|
+
const manifest = require_.resolve(`${platformPkg}/package.json`);
|
|
41
|
+
const dir = path.dirname(manifest);
|
|
42
|
+
const declared = require_(manifest).bin;
|
|
43
|
+
const rel =
|
|
44
|
+
typeof declared === "string"
|
|
45
|
+
? declared
|
|
46
|
+
: declared && (declared.vaern || Object.values(declared)[0]);
|
|
47
|
+
const candidate = rel ? path.join(dir, rel) : path.join(dir, "bin", "vaern");
|
|
48
|
+
if (!fs.existsSync(candidate)) return done(`no binary in ${platformPkg}`);
|
|
49
|
+
binary = candidate;
|
|
50
|
+
} catch {
|
|
51
|
+
return done(`platform package ${platformPkg} not installed`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fs.chmodSync(binary, 0o755);
|
|
55
|
+
|
|
56
|
+
// Candidate bin directories: local install, then global prefix.
|
|
57
|
+
const candidates = [
|
|
58
|
+
path.resolve(__dirname, "..", "..", "..", ".bin"), // node_modules/.bin
|
|
59
|
+
];
|
|
60
|
+
if (process.env.npm_config_prefix) {
|
|
61
|
+
candidates.push(path.join(process.env.npm_config_prefix, "bin"));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let linked = false;
|
|
65
|
+
for (const binDir of candidates) {
|
|
66
|
+
const link = path.join(binDir, "vaern");
|
|
67
|
+
try {
|
|
68
|
+
if (!fs.existsSync(binDir)) continue;
|
|
69
|
+
const stat = fs.lstatSync(link);
|
|
70
|
+
// Only replace something that currently points at OUR shim.
|
|
71
|
+
const target = stat.isSymbolicLink() ? fs.readlinkSync(link) : link;
|
|
72
|
+
if (!/vaern\.cjs$/.test(target) && !/vaern\.cjs$/.test(path.resolve(binDir, target))) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
fs.rmSync(link, { force: true });
|
|
76
|
+
fs.symlinkSync(binary, link);
|
|
77
|
+
linked = true;
|
|
78
|
+
} catch {
|
|
79
|
+
continue; // read-only fs, permissions, race — all fine, the shim still works
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return done(linked ? `linked ${binary}` : "no replaceable bin link found");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
main();
|
|
87
|
+
} catch {
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|