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

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]
@@ -113,7 +115,9 @@ var USER_SELECTABLE_WORK_KINDS = [
113
115
  "directory",
114
116
  "awesome-repo",
115
117
  "repo",
116
- "app"
118
+ "app",
119
+ "knowledge-base",
120
+ "store"
117
121
  ];
118
122
  var WORK_KINDS = [...USER_SELECTABLE_WORK_KINDS, "company", "campaign", "project", "default"];
119
123
  new Set(WORK_KINDS);
@@ -123,6 +127,9 @@ var RECORD_VISIBILITIES = ["private", "team", "organization"];
123
127
  new Set(RECORD_VISIBILITIES);
124
128
  var RECORD_LIST_VIEWS = ["mine", "shared", "organization"];
125
129
  new Set(RECORD_LIST_VIEWS);
130
+ new Set(
131
+ "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(" ")
132
+ );
126
133
  var VERSION = "1.0.0";
127
134
  var GTM_SKILLS = [
128
135
  // ── research ────────────────────────────────────────────────────────
@@ -1862,12 +1869,85 @@ var TerminalNotProvisionedError = class extends Error {
1862
1869
  this.name = "TerminalNotProvisionedError";
1863
1870
  }
1864
1871
  };
1872
+ var GITHUB_FULL_SCOPES_ALL = [
1873
+ "user:email",
1874
+ "read:user",
1875
+ "repo",
1876
+ "delete_repo",
1877
+ "workflow",
1878
+ "write:repo_hook",
1879
+ "read:org",
1880
+ "project"
1881
+ ];
1882
+ var GITHUB_DELETE_REPO_SCOPE = "delete_repo";
1883
+ function isGithubDeleteRepoScopeEnabled(env = readEnv()) {
1884
+ return (env?.GITHUB_OAUTH_DELETE_REPO_SCOPE_ENABLED ?? "").trim().toLowerCase() === "true";
1885
+ }
1886
+ function readEnv() {
1887
+ return typeof process !== "undefined" ? process.env : void 0;
1888
+ }
1889
+ Object.freeze(
1890
+ GITHUB_FULL_SCOPES_ALL.filter((scope) => scope !== GITHUB_DELETE_REPO_SCOPE || isGithubDeleteRepoScopeEnabled())
1891
+ );
1892
+ var realProbe = () => ({
1893
+ platform: process.platform,
1894
+ readFile: (path) => {
1895
+ try {
1896
+ return fs.readFileSync(path, "utf8");
1897
+ } catch {
1898
+ return null;
1899
+ }
1900
+ },
1901
+ readDir: (path) => {
1902
+ try {
1903
+ return fs.readdirSync(path);
1904
+ } catch {
1905
+ return [];
1906
+ }
1907
+ },
1908
+ reportHeader: () => {
1909
+ const report = process.report;
1910
+ if (!report?.getReport) return void 0;
1911
+ const previous = report.excludeNetwork;
1912
+ report.excludeNetwork = true;
1913
+ try {
1914
+ return report.getReport().header;
1915
+ } finally {
1916
+ report.excludeNetwork = previous;
1917
+ }
1918
+ }
1919
+ });
1920
+ function detectMuslLinux(probe) {
1921
+ if (probe.platform !== "linux") return false;
1922
+ try {
1923
+ if (probe.readDir("/lib").some((name) => name.startsWith("ld-musl-"))) return true;
1924
+ const ldd = probe.readFile("/usr/bin/ldd");
1925
+ if (ldd !== null) return ldd.includes("musl");
1926
+ const header = probe.reportHeader();
1927
+ return header !== void 0 && !header.glibcVersionRuntime;
1928
+ } catch {
1929
+ return false;
1930
+ }
1931
+ }
1932
+ var cachedMusl = null;
1933
+ function isMuslLinux() {
1934
+ if (cachedMusl === null) cachedMusl = detectMuslLinux(realProbe());
1935
+ return cachedMusl;
1936
+ }
1937
+ function muslBlocksPtyAddon(resolvePackageJson, musl = isMuslLinux(), fileExists = fs.existsSync) {
1938
+ if (!musl) return false;
1939
+ try {
1940
+ return !fileExists(path.join(path.dirname(resolvePackageJson()), "build", "Release", "pty.node"));
1941
+ } catch {
1942
+ return true;
1943
+ }
1944
+ }
1865
1945
 
1866
1946
  // src/pty-local.plugin.ts
1867
1947
  var DEFAULT_COLS = 120;
1868
1948
  var DEFAULT_ROWS = 32;
1869
1949
  function makePtyLocalSessionId(runId, pid) {
1870
- const suffix = typeof pid === "number" && Number.isFinite(pid) ? String(pid) : "no-pid";
1950
+ const suffix = typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? String(pid) : "no-pid";
1871
1951
  return `pty-local:${runId}:${suffix}`;
1872
1952
  }
1873
1953
  var PtyLocalPlugin = class {
@@ -2061,6 +2141,9 @@ var PtyLocalPlugin = class {
2061
2141
  }
2062
2142
  // ── runtime require ─────────────────────────────────────────────
2063
2143
  tryLoadPty() {
2144
+ if (muslBlocksPtyAddon(() => __require.resolve("@homebridge/node-pty-prebuilt-multiarch/package.json"))) {
2145
+ return null;
2146
+ }
2064
2147
  try {
2065
2148
  const required = __require("@homebridge/node-pty-prebuilt-multiarch");
2066
2149
  return typeof required?.spawn === "function" ? required : null;
@@ -2112,4 +2195,7 @@ var index_default = PtyLocalPlugin;
2112
2195
 
2113
2196
  exports.PtyLocalPlugin = PtyLocalPlugin;
2114
2197
  exports.default = index_default;
2198
+ exports.detectMuslLinux = detectMuslLinux;
2199
+ exports.isMuslLinux = isMuslLinux;
2115
2200
  exports.makePtyLocalSessionId = makePtyLocalSessionId;
2201
+ 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]
@@ -109,7 +111,9 @@ var USER_SELECTABLE_WORK_KINDS = [
109
111
  "directory",
110
112
  "awesome-repo",
111
113
  "repo",
112
- "app"
114
+ "app",
115
+ "knowledge-base",
116
+ "store"
113
117
  ];
114
118
  var WORK_KINDS = [...USER_SELECTABLE_WORK_KINDS, "company", "campaign", "project", "default"];
115
119
  new Set(WORK_KINDS);
@@ -119,6 +123,9 @@ var RECORD_VISIBILITIES = ["private", "team", "organization"];
119
123
  new Set(RECORD_VISIBILITIES);
120
124
  var RECORD_LIST_VIEWS = ["mine", "shared", "organization"];
121
125
  new Set(RECORD_LIST_VIEWS);
126
+ new Set(
127
+ "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(" ")
128
+ );
122
129
  var VERSION = "1.0.0";
123
130
  var GTM_SKILLS = [
124
131
  // ── research ────────────────────────────────────────────────────────
@@ -1858,12 +1865,85 @@ var TerminalNotProvisionedError = class extends Error {
1858
1865
  this.name = "TerminalNotProvisionedError";
1859
1866
  }
1860
1867
  };
1868
+ var GITHUB_FULL_SCOPES_ALL = [
1869
+ "user:email",
1870
+ "read:user",
1871
+ "repo",
1872
+ "delete_repo",
1873
+ "workflow",
1874
+ "write:repo_hook",
1875
+ "read:org",
1876
+ "project"
1877
+ ];
1878
+ var GITHUB_DELETE_REPO_SCOPE = "delete_repo";
1879
+ function isGithubDeleteRepoScopeEnabled(env = readEnv()) {
1880
+ return (env?.GITHUB_OAUTH_DELETE_REPO_SCOPE_ENABLED ?? "").trim().toLowerCase() === "true";
1881
+ }
1882
+ function readEnv() {
1883
+ return typeof process !== "undefined" ? process.env : void 0;
1884
+ }
1885
+ Object.freeze(
1886
+ GITHUB_FULL_SCOPES_ALL.filter((scope) => scope !== GITHUB_DELETE_REPO_SCOPE || isGithubDeleteRepoScopeEnabled())
1887
+ );
1888
+ var realProbe = () => ({
1889
+ platform: process.platform,
1890
+ readFile: (path) => {
1891
+ try {
1892
+ return readFileSync(path, "utf8");
1893
+ } catch {
1894
+ return null;
1895
+ }
1896
+ },
1897
+ readDir: (path) => {
1898
+ try {
1899
+ return readdirSync(path);
1900
+ } catch {
1901
+ return [];
1902
+ }
1903
+ },
1904
+ reportHeader: () => {
1905
+ const report = process.report;
1906
+ if (!report?.getReport) return void 0;
1907
+ const previous = report.excludeNetwork;
1908
+ report.excludeNetwork = true;
1909
+ try {
1910
+ return report.getReport().header;
1911
+ } finally {
1912
+ report.excludeNetwork = previous;
1913
+ }
1914
+ }
1915
+ });
1916
+ function detectMuslLinux(probe) {
1917
+ if (probe.platform !== "linux") return false;
1918
+ try {
1919
+ if (probe.readDir("/lib").some((name) => name.startsWith("ld-musl-"))) return true;
1920
+ const ldd = probe.readFile("/usr/bin/ldd");
1921
+ if (ldd !== null) return ldd.includes("musl");
1922
+ const header = probe.reportHeader();
1923
+ return header !== void 0 && !header.glibcVersionRuntime;
1924
+ } catch {
1925
+ return false;
1926
+ }
1927
+ }
1928
+ var cachedMusl = null;
1929
+ function isMuslLinux() {
1930
+ if (cachedMusl === null) cachedMusl = detectMuslLinux(realProbe());
1931
+ return cachedMusl;
1932
+ }
1933
+ function muslBlocksPtyAddon(resolvePackageJson, musl = isMuslLinux(), fileExists = existsSync) {
1934
+ if (!musl) return false;
1935
+ try {
1936
+ return !fileExists(join(dirname(resolvePackageJson()), "build", "Release", "pty.node"));
1937
+ } catch {
1938
+ return true;
1939
+ }
1940
+ }
1861
1941
 
1862
1942
  // src/pty-local.plugin.ts
1863
1943
  var DEFAULT_COLS = 120;
1864
1944
  var DEFAULT_ROWS = 32;
1865
1945
  function makePtyLocalSessionId(runId, pid) {
1866
- const suffix = typeof pid === "number" && Number.isFinite(pid) ? String(pid) : "no-pid";
1946
+ const suffix = typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? String(pid) : "no-pid";
1867
1947
  return `pty-local:${runId}:${suffix}`;
1868
1948
  }
1869
1949
  var PtyLocalPlugin = class {
@@ -2057,6 +2137,9 @@ var PtyLocalPlugin = class {
2057
2137
  }
2058
2138
  // ── runtime require ─────────────────────────────────────────────
2059
2139
  tryLoadPty() {
2140
+ if (muslBlocksPtyAddon(() => __require.resolve("@homebridge/node-pty-prebuilt-multiarch/package.json"))) {
2141
+ return null;
2142
+ }
2060
2143
  try {
2061
2144
  const required = __require("@homebridge/node-pty-prebuilt-multiarch");
2062
2145
  return typeof required?.spawn === "function" ? required : null;
@@ -2106,4 +2189,4 @@ var index_default = PtyLocalPlugin;
2106
2189
  * implementation adds is additive.
2107
2190
  */
2108
2191
 
2109
- export { PtyLocalPlugin, index_default as default, makePtyLocalSessionId };
2192
+ 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.16",
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.33"
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.4",
42
+ "@ever-works/plugin": "^1.2.33",
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:403c03d5658f29ab9bc38cdc2f4649f72f16f87d177d6af72119abe1d753c8eb",
74
+ "commit": "c6b8fd57745689ed9be529bed3fe4bd3d4f85b67",
75
+ "source": "https://github.com/ever-co/ever-works/tree/c6b8fd57745689ed9be529bed3fe4bd3d4f85b67/packages/plugins/pty-local"
76
76
  }
77
77
  }