@skaft/octet 0.8.1 → 0.10.4

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
@@ -1,20 +1,19 @@
1
1
  # octet npm launcher
2
2
 
3
- `@skaft/octet` is a small, shell-only launcher for the native octet
4
- runtime. npm selects one exact-version platform package through
5
- `optionalDependencies`; the normal `octet` and `octet-host` paths immediately `exec`
6
- the selected native binary.
3
+ `@skaft/octet` is a small Node.js launcher for the native octet runtime. npm
4
+ selects one exact-version platform package through `optionalDependencies`; the
5
+ `octet` and `octet-host` commands start the selected native binary directly.
7
6
 
8
7
  These scoped names are source packaging identities, not proof of registry rights
9
8
  or availability. Use the installation command only after an authorized release
10
9
  has published the packages.
11
10
 
12
- The launcher does not run Node, access the network, download an archive, or
13
- execute an install lifecycle hook. Install it with scripts, audit, and funding
14
- requests disabled:
11
+ The launcher requires Node.js but does not access the network, download an
12
+ archive, or execute an install lifecycle hook. Install it with scripts, audit,
13
+ and funding requests disabled:
15
14
 
16
15
  ```sh
17
- npm install --global --ignore-scripts --no-audit --no-fund @skaft/octet@0.8.1
16
+ npm install --global --ignore-scripts --no-audit --no-fund @skaft/octet@0.10.4
18
17
  ```
19
18
 
20
19
  GNU/Linux uses the glibc x64 package. macOS uses the arm64 or x64 package that
package/bin/octet CHANGED
@@ -1,26 +1,5 @@
1
- #!/bin/sh
2
- set -eu
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
3
 
4
- # npm may expose bin/octet through a symlink in its global bin directory. Resolve
5
- # that link without changing the caller's cwd before handing off to the common
6
- # shell-only launcher.
7
- script=$0
8
- case "$script" in
9
- /*) ;;
10
- *) script=$(pwd -P)/$script ;;
11
- esac
12
- while [ -L "$script" ]; do
13
- link=$(readlink "$script") || {
14
- printf '%s\n' 'octet npm launcher could not resolve its executable path' >&2
15
- exit 1
16
- }
17
- case "$link" in
18
- /*) script=$link ;;
19
- *) script=$(dirname "$script")/$link ;;
20
- esac
21
- done
22
- script_directory=$(CDPATH= cd -P -- "$(dirname "$script")" 2>/dev/null && pwd -P) || {
23
- printf '%s\n' 'octet npm launcher could not resolve its package directory' >&2
24
- exit 1
25
- }
26
- exec "$script_directory/../lib/launch.sh" octet "$@"
4
+ const { launch } = require('../lib/launch.js');
5
+ launch('octet');
package/bin/octet-host CHANGED
@@ -1,25 +1,5 @@
1
- #!/bin/sh
2
- set -eu
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
3
 
4
- # npm may expose bin/octet-host through a symlink in its global bin directory.
5
- # Resolve it before exec so package lookup remains independent of PATH.
6
- script=$0
7
- case "$script" in
8
- /*) ;;
9
- *) script=$(pwd -P)/$script ;;
10
- esac
11
- while [ -L "$script" ]; do
12
- link=$(readlink "$script") || {
13
- printf '%s\n' 'octet npm launcher could not resolve its executable path' >&2
14
- exit 1
15
- }
16
- case "$link" in
17
- /*) script=$link ;;
18
- *) script=$(dirname "$script")/$link ;;
19
- esac
20
- done
21
- script_directory=$(CDPATH= cd -P -- "$(dirname "$script")" 2>/dev/null && pwd -P) || {
22
- printf '%s\n' 'octet npm launcher could not resolve its package directory' >&2
23
- exit 1
24
- }
25
- exec "$script_directory/../lib/launch.sh" octet-host "$@"
4
+ const { launch } = require('../lib/launch.js');
5
+ launch('octet-host');
package/lib/launch.js ADDED
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const { spawnSync } = require('node:child_process');
6
+
7
+ const PLATFORMS = Object.freeze({
8
+ 'darwin-arm64': '@skaft/octet-darwin-arm64',
9
+ 'darwin-x64': '@skaft/octet-darwin-x64',
10
+ 'linux-x64': '@skaft/octet-linux-x64-gnu',
11
+ 'win32-x64': '@skaft/octet-win32-x64',
12
+ });
13
+
14
+ function selectedPackage(platform = process.platform, architecture = process.arch) {
15
+ if (platform === 'linux' && architecture === 'x64') {
16
+ const libc = process.report?.getReport?.().header?.glibcVersionRuntime;
17
+ if (!libc) throw new Error('octet npm package requires GNU libc on Linux; musl is not supported');
18
+ }
19
+ const key = `${platform}-${architecture}`;
20
+ const selected = PLATFORMS[key];
21
+ if (!selected) throw new Error(`octet npm package does not support this platform: ${key}`);
22
+ return selected;
23
+ }
24
+
25
+ function findPlatformRoot(launcherRoot, packageName) {
26
+ const packageLeaf = packageName.slice(packageName.indexOf('/') + 1);
27
+ const candidates = [
28
+ path.join(launcherRoot, 'node_modules', ...packageName.split('/')),
29
+ path.join(launcherRoot, '..', packageLeaf),
30
+ ];
31
+ for (const candidate of candidates) {
32
+ try {
33
+ if (fs.lstatSync(candidate).isDirectory() && !fs.lstatSync(candidate).isSymbolicLink()) return candidate;
34
+ } catch (error) {
35
+ if (error.code !== 'ENOENT') throw error;
36
+ }
37
+ }
38
+ throw new Error(`octet npm package is missing the selected platform runtime: ${packageName}`);
39
+ }
40
+
41
+ function launch(commandName, args = process.argv.slice(2)) {
42
+ if (commandName !== 'octet' && commandName !== 'octet-host') throw new Error('invalid native command');
43
+ const launcherRoot = path.resolve(__dirname, '..');
44
+ const packageName = selectedPackage();
45
+ const platformRoot = findPlatformRoot(launcherRoot, packageName);
46
+ const executableName = process.platform === 'win32' ? `${commandName}.exe` : commandName;
47
+ const executable = path.join(platformRoot, 'bin', executableName);
48
+ const versionPath = path.join(platformRoot, 'share', 'octet', '.octet-version');
49
+ const required = [
50
+ ...['package.json', 'README.md', 'LICENSE'].map((name) => path.join(platformRoot, name)), executable,
51
+ path.join(platformRoot, 'share', 'octet', 'README.md'),
52
+ path.join(platformRoot, 'share', 'octet', 'docs'),
53
+ path.join(platformRoot, 'share', 'octet', 'examples'),
54
+ path.join(platformRoot, 'share', 'octet', 'sdk'),
55
+ ];
56
+ for (const file of required) {
57
+ try {
58
+ const stat = fs.lstatSync(file);
59
+ if (stat.isSymbolicLink() || (file === executable ? !stat.isFile() : !stat.isFile() && !stat.isDirectory())) {
60
+ throw new Error(`octet npm platform package is incomplete: ${platformRoot}`);
61
+ }
62
+ } catch (error) {
63
+ if (error.code === 'ENOENT') throw new Error(`octet npm platform package is incomplete: ${platformRoot}`);
64
+ throw error;
65
+ }
66
+ }
67
+ if (process.platform !== 'win32' && (fs.statSync(executable).mode & 0o111) === 0) {
68
+ throw new Error(`octet npm platform executable is not executable: ${executable}`);
69
+ }
70
+ const version = fs.readFileSync(path.join(launcherRoot, 'package.json'), 'utf8').match(/"version"\s*:\s*"([^"]+)"/);
71
+ if (!version || fs.readFileSync(versionPath, 'utf8').trim() !== version[1]) {
72
+ throw new Error('octet npm platform version does not match launcher version');
73
+ }
74
+ const result = spawnSync(executable, args, { cwd: process.cwd(), env: process.env, stdio: 'inherit' });
75
+ if (result.error) throw result.error;
76
+ if (result.signal) {
77
+ process.kill(process.pid, result.signal);
78
+ return;
79
+ }
80
+ process.exitCode = result.status === null ? 1 : result.status;
81
+ }
82
+
83
+ module.exports = { PLATFORMS, selectedPackage, findPlatformRoot, launch };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@skaft/octet",
3
- "version": "0.8.1",
3
+ "version": "0.10.4",
4
4
  "description": "Native octet coding agent launcher",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/skaft-software/octet",
7
+ "homepage": "https://octet.skaft.org",
7
8
  "files": [
8
9
  "README.md",
9
10
  "LICENSE",
@@ -15,8 +16,9 @@
15
16
  "octet-host": "bin/octet-host"
16
17
  },
17
18
  "optionalDependencies": {
18
- "@skaft/octet-darwin-arm64": "0.8.1",
19
- "@skaft/octet-darwin-x64": "0.8.1",
20
- "@skaft/octet-linux-x64-gnu": "0.8.1"
19
+ "@skaft/octet-darwin-arm64": "0.10.4",
20
+ "@skaft/octet-darwin-x64": "0.10.4",
21
+ "@skaft/octet-linux-x64-gnu": "0.10.4",
22
+ "@skaft/octet-win32-x64": "0.10.4"
21
23
  }
22
24
  }
package/lib/launch.sh DELETED
@@ -1,117 +0,0 @@
1
- #!/bin/sh
2
- set -eu
3
-
4
- package_version="0.8.1"
5
-
6
- fail() {
7
- printf '%s\n' "$1" >&2
8
- exit 1
9
- }
10
-
11
- command_name=${1-}
12
- case "$command_name" in
13
- octet|octet-host) ;;
14
- *) fail 'octet npm launcher received an invalid native command' ;;
15
- esac
16
- shift
17
-
18
- # npm exposes each bin entry through a symlink in its global bin directory.
19
- # Resolve it without changing the caller's working directory before locating
20
- # the package-local launcher.
21
- script=$0
22
- case "$script" in
23
- /*) ;;
24
- *) script=$(pwd -P)/$script ;;
25
- esac
26
- while [ -L "$script" ]; do
27
- link=$(readlink "$script") || fail 'octet npm launcher could not resolve its executable path'
28
- case "$link" in
29
- /*) script=$link ;;
30
- *) script=$(dirname "$script")/$link ;;
31
- esac
32
- done
33
- launch_directory=$(CDPATH= cd -P -- "$(dirname "$script")" 2>/dev/null && pwd -P) || \
34
- fail 'octet npm launcher could not resolve its package directory'
35
- launcher_root=$(CDPATH= cd -P -- "$launch_directory/.." 2>/dev/null && pwd -P) || \
36
- fail 'octet npm launcher could not resolve its package root'
37
- [ -d "$launcher_root" ] && [ ! -L "$launcher_root" ] || \
38
- fail 'octet npm launcher package root is not a real directory'
39
-
40
- operating_system=$(uname -s 2>/dev/null) || fail 'octet npm launcher requires uname'
41
- machine=$(uname -m 2>/dev/null) || fail 'octet npm launcher could not determine the CPU architecture'
42
- platform_package=
43
- case "$operating_system:$machine" in
44
- Darwin:arm64|Darwin:aarch64)
45
- platform_package='@skaft/octet-darwin-arm64'
46
- ;;
47
- Darwin:x86_64|Darwin:amd64)
48
- # Select the package matching the executable ABI. An x86_64 octet under
49
- # Rosetta is still an x86_64 binary and must not exec arm64 code.
50
- platform_package='@skaft/octet-darwin-x64'
51
- ;;
52
- Linux:x86_64|Linux:amd64)
53
- glibc_available=false
54
- if command -v getconf >/dev/null 2>&1; then
55
- glibc_version=$(getconf GNU_LIBC_VERSION 2>/dev/null || true)
56
- case "$glibc_version" in
57
- glibc\ *|GNU\ libc\ *) glibc_available=true ;;
58
- esac
59
- fi
60
- if [ "$glibc_available" != true ] && command -v ldd >/dev/null 2>&1; then
61
- ldd_version=$(ldd --version 2>&1 || true)
62
- case "$ldd_version" in
63
- *glibc*|*GLIBC*|*'GNU libc'*|*'GNU C Library'*) glibc_available=true ;;
64
- esac
65
- fi
66
- [ "$glibc_available" = true ] || \
67
- fail 'octet npm package requires GNU libc on Linux; musl is not supported'
68
- platform_package='@skaft/octet-linux-x64-gnu'
69
- ;;
70
- Darwin:*) fail "octet npm package does not support macOS architecture: $machine" ;;
71
- Linux:*) fail "octet npm package does not support Linux architecture: $machine" ;;
72
- *) fail "octet npm package does not support operating system: $operating_system" ;;
73
- esac
74
-
75
- platform_name=${platform_package#*/}
76
- platform_root=
77
- # npm may nest optional dependencies below the public package or hoist them to
78
- # the sibling scope directory. Both layouts are explicit; there is no network
79
- # resolver or fallback package.
80
- for candidate in \
81
- "$launcher_root/node_modules/$platform_package" \
82
- "$launcher_root/../$platform_name"; do
83
- if [ -d "$candidate" ] && [ ! -L "$candidate" ]; then
84
- platform_root=$candidate
85
- break
86
- fi
87
- done
88
- [ -n "$platform_root" ] || \
89
- fail "octet npm package is missing the selected platform runtime: $platform_package"
90
-
91
- for required in \
92
- "$platform_root/package.json" \
93
- "$platform_root/README.md" \
94
- "$platform_root/LICENSE" \
95
- "$platform_root/bin/$command_name" \
96
- "$platform_root/share/octet/.octet-version" \
97
- "$platform_root/share/octet/README.md"; do
98
- [ -f "$required" ] && [ ! -L "$required" ] || \
99
- fail "octet npm platform package is incomplete: $platform_root"
100
- done
101
- for required_directory in \
102
- "$platform_root/bin" \
103
- "$platform_root/share/octet" \
104
- "$platform_root/share/octet/docs" \
105
- "$platform_root/share/octet/examples" \
106
- "$platform_root/share/octet/sdk"; do
107
- [ -d "$required_directory" ] && [ ! -L "$required_directory" ] || \
108
- fail "octet npm platform package is incomplete: $platform_root"
109
- done
110
- [ -x "$platform_root/bin/$command_name" ] || \
111
- fail "octet npm platform executable is not executable: $platform_root/bin/$command_name"
112
- [ "$(cat "$platform_root/share/octet/.octet-version")" = "$package_version" ] || \
113
- fail "octet npm platform version does not match launcher version $package_version"
114
-
115
- # Do not print on the successful path: octet-host stdout is a protocol stream.
116
- # exec preserves cwd, argv, environment, stdio, signal delivery, and status.
117
- exec "$platform_root/bin/$command_name" "$@"