@rivet-dev/agentos-sidecar 0.0.0-agentos-dylib-plugin.473700e

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.
Files changed (4) hide show
  1. package/README.md +19 -0
  2. package/index.d.ts +12 -0
  3. package/index.js +76 -0
  4. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @rivet-dev/agent-os-sidecar
2
+
3
+ Platform-specific resolver for the Agent OS native sidecar binary.
4
+
5
+ The compiled `agent-os-sidecar` binary ships inside one of the
6
+ `@rivet-dev/agent-os-sidecar-<platform>` packages, which this package declares as
7
+ optional dependencies. npm installs only the package matching the current
8
+ `os`/`cpu`/`libc` at install time.
9
+
10
+ ```js
11
+ const { getSidecarPath } = require("@rivet-dev/agent-os-sidecar");
12
+
13
+ const binaryPath = getSidecarPath();
14
+ ```
15
+
16
+ Set `AGENT_OS_SIDECAR_BIN` to an absolute path to override resolution (useful
17
+ for development or custom builds).
18
+
19
+ Supported platforms: `linux-x64-gnu`, `linux-arm64-gnu`.
package/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Resolve the absolute path to the prebuilt `agentos-sidecar` binary for the
3
+ * current platform.
4
+ *
5
+ * Resolution priority:
6
+ * 1. `AGENTOS_SIDECAR_BIN` env var (absolute path override).
7
+ * 2. A `agentos-sidecar` binary placed next to this package (dev builds).
8
+ * 3. The platform-specific `@rivet-dev/agentos-sidecar-<platform>` package.
9
+ *
10
+ * @throws if the platform is unsupported or no binary can be found.
11
+ */
12
+ export function getSidecarPath(): string;
package/index.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ // Platform-specific resolver for the prebuilt `agentos-sidecar` binary. The
4
+ // binary itself ships inside one of the `@rivet-dev/agentos-sidecar-<platform>`
5
+ // packages, declared as optionalDependencies so npm only installs the one
6
+ // matching the current `os`/`cpu`/`libc` at install time.
7
+ //
8
+ // Resolution priority:
9
+ // 1. `AGENTOS_SIDECAR_BIN` env var (absolute path override).
10
+ // 2. A `agentos-sidecar` binary placed next to this package (dev builds).
11
+ // 3. The platform-specific `@rivet-dev/agentos-sidecar-<platform>` package.
12
+
13
+ const { existsSync } = require("node:fs");
14
+ const { join, dirname } = require("node:path");
15
+
16
+ const BINARY_NAME = "agentos-sidecar";
17
+
18
+ // No runtime chmod: the platform packages are published with `npm publish`,
19
+ // which preserves the binary's 0755 executable bit (pnpm publish would strip
20
+ // it to 0644). This mirrors how @rivetkit/engine-cli ships rivet-engine. See
21
+ // the "Native Binary Distribution" section in CLAUDE.md.
22
+
23
+ function getPlatformPackageName() {
24
+ const { platform, arch } = process;
25
+ switch (platform) {
26
+ case "linux":
27
+ if (arch === "x64") return "@rivet-dev/agentos-sidecar-linux-x64-gnu";
28
+ if (arch === "arm64") return "@rivet-dev/agentos-sidecar-linux-arm64-gnu";
29
+ break;
30
+ default:
31
+ break;
32
+ }
33
+ return null;
34
+ }
35
+
36
+ function getSidecarPath() {
37
+ const override = process.env.AGENTOS_SIDECAR_BIN;
38
+ if (override) {
39
+ if (!existsSync(override)) {
40
+ throw new Error(
41
+ `AGENTOS_SIDECAR_BIN is set to ${override} but the file does not exist`,
42
+ );
43
+ }
44
+ return override;
45
+ }
46
+
47
+ const localBinary = join(__dirname, BINARY_NAME);
48
+ if (existsSync(localBinary)) {
49
+ return localBinary;
50
+ }
51
+
52
+ const platformPkg = getPlatformPackageName();
53
+ if (!platformPkg) {
54
+ throw new Error(
55
+ `@rivet-dev/agentos-sidecar: unsupported platform ${process.platform}/${process.arch}. ` +
56
+ "The Agent OS sidecar currently supports linux x64 and arm64. " +
57
+ "Set AGENTOS_SIDECAR_BIN to a local agentos-sidecar binary to override.",
58
+ );
59
+ }
60
+
61
+ let pkgJsonPath;
62
+ try {
63
+ pkgJsonPath = require.resolve(`${platformPkg}/package.json`);
64
+ } catch {
65
+ throw new Error(
66
+ `@rivet-dev/agentos-sidecar: platform package ${platformPkg} is not installed.\n` +
67
+ "This usually means the platform is unsupported or optionalDependencies were\n" +
68
+ `skipped during install. Try: npm install --include=optional ${platformPkg}\n` +
69
+ "Or set AGENTOS_SIDECAR_BIN to a local agentos-sidecar binary.",
70
+ );
71
+ }
72
+
73
+ return join(dirname(pkgJsonPath), BINARY_NAME);
74
+ }
75
+
76
+ module.exports = { getSidecarPath };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@rivet-dev/agentos-sidecar",
3
+ "version": "0.0.0-agentos-dylib-plugin.473700e",
4
+ "description": "Platform-specific resolver for the Agent OS native sidecar binary",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/rivet-dev/agent-os.git",
9
+ "directory": "packages/sidecar-binary"
10
+ },
11
+ "main": "./index.js",
12
+ "types": "./index.d.ts",
13
+ "files": [
14
+ "index.js",
15
+ "index.d.ts",
16
+ "README.md"
17
+ ],
18
+ "engines": {
19
+ "node": ">=20"
20
+ },
21
+ "optionalDependencies": {
22
+ "@rivet-dev/agentos-sidecar-linux-x64-gnu": "0.0.0-agentos-dylib-plugin.473700e"
23
+ }
24
+ }