@ever-works/pty-local-plugin 1.0.11 → 1.0.15

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/dist/index.cjs CHANGED
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var child_process = require('child_process');
6
+ var fs = require('fs');
7
+ var path = require('path');
6
8
 
7
9
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
10
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -123,6 +125,9 @@ var RECORD_VISIBILITIES = ["private", "team", "organization"];
123
125
  new Set(RECORD_VISIBILITIES);
124
126
  var RECORD_LIST_VIEWS = ["mine", "shared", "organization"];
125
127
  new Set(RECORD_LIST_VIEWS);
128
+ new Set(
129
+ "a abbr address applet area article aside audio b base bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl dt em embed fieldset figcaption figure font footer form frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe image img input ins kbd label legend li link main map mark marquee math menu meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select slot small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr xmp".split(" ")
130
+ );
126
131
  var VERSION = "1.0.0";
127
132
  var GTM_SKILLS = [
128
133
  // ── research ────────────────────────────────────────────────────────
@@ -1862,12 +1867,85 @@ var TerminalNotProvisionedError = class extends Error {
1862
1867
  this.name = "TerminalNotProvisionedError";
1863
1868
  }
1864
1869
  };
1870
+ var GITHUB_FULL_SCOPES_ALL = [
1871
+ "user:email",
1872
+ "read:user",
1873
+ "repo",
1874
+ "delete_repo",
1875
+ "workflow",
1876
+ "write:repo_hook",
1877
+ "read:org",
1878
+ "project"
1879
+ ];
1880
+ var GITHUB_DELETE_REPO_SCOPE = "delete_repo";
1881
+ function isGithubDeleteRepoScopeEnabled(env = readEnv()) {
1882
+ return (env?.GITHUB_OAUTH_DELETE_REPO_SCOPE_ENABLED ?? "").trim().toLowerCase() === "true";
1883
+ }
1884
+ function readEnv() {
1885
+ return typeof process !== "undefined" ? process.env : void 0;
1886
+ }
1887
+ Object.freeze(
1888
+ GITHUB_FULL_SCOPES_ALL.filter((scope) => scope !== GITHUB_DELETE_REPO_SCOPE || isGithubDeleteRepoScopeEnabled())
1889
+ );
1890
+ var realProbe = () => ({
1891
+ platform: process.platform,
1892
+ readFile: (path) => {
1893
+ try {
1894
+ return fs.readFileSync(path, "utf8");
1895
+ } catch {
1896
+ return null;
1897
+ }
1898
+ },
1899
+ readDir: (path) => {
1900
+ try {
1901
+ return fs.readdirSync(path);
1902
+ } catch {
1903
+ return [];
1904
+ }
1905
+ },
1906
+ reportHeader: () => {
1907
+ const report = process.report;
1908
+ if (!report?.getReport) return void 0;
1909
+ const previous = report.excludeNetwork;
1910
+ report.excludeNetwork = true;
1911
+ try {
1912
+ return report.getReport().header;
1913
+ } finally {
1914
+ report.excludeNetwork = previous;
1915
+ }
1916
+ }
1917
+ });
1918
+ function detectMuslLinux(probe) {
1919
+ if (probe.platform !== "linux") return false;
1920
+ try {
1921
+ if (probe.readDir("/lib").some((name) => name.startsWith("ld-musl-"))) return true;
1922
+ const ldd = probe.readFile("/usr/bin/ldd");
1923
+ if (ldd !== null) return ldd.includes("musl");
1924
+ const header = probe.reportHeader();
1925
+ return header !== void 0 && !header.glibcVersionRuntime;
1926
+ } catch {
1927
+ return false;
1928
+ }
1929
+ }
1930
+ var cachedMusl = null;
1931
+ function isMuslLinux() {
1932
+ if (cachedMusl === null) cachedMusl = detectMuslLinux(realProbe());
1933
+ return cachedMusl;
1934
+ }
1935
+ function muslBlocksPtyAddon(resolvePackageJson, musl = isMuslLinux(), fileExists = fs.existsSync) {
1936
+ if (!musl) return false;
1937
+ try {
1938
+ return !fileExists(path.join(path.dirname(resolvePackageJson()), "build", "Release", "pty.node"));
1939
+ } catch {
1940
+ return true;
1941
+ }
1942
+ }
1865
1943
 
1866
1944
  // src/pty-local.plugin.ts
1867
1945
  var DEFAULT_COLS = 120;
1868
1946
  var DEFAULT_ROWS = 32;
1869
1947
  function makePtyLocalSessionId(runId, pid) {
1870
- const suffix = typeof pid === "number" && Number.isFinite(pid) ? String(pid) : "no-pid";
1948
+ const suffix = typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? String(pid) : "no-pid";
1871
1949
  return `pty-local:${runId}:${suffix}`;
1872
1950
  }
1873
1951
  var PtyLocalPlugin = class {
@@ -2061,6 +2139,9 @@ var PtyLocalPlugin = class {
2061
2139
  }
2062
2140
  // ── runtime require ─────────────────────────────────────────────
2063
2141
  tryLoadPty() {
2142
+ if (muslBlocksPtyAddon(() => __require.resolve("@homebridge/node-pty-prebuilt-multiarch/package.json"))) {
2143
+ return null;
2144
+ }
2064
2145
  try {
2065
2146
  const required = __require("@homebridge/node-pty-prebuilt-multiarch");
2066
2147
  return typeof required?.spawn === "function" ? required : null;
@@ -2112,4 +2193,7 @@ var index_default = PtyLocalPlugin;
2112
2193
 
2113
2194
  exports.PtyLocalPlugin = PtyLocalPlugin;
2114
2195
  exports.default = index_default;
2196
+ exports.detectMuslLinux = detectMuslLinux;
2197
+ exports.isMuslLinux = isMuslLinux;
2115
2198
  exports.makePtyLocalSessionId = makePtyLocalSessionId;
2199
+ exports.muslBlocksPtyAddon = muslBlocksPtyAddon;
package/dist/index.d.cts CHANGED
@@ -55,4 +55,43 @@ declare class PtyLocalPlugin implements IPlugin, ITerminalStreamPlugin {
55
55
  getManifest(): PluginManifest;
56
56
  }
57
57
 
58
- export { PtyLocalPlugin, PtyLocalPlugin as default, makePtyLocalSessionId };
58
+ /**
59
+ * musl Linux (Alpine) and the PTY addon.
60
+ *
61
+ * `@homebridge/node-pty-prebuilt-multiarch` 0.15 ships `linux-musl-*`
62
+ * prebuilds, but its loader (`lib/utils.js` `loadNativeModule`) looks only in
63
+ * `build/Release`, `build/Debug` and `prebuilds/<platform>-<arch>`. On musl it
64
+ * therefore loads the GLIBC prebuild: the `require` succeeds and the first
65
+ * `spawn()` segfaults the whole process (seen on `node:26-alpine`,
66
+ * 2026-11-11). A source build in `build/Release` (an install with
67
+ * `npm_config_build_from_source`) is built for this libc and is safe.
68
+ */
69
+ /** How the check reads the machine; tests inject their own. */
70
+ interface MuslProbe {
71
+ platform: string;
72
+ /** A file's text, or null when it cannot be read. */
73
+ readFile(path: string): string | null;
74
+ /** A folder's entries, or [] when it cannot be read. */
75
+ readDir(path: string): string[];
76
+ /** Node's diagnostic report header, read without touching the network. */
77
+ reportHeader(): {
78
+ glibcVersionRuntime?: unknown;
79
+ } | undefined;
80
+ }
81
+ /**
82
+ * The libc, from the cheapest evidence first — the files `detect-libc` and
83
+ * the claude-code plugin read (`/lib/ld-musl-*`, `/usr/bin/ldd`), then the
84
+ * diagnostic report (no `glibcVersionRuntime` on musl). Never throws.
85
+ */
86
+ declare function detectMuslLinux(probe: MuslProbe): boolean;
87
+ /** True on musl Linux. Detected once per process (the libc does not change under it). */
88
+ declare function isMuslLinux(): boolean;
89
+ /**
90
+ * True when the PTY addon must not be loaded here: musl Linux without a
91
+ * source build of the addon. `resolvePackageJson` returns the addon's
92
+ * `package.json` path (throws when it is not installed — then nothing is
93
+ * loadable anyway, so the answer is `musl`).
94
+ */
95
+ declare function muslBlocksPtyAddon(resolvePackageJson: () => string, musl?: boolean, fileExists?: (path: string) => boolean): boolean;
96
+
97
+ export { type MuslProbe, PtyLocalPlugin, PtyLocalPlugin as default, detectMuslLinux, isMuslLinux, makePtyLocalSessionId, muslBlocksPtyAddon };
package/dist/index.d.ts CHANGED
@@ -55,4 +55,43 @@ declare class PtyLocalPlugin implements IPlugin, ITerminalStreamPlugin {
55
55
  getManifest(): PluginManifest;
56
56
  }
57
57
 
58
- export { PtyLocalPlugin, PtyLocalPlugin as default, makePtyLocalSessionId };
58
+ /**
59
+ * musl Linux (Alpine) and the PTY addon.
60
+ *
61
+ * `@homebridge/node-pty-prebuilt-multiarch` 0.15 ships `linux-musl-*`
62
+ * prebuilds, but its loader (`lib/utils.js` `loadNativeModule`) looks only in
63
+ * `build/Release`, `build/Debug` and `prebuilds/<platform>-<arch>`. On musl it
64
+ * therefore loads the GLIBC prebuild: the `require` succeeds and the first
65
+ * `spawn()` segfaults the whole process (seen on `node:26-alpine`,
66
+ * 2026-11-11). A source build in `build/Release` (an install with
67
+ * `npm_config_build_from_source`) is built for this libc and is safe.
68
+ */
69
+ /** How the check reads the machine; tests inject their own. */
70
+ interface MuslProbe {
71
+ platform: string;
72
+ /** A file's text, or null when it cannot be read. */
73
+ readFile(path: string): string | null;
74
+ /** A folder's entries, or [] when it cannot be read. */
75
+ readDir(path: string): string[];
76
+ /** Node's diagnostic report header, read without touching the network. */
77
+ reportHeader(): {
78
+ glibcVersionRuntime?: unknown;
79
+ } | undefined;
80
+ }
81
+ /**
82
+ * The libc, from the cheapest evidence first — the files `detect-libc` and
83
+ * the claude-code plugin read (`/lib/ld-musl-*`, `/usr/bin/ldd`), then the
84
+ * diagnostic report (no `glibcVersionRuntime` on musl). Never throws.
85
+ */
86
+ declare function detectMuslLinux(probe: MuslProbe): boolean;
87
+ /** True on musl Linux. Detected once per process (the libc does not change under it). */
88
+ declare function isMuslLinux(): boolean;
89
+ /**
90
+ * True when the PTY addon must not be loaded here: musl Linux without a
91
+ * source build of the addon. `resolvePackageJson` returns the addon's
92
+ * `package.json` path (throws when it is not installed — then nothing is
93
+ * loadable anyway, so the answer is `musl`).
94
+ */
95
+ declare function muslBlocksPtyAddon(resolvePackageJson: () => string, musl?: boolean, fileExists?: (path: string) => boolean): boolean;
96
+
97
+ export { type MuslProbe, PtyLocalPlugin, PtyLocalPlugin as default, detectMuslLinux, isMuslLinux, makePtyLocalSessionId, muslBlocksPtyAddon };
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { spawn } from 'child_process';
2
+ import { existsSync, readdirSync, readFileSync } from 'fs';
3
+ import { join, dirname } from 'path';
2
4
 
3
5
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
6
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -119,6 +121,9 @@ var RECORD_VISIBILITIES = ["private", "team", "organization"];
119
121
  new Set(RECORD_VISIBILITIES);
120
122
  var RECORD_LIST_VIEWS = ["mine", "shared", "organization"];
121
123
  new Set(RECORD_LIST_VIEWS);
124
+ new Set(
125
+ "a abbr address applet area article aside audio b base bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl dt em embed fieldset figcaption figure font footer form frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe image img input ins kbd label legend li link main map mark marquee math menu meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select slot small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr xmp".split(" ")
126
+ );
122
127
  var VERSION = "1.0.0";
123
128
  var GTM_SKILLS = [
124
129
  // ── research ────────────────────────────────────────────────────────
@@ -1858,12 +1863,85 @@ var TerminalNotProvisionedError = class extends Error {
1858
1863
  this.name = "TerminalNotProvisionedError";
1859
1864
  }
1860
1865
  };
1866
+ var GITHUB_FULL_SCOPES_ALL = [
1867
+ "user:email",
1868
+ "read:user",
1869
+ "repo",
1870
+ "delete_repo",
1871
+ "workflow",
1872
+ "write:repo_hook",
1873
+ "read:org",
1874
+ "project"
1875
+ ];
1876
+ var GITHUB_DELETE_REPO_SCOPE = "delete_repo";
1877
+ function isGithubDeleteRepoScopeEnabled(env = readEnv()) {
1878
+ return (env?.GITHUB_OAUTH_DELETE_REPO_SCOPE_ENABLED ?? "").trim().toLowerCase() === "true";
1879
+ }
1880
+ function readEnv() {
1881
+ return typeof process !== "undefined" ? process.env : void 0;
1882
+ }
1883
+ Object.freeze(
1884
+ GITHUB_FULL_SCOPES_ALL.filter((scope) => scope !== GITHUB_DELETE_REPO_SCOPE || isGithubDeleteRepoScopeEnabled())
1885
+ );
1886
+ var realProbe = () => ({
1887
+ platform: process.platform,
1888
+ readFile: (path) => {
1889
+ try {
1890
+ return readFileSync(path, "utf8");
1891
+ } catch {
1892
+ return null;
1893
+ }
1894
+ },
1895
+ readDir: (path) => {
1896
+ try {
1897
+ return readdirSync(path);
1898
+ } catch {
1899
+ return [];
1900
+ }
1901
+ },
1902
+ reportHeader: () => {
1903
+ const report = process.report;
1904
+ if (!report?.getReport) return void 0;
1905
+ const previous = report.excludeNetwork;
1906
+ report.excludeNetwork = true;
1907
+ try {
1908
+ return report.getReport().header;
1909
+ } finally {
1910
+ report.excludeNetwork = previous;
1911
+ }
1912
+ }
1913
+ });
1914
+ function detectMuslLinux(probe) {
1915
+ if (probe.platform !== "linux") return false;
1916
+ try {
1917
+ if (probe.readDir("/lib").some((name) => name.startsWith("ld-musl-"))) return true;
1918
+ const ldd = probe.readFile("/usr/bin/ldd");
1919
+ if (ldd !== null) return ldd.includes("musl");
1920
+ const header = probe.reportHeader();
1921
+ return header !== void 0 && !header.glibcVersionRuntime;
1922
+ } catch {
1923
+ return false;
1924
+ }
1925
+ }
1926
+ var cachedMusl = null;
1927
+ function isMuslLinux() {
1928
+ if (cachedMusl === null) cachedMusl = detectMuslLinux(realProbe());
1929
+ return cachedMusl;
1930
+ }
1931
+ function muslBlocksPtyAddon(resolvePackageJson, musl = isMuslLinux(), fileExists = existsSync) {
1932
+ if (!musl) return false;
1933
+ try {
1934
+ return !fileExists(join(dirname(resolvePackageJson()), "build", "Release", "pty.node"));
1935
+ } catch {
1936
+ return true;
1937
+ }
1938
+ }
1861
1939
 
1862
1940
  // src/pty-local.plugin.ts
1863
1941
  var DEFAULT_COLS = 120;
1864
1942
  var DEFAULT_ROWS = 32;
1865
1943
  function makePtyLocalSessionId(runId, pid) {
1866
- const suffix = typeof pid === "number" && Number.isFinite(pid) ? String(pid) : "no-pid";
1944
+ const suffix = typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? String(pid) : "no-pid";
1867
1945
  return `pty-local:${runId}:${suffix}`;
1868
1946
  }
1869
1947
  var PtyLocalPlugin = class {
@@ -2057,6 +2135,9 @@ var PtyLocalPlugin = class {
2057
2135
  }
2058
2136
  // ── runtime require ─────────────────────────────────────────────
2059
2137
  tryLoadPty() {
2138
+ if (muslBlocksPtyAddon(() => __require.resolve("@homebridge/node-pty-prebuilt-multiarch/package.json"))) {
2139
+ return null;
2140
+ }
2060
2141
  try {
2061
2142
  const required = __require("@homebridge/node-pty-prebuilt-multiarch");
2062
2143
  return typeof required?.spawn === "function" ? required : null;
@@ -2106,4 +2187,4 @@ var index_default = PtyLocalPlugin;
2106
2187
  * implementation adds is additive.
2107
2188
  */
2108
2189
 
2109
- export { PtyLocalPlugin, index_default as default, makePtyLocalSessionId };
2190
+ export { PtyLocalPlugin, index_default as default, detectMuslLinux, isMuslLinux, makePtyLocalSessionId, muslBlocksPtyAddon };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ever-works/pty-local-plugin",
3
- "version": "1.0.11",
3
+ "version": "1.0.15",
4
4
  "description": "Streaming-terminal session host for Ever Works — spawns the agent CLI under a real PTY inside the executing job-runtime worker (node-pty prebuilt), degrading to a child_process pipe floor when the native addon is unavailable.",
5
5
  "author": {
6
6
  "name": "Ever Co. LTD",
@@ -32,14 +32,14 @@
32
32
  "test:coverage": "vitest run --coverage"
33
33
  },
34
34
  "peerDependencies": {
35
- "@ever-works/plugin": "^1.2.16"
35
+ "@ever-works/plugin": "^1.2.28"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@homebridge/node-pty-prebuilt-multiarch": "^0.13.1"
38
+ "@homebridge/node-pty-prebuilt-multiarch": "^0.15.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@ever-works/contracts": "^1.0.19",
42
- "@ever-works/plugin": "^1.2.16",
41
+ "@ever-works/contracts": "^1.1.1",
42
+ "@ever-works/plugin": "^1.2.28",
43
43
  "@types/node": "^26.6.4",
44
44
  "tsup": "^8.4.0",
45
45
  "typescript": "^5.7.3",
@@ -62,16 +62,16 @@
62
62
  },
63
63
  "repository": {
64
64
  "type": "git",
65
- "url": "git+https://github.com/ever-works/ever-works.git",
65
+ "url": "git+https://github.com/ever-co/ever-works.git",
66
66
  "directory": "packages/plugins/pty-local"
67
67
  },
68
- "homepage": "https://github.com/ever-works/ever-works/tree/main/packages/plugins/pty-local#readme",
68
+ "homepage": "https://github.com/ever-co/ever-works/tree/main/packages/plugins/pty-local#readme",
69
69
  "bugs": {
70
- "url": "https://github.com/ever-works/ever-works/issues"
70
+ "url": "https://github.com/ever-co/ever-works/issues"
71
71
  },
72
72
  "everworksRelease": {
73
- "contentHash": "sha256:60754994058a5f2fee57652614294f8ec8ee242ad442e14fcacfeff7600ab777",
74
- "commit": "89cee44a662034ea957b07ec5e1230ecf340b107",
75
- "source": "https://github.com/ever-works/ever-works/tree/89cee44a662034ea957b07ec5e1230ecf340b107/packages/plugins/pty-local"
73
+ "contentHash": "sha256:299638dd2395733f561d5954180b571cd9cd73431573bde4eed6fe099ca2ab12",
74
+ "commit": "2288ff7e91562b0f079c365348ba08ab3a16f1dd",
75
+ "source": "https://github.com/ever-co/ever-works/tree/2288ff7e91562b0f079c365348ba08ab3a16f1dd/packages/plugins/pty-local"
76
76
  }
77
77
  }