usebeeline 0.1.184 → 0.1.185-rc.2
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/usebeeline.mjs +507 -361
- package/package.json +1 -1
package/dist/usebeeline.mjs
CHANGED
|
@@ -1701,8 +1701,8 @@ var require_errors = __commonJS({
|
|
|
1701
1701
|
"use strict";
|
|
1702
1702
|
var kUndiciError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR");
|
|
1703
1703
|
var UndiciError = class extends Error {
|
|
1704
|
-
constructor(
|
|
1705
|
-
super(
|
|
1704
|
+
constructor(message2) {
|
|
1705
|
+
super(message2);
|
|
1706
1706
|
this.name = "UndiciError";
|
|
1707
1707
|
this.code = "UND_ERR";
|
|
1708
1708
|
}
|
|
@@ -1713,10 +1713,10 @@ var require_errors = __commonJS({
|
|
|
1713
1713
|
};
|
|
1714
1714
|
var kConnectTimeoutError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_CONNECT_TIMEOUT");
|
|
1715
1715
|
var ConnectTimeoutError = class extends UndiciError {
|
|
1716
|
-
constructor(
|
|
1717
|
-
super(
|
|
1716
|
+
constructor(message2) {
|
|
1717
|
+
super(message2);
|
|
1718
1718
|
this.name = "ConnectTimeoutError";
|
|
1719
|
-
this.message =
|
|
1719
|
+
this.message = message2 || "Connect Timeout Error";
|
|
1720
1720
|
this.code = "UND_ERR_CONNECT_TIMEOUT";
|
|
1721
1721
|
}
|
|
1722
1722
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1726,10 +1726,10 @@ var require_errors = __commonJS({
|
|
|
1726
1726
|
};
|
|
1727
1727
|
var kHeadersTimeoutError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_HEADERS_TIMEOUT");
|
|
1728
1728
|
var HeadersTimeoutError = class extends UndiciError {
|
|
1729
|
-
constructor(
|
|
1730
|
-
super(
|
|
1729
|
+
constructor(message2) {
|
|
1730
|
+
super(message2);
|
|
1731
1731
|
this.name = "HeadersTimeoutError";
|
|
1732
|
-
this.message =
|
|
1732
|
+
this.message = message2 || "Headers Timeout Error";
|
|
1733
1733
|
this.code = "UND_ERR_HEADERS_TIMEOUT";
|
|
1734
1734
|
}
|
|
1735
1735
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1739,10 +1739,10 @@ var require_errors = __commonJS({
|
|
|
1739
1739
|
};
|
|
1740
1740
|
var kHeadersOverflowError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_HEADERS_OVERFLOW");
|
|
1741
1741
|
var HeadersOverflowError = class extends UndiciError {
|
|
1742
|
-
constructor(
|
|
1743
|
-
super(
|
|
1742
|
+
constructor(message2) {
|
|
1743
|
+
super(message2);
|
|
1744
1744
|
this.name = "HeadersOverflowError";
|
|
1745
|
-
this.message =
|
|
1745
|
+
this.message = message2 || "Headers Overflow Error";
|
|
1746
1746
|
this.code = "UND_ERR_HEADERS_OVERFLOW";
|
|
1747
1747
|
}
|
|
1748
1748
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1752,10 +1752,10 @@ var require_errors = __commonJS({
|
|
|
1752
1752
|
};
|
|
1753
1753
|
var kBodyTimeoutError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_BODY_TIMEOUT");
|
|
1754
1754
|
var BodyTimeoutError = class extends UndiciError {
|
|
1755
|
-
constructor(
|
|
1756
|
-
super(
|
|
1755
|
+
constructor(message2) {
|
|
1756
|
+
super(message2);
|
|
1757
1757
|
this.name = "BodyTimeoutError";
|
|
1758
|
-
this.message =
|
|
1758
|
+
this.message = message2 || "Body Timeout Error";
|
|
1759
1759
|
this.code = "UND_ERR_BODY_TIMEOUT";
|
|
1760
1760
|
}
|
|
1761
1761
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1765,10 +1765,10 @@ var require_errors = __commonJS({
|
|
|
1765
1765
|
};
|
|
1766
1766
|
var kResponseStatusCodeError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_RESPONSE_STATUS_CODE");
|
|
1767
1767
|
var ResponseStatusCodeError = class extends UndiciError {
|
|
1768
|
-
constructor(
|
|
1769
|
-
super(
|
|
1768
|
+
constructor(message2, statusCode, headers, body) {
|
|
1769
|
+
super(message2);
|
|
1770
1770
|
this.name = "ResponseStatusCodeError";
|
|
1771
|
-
this.message =
|
|
1771
|
+
this.message = message2 || "Response Status Code Error";
|
|
1772
1772
|
this.code = "UND_ERR_RESPONSE_STATUS_CODE";
|
|
1773
1773
|
this.body = body;
|
|
1774
1774
|
this.status = statusCode;
|
|
@@ -1782,10 +1782,10 @@ var require_errors = __commonJS({
|
|
|
1782
1782
|
};
|
|
1783
1783
|
var kInvalidArgumentError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_INVALID_ARG");
|
|
1784
1784
|
var InvalidArgumentError = class extends UndiciError {
|
|
1785
|
-
constructor(
|
|
1786
|
-
super(
|
|
1785
|
+
constructor(message2) {
|
|
1786
|
+
super(message2);
|
|
1787
1787
|
this.name = "InvalidArgumentError";
|
|
1788
|
-
this.message =
|
|
1788
|
+
this.message = message2 || "Invalid Argument Error";
|
|
1789
1789
|
this.code = "UND_ERR_INVALID_ARG";
|
|
1790
1790
|
}
|
|
1791
1791
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1795,10 +1795,10 @@ var require_errors = __commonJS({
|
|
|
1795
1795
|
};
|
|
1796
1796
|
var kInvalidReturnValueError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_INVALID_RETURN_VALUE");
|
|
1797
1797
|
var InvalidReturnValueError = class extends UndiciError {
|
|
1798
|
-
constructor(
|
|
1799
|
-
super(
|
|
1798
|
+
constructor(message2) {
|
|
1799
|
+
super(message2);
|
|
1800
1800
|
this.name = "InvalidReturnValueError";
|
|
1801
|
-
this.message =
|
|
1801
|
+
this.message = message2 || "Invalid Return Value Error";
|
|
1802
1802
|
this.code = "UND_ERR_INVALID_RETURN_VALUE";
|
|
1803
1803
|
}
|
|
1804
1804
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1808,10 +1808,10 @@ var require_errors = __commonJS({
|
|
|
1808
1808
|
};
|
|
1809
1809
|
var kAbortError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_ABORT");
|
|
1810
1810
|
var AbortError = class extends UndiciError {
|
|
1811
|
-
constructor(
|
|
1812
|
-
super(
|
|
1811
|
+
constructor(message2) {
|
|
1812
|
+
super(message2);
|
|
1813
1813
|
this.name = "AbortError";
|
|
1814
|
-
this.message =
|
|
1814
|
+
this.message = message2 || "The operation was aborted";
|
|
1815
1815
|
this.code = "UND_ERR_ABORT";
|
|
1816
1816
|
}
|
|
1817
1817
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1821,10 +1821,10 @@ var require_errors = __commonJS({
|
|
|
1821
1821
|
};
|
|
1822
1822
|
var kRequestAbortedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_ABORTED");
|
|
1823
1823
|
var RequestAbortedError = class extends AbortError {
|
|
1824
|
-
constructor(
|
|
1825
|
-
super(
|
|
1824
|
+
constructor(message2) {
|
|
1825
|
+
super(message2);
|
|
1826
1826
|
this.name = "AbortError";
|
|
1827
|
-
this.message =
|
|
1827
|
+
this.message = message2 || "Request aborted";
|
|
1828
1828
|
this.code = "UND_ERR_ABORTED";
|
|
1829
1829
|
}
|
|
1830
1830
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1834,10 +1834,10 @@ var require_errors = __commonJS({
|
|
|
1834
1834
|
};
|
|
1835
1835
|
var kInformationalError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_INFO");
|
|
1836
1836
|
var InformationalError = class extends UndiciError {
|
|
1837
|
-
constructor(
|
|
1838
|
-
super(
|
|
1837
|
+
constructor(message2) {
|
|
1838
|
+
super(message2);
|
|
1839
1839
|
this.name = "InformationalError";
|
|
1840
|
-
this.message =
|
|
1840
|
+
this.message = message2 || "Request information";
|
|
1841
1841
|
this.code = "UND_ERR_INFO";
|
|
1842
1842
|
}
|
|
1843
1843
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1847,10 +1847,10 @@ var require_errors = __commonJS({
|
|
|
1847
1847
|
};
|
|
1848
1848
|
var kRequestContentLengthMismatchError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_REQ_CONTENT_LENGTH_MISMATCH");
|
|
1849
1849
|
var RequestContentLengthMismatchError = class extends UndiciError {
|
|
1850
|
-
constructor(
|
|
1851
|
-
super(
|
|
1850
|
+
constructor(message2) {
|
|
1851
|
+
super(message2);
|
|
1852
1852
|
this.name = "RequestContentLengthMismatchError";
|
|
1853
|
-
this.message =
|
|
1853
|
+
this.message = message2 || "Request body length does not match content-length header";
|
|
1854
1854
|
this.code = "UND_ERR_REQ_CONTENT_LENGTH_MISMATCH";
|
|
1855
1855
|
}
|
|
1856
1856
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1860,10 +1860,10 @@ var require_errors = __commonJS({
|
|
|
1860
1860
|
};
|
|
1861
1861
|
var kResponseContentLengthMismatchError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_RES_CONTENT_LENGTH_MISMATCH");
|
|
1862
1862
|
var ResponseContentLengthMismatchError = class extends UndiciError {
|
|
1863
|
-
constructor(
|
|
1864
|
-
super(
|
|
1863
|
+
constructor(message2) {
|
|
1864
|
+
super(message2);
|
|
1865
1865
|
this.name = "ResponseContentLengthMismatchError";
|
|
1866
|
-
this.message =
|
|
1866
|
+
this.message = message2 || "Response body length does not match content-length header";
|
|
1867
1867
|
this.code = "UND_ERR_RES_CONTENT_LENGTH_MISMATCH";
|
|
1868
1868
|
}
|
|
1869
1869
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1873,10 +1873,10 @@ var require_errors = __commonJS({
|
|
|
1873
1873
|
};
|
|
1874
1874
|
var kClientDestroyedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_DESTROYED");
|
|
1875
1875
|
var ClientDestroyedError = class extends UndiciError {
|
|
1876
|
-
constructor(
|
|
1877
|
-
super(
|
|
1876
|
+
constructor(message2) {
|
|
1877
|
+
super(message2);
|
|
1878
1878
|
this.name = "ClientDestroyedError";
|
|
1879
|
-
this.message =
|
|
1879
|
+
this.message = message2 || "The client is destroyed";
|
|
1880
1880
|
this.code = "UND_ERR_DESTROYED";
|
|
1881
1881
|
}
|
|
1882
1882
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1886,10 +1886,10 @@ var require_errors = __commonJS({
|
|
|
1886
1886
|
};
|
|
1887
1887
|
var kClientClosedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_CLOSED");
|
|
1888
1888
|
var ClientClosedError = class extends UndiciError {
|
|
1889
|
-
constructor(
|
|
1890
|
-
super(
|
|
1889
|
+
constructor(message2) {
|
|
1890
|
+
super(message2);
|
|
1891
1891
|
this.name = "ClientClosedError";
|
|
1892
|
-
this.message =
|
|
1892
|
+
this.message = message2 || "The client is closed";
|
|
1893
1893
|
this.code = "UND_ERR_CLOSED";
|
|
1894
1894
|
}
|
|
1895
1895
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1899,10 +1899,10 @@ var require_errors = __commonJS({
|
|
|
1899
1899
|
};
|
|
1900
1900
|
var kSocketError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_SOCKET");
|
|
1901
1901
|
var SocketError = class extends UndiciError {
|
|
1902
|
-
constructor(
|
|
1903
|
-
super(
|
|
1902
|
+
constructor(message2, socket) {
|
|
1903
|
+
super(message2);
|
|
1904
1904
|
this.name = "SocketError";
|
|
1905
|
-
this.message =
|
|
1905
|
+
this.message = message2 || "Socket error";
|
|
1906
1906
|
this.code = "UND_ERR_SOCKET";
|
|
1907
1907
|
this.socket = socket;
|
|
1908
1908
|
}
|
|
@@ -1913,10 +1913,10 @@ var require_errors = __commonJS({
|
|
|
1913
1913
|
};
|
|
1914
1914
|
var kNotSupportedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_NOT_SUPPORTED");
|
|
1915
1915
|
var NotSupportedError = class extends UndiciError {
|
|
1916
|
-
constructor(
|
|
1917
|
-
super(
|
|
1916
|
+
constructor(message2) {
|
|
1917
|
+
super(message2);
|
|
1918
1918
|
this.name = "NotSupportedError";
|
|
1919
|
-
this.message =
|
|
1919
|
+
this.message = message2 || "Not supported error";
|
|
1920
1920
|
this.code = "UND_ERR_NOT_SUPPORTED";
|
|
1921
1921
|
}
|
|
1922
1922
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1926,10 +1926,10 @@ var require_errors = __commonJS({
|
|
|
1926
1926
|
};
|
|
1927
1927
|
var kBalancedPoolMissingUpstreamError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_BPL_MISSING_UPSTREAM");
|
|
1928
1928
|
var BalancedPoolMissingUpstreamError = class extends UndiciError {
|
|
1929
|
-
constructor(
|
|
1930
|
-
super(
|
|
1929
|
+
constructor(message2) {
|
|
1930
|
+
super(message2);
|
|
1931
1931
|
this.name = "MissingUpstreamError";
|
|
1932
|
-
this.message =
|
|
1932
|
+
this.message = message2 || "No upstream has been added to the BalancedPool";
|
|
1933
1933
|
this.code = "UND_ERR_BPL_MISSING_UPSTREAM";
|
|
1934
1934
|
}
|
|
1935
1935
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1939,8 +1939,8 @@ var require_errors = __commonJS({
|
|
|
1939
1939
|
};
|
|
1940
1940
|
var kHTTPParserError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_HTTP_PARSER");
|
|
1941
1941
|
var HTTPParserError = class extends Error {
|
|
1942
|
-
constructor(
|
|
1943
|
-
super(
|
|
1942
|
+
constructor(message2, code, data) {
|
|
1943
|
+
super(message2);
|
|
1944
1944
|
this.name = "HTTPParserError";
|
|
1945
1945
|
this.code = code ? `HPE_${code}` : void 0;
|
|
1946
1946
|
this.data = data ? data.toString() : void 0;
|
|
@@ -1952,10 +1952,10 @@ var require_errors = __commonJS({
|
|
|
1952
1952
|
};
|
|
1953
1953
|
var kResponseExceededMaxSizeError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_RES_EXCEEDED_MAX_SIZE");
|
|
1954
1954
|
var ResponseExceededMaxSizeError = class extends UndiciError {
|
|
1955
|
-
constructor(
|
|
1956
|
-
super(
|
|
1955
|
+
constructor(message2) {
|
|
1956
|
+
super(message2);
|
|
1957
1957
|
this.name = "ResponseExceededMaxSizeError";
|
|
1958
|
-
this.message =
|
|
1958
|
+
this.message = message2 || "Response content exceeded max size";
|
|
1959
1959
|
this.code = "UND_ERR_RES_EXCEEDED_MAX_SIZE";
|
|
1960
1960
|
}
|
|
1961
1961
|
static [Symbol.hasInstance](instance) {
|
|
@@ -1965,10 +1965,10 @@ var require_errors = __commonJS({
|
|
|
1965
1965
|
};
|
|
1966
1966
|
var kRequestRetryError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_REQ_RETRY");
|
|
1967
1967
|
var RequestRetryError = class extends UndiciError {
|
|
1968
|
-
constructor(
|
|
1969
|
-
super(
|
|
1968
|
+
constructor(message2, code, { headers, data }) {
|
|
1969
|
+
super(message2);
|
|
1970
1970
|
this.name = "RequestRetryError";
|
|
1971
|
-
this.message =
|
|
1971
|
+
this.message = message2 || "Request retry error";
|
|
1972
1972
|
this.code = "UND_ERR_REQ_RETRY";
|
|
1973
1973
|
this.statusCode = code;
|
|
1974
1974
|
this.data = data;
|
|
@@ -1981,10 +1981,10 @@ var require_errors = __commonJS({
|
|
|
1981
1981
|
};
|
|
1982
1982
|
var kResponseError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_RESPONSE");
|
|
1983
1983
|
var ResponseError = class extends UndiciError {
|
|
1984
|
-
constructor(
|
|
1985
|
-
super(
|
|
1984
|
+
constructor(message2, code, { headers, data }) {
|
|
1985
|
+
super(message2);
|
|
1986
1986
|
this.name = "ResponseError";
|
|
1987
|
-
this.message =
|
|
1987
|
+
this.message = message2 || "Response error";
|
|
1988
1988
|
this.code = "UND_ERR_RESPONSE";
|
|
1989
1989
|
this.statusCode = code;
|
|
1990
1990
|
this.data = data;
|
|
@@ -1997,10 +1997,10 @@ var require_errors = __commonJS({
|
|
|
1997
1997
|
};
|
|
1998
1998
|
var kSecureProxyConnectionError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_PRX_TLS");
|
|
1999
1999
|
var SecureProxyConnectionError = class extends UndiciError {
|
|
2000
|
-
constructor(cause,
|
|
2001
|
-
super(
|
|
2000
|
+
constructor(cause, message2, options) {
|
|
2001
|
+
super(message2, { cause, ...options ?? {} });
|
|
2002
2002
|
this.name = "SecureProxyConnectionError";
|
|
2003
|
-
this.message =
|
|
2003
|
+
this.message = message2 || "Secure Proxy Connection failed";
|
|
2004
2004
|
this.code = "UND_ERR_PRX_TLS";
|
|
2005
2005
|
this.cause = cause;
|
|
2006
2006
|
}
|
|
@@ -2011,10 +2011,10 @@ var require_errors = __commonJS({
|
|
|
2011
2011
|
};
|
|
2012
2012
|
var kMessageSizeExceededError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_WS_MESSAGE_SIZE_EXCEEDED");
|
|
2013
2013
|
var MessageSizeExceededError = class extends UndiciError {
|
|
2014
|
-
constructor(
|
|
2015
|
-
super(
|
|
2014
|
+
constructor(message2) {
|
|
2015
|
+
super(message2);
|
|
2016
2016
|
this.name = "MessageSizeExceededError";
|
|
2017
|
-
this.message =
|
|
2017
|
+
this.message = message2 || "Max decompressed message size exceeded";
|
|
2018
2018
|
this.code = "UND_ERR_WS_MESSAGE_SIZE_EXCEEDED";
|
|
2019
2019
|
}
|
|
2020
2020
|
static [Symbol.hasInstance](instance) {
|
|
@@ -3961,14 +3961,14 @@ var require_connect = __commonJS({
|
|
|
3961
3961
|
if (socket == null) {
|
|
3962
3962
|
return;
|
|
3963
3963
|
}
|
|
3964
|
-
let
|
|
3964
|
+
let message2 = "Connect Timeout Error";
|
|
3965
3965
|
if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) {
|
|
3966
|
-
|
|
3966
|
+
message2 += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`;
|
|
3967
3967
|
} else {
|
|
3968
|
-
|
|
3968
|
+
message2 += ` (attempted address: ${opts.hostname}:${opts.port},`;
|
|
3969
3969
|
}
|
|
3970
|
-
|
|
3971
|
-
util.destroy(socket, new ConnectTimeoutError(
|
|
3970
|
+
message2 += ` timeout: ${opts.timeout}ms)`;
|
|
3971
|
+
util.destroy(socket, new ConnectTimeoutError(message2));
|
|
3972
3972
|
}
|
|
3973
3973
|
module.exports = buildConnector;
|
|
3974
3974
|
}
|
|
@@ -4950,15 +4950,15 @@ var require_webidl = __commonJS({
|
|
|
4950
4950
|
webidl.converters = {};
|
|
4951
4951
|
webidl.util = {};
|
|
4952
4952
|
webidl.errors = {};
|
|
4953
|
-
webidl.errors.exception = function(
|
|
4954
|
-
return new TypeError(`${
|
|
4953
|
+
webidl.errors.exception = function(message2) {
|
|
4954
|
+
return new TypeError(`${message2.header}: ${message2.message}`);
|
|
4955
4955
|
};
|
|
4956
4956
|
webidl.errors.conversionFailed = function(context) {
|
|
4957
4957
|
const plural = context.types.length === 1 ? "" : " one of";
|
|
4958
|
-
const
|
|
4958
|
+
const message2 = `${context.argument} could not be converted to${plural}: ${context.types.join(", ")}.`;
|
|
4959
4959
|
return webidl.errors.exception({
|
|
4960
4960
|
header: context.prefix,
|
|
4961
|
-
message
|
|
4961
|
+
message: message2
|
|
4962
4962
|
});
|
|
4963
4963
|
};
|
|
4964
4964
|
webidl.errors.invalidArgument = function(context) {
|
|
@@ -7071,7 +7071,7 @@ var require_client_h1 = __commonJS({
|
|
|
7071
7071
|
kResume,
|
|
7072
7072
|
kHTTPContext
|
|
7073
7073
|
} = require_symbols();
|
|
7074
|
-
var
|
|
7074
|
+
var constants2 = require_constants2();
|
|
7075
7075
|
var EMPTY_BUF = Buffer.alloc(0);
|
|
7076
7076
|
var FastBuffer = Buffer[Symbol.species];
|
|
7077
7077
|
var addListener = util.addListener;
|
|
@@ -7146,7 +7146,7 @@ var require_client_h1 = __commonJS({
|
|
|
7146
7146
|
constructor(client, socket, { exports: exports2 }) {
|
|
7147
7147
|
assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0);
|
|
7148
7148
|
this.llhttp = exports2;
|
|
7149
|
-
this.ptr = this.llhttp.llhttp_alloc(
|
|
7149
|
+
this.ptr = this.llhttp.llhttp_alloc(constants2.TYPE.RESPONSE);
|
|
7150
7150
|
this.client = client;
|
|
7151
7151
|
this.socket = socket;
|
|
7152
7152
|
this.timeout = null;
|
|
@@ -7241,11 +7241,11 @@ var require_client_h1 = __commonJS({
|
|
|
7241
7241
|
currentBufferRef = null;
|
|
7242
7242
|
}
|
|
7243
7243
|
const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr;
|
|
7244
|
-
if (ret !==
|
|
7244
|
+
if (ret !== constants2.ERROR.OK) {
|
|
7245
7245
|
const body = data.subarray(offset);
|
|
7246
|
-
if (ret ===
|
|
7246
|
+
if (ret === constants2.ERROR.PAUSED_UPGRADE) {
|
|
7247
7247
|
this.onUpgrade(body);
|
|
7248
|
-
} else if (ret ===
|
|
7248
|
+
} else if (ret === constants2.ERROR.PAUSED) {
|
|
7249
7249
|
this.paused = true;
|
|
7250
7250
|
socket.unshift(body);
|
|
7251
7251
|
} else {
|
|
@@ -7268,10 +7268,10 @@ var require_client_h1 = __commonJS({
|
|
|
7268
7268
|
} finally {
|
|
7269
7269
|
currentParser = null;
|
|
7270
7270
|
}
|
|
7271
|
-
if (ret ===
|
|
7271
|
+
if (ret === constants2.ERROR.OK) {
|
|
7272
7272
|
return null;
|
|
7273
7273
|
}
|
|
7274
|
-
if (ret ===
|
|
7274
|
+
if (ret === constants2.ERROR.PAUSED || ret === constants2.ERROR.PAUSED_UPGRADE) {
|
|
7275
7275
|
this.paused = true;
|
|
7276
7276
|
return null;
|
|
7277
7277
|
}
|
|
@@ -7283,12 +7283,12 @@ var require_client_h1 = __commonJS({
|
|
|
7283
7283
|
return new ResponseContentLengthMismatchError();
|
|
7284
7284
|
}
|
|
7285
7285
|
const ptr = llhttp.llhttp_get_error_reason(this.ptr);
|
|
7286
|
-
let
|
|
7286
|
+
let message2 = "";
|
|
7287
7287
|
if (ptr) {
|
|
7288
7288
|
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
|
|
7289
|
-
|
|
7289
|
+
message2 = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
|
|
7290
7290
|
}
|
|
7291
|
-
return new HTTPParserError(
|
|
7291
|
+
return new HTTPParserError(message2, constants2.ERROR[ret], data);
|
|
7292
7292
|
}
|
|
7293
7293
|
destroy() {
|
|
7294
7294
|
assert(this.ptr != null);
|
|
@@ -7467,7 +7467,7 @@ var require_client_h1 = __commonJS({
|
|
|
7467
7467
|
socket[kBlocking] = false;
|
|
7468
7468
|
client[kResume]();
|
|
7469
7469
|
}
|
|
7470
|
-
return pause ?
|
|
7470
|
+
return pause ? constants2.ERROR.PAUSED : 0;
|
|
7471
7471
|
}
|
|
7472
7472
|
onBody(buf) {
|
|
7473
7473
|
const { client, socket, statusCode, maxResponseSize } = this;
|
|
@@ -7489,7 +7489,7 @@ var require_client_h1 = __commonJS({
|
|
|
7489
7489
|
}
|
|
7490
7490
|
this.bytesRead += buf.length;
|
|
7491
7491
|
if (request2.onData(buf) === false) {
|
|
7492
|
-
return
|
|
7492
|
+
return constants2.ERROR.PAUSED;
|
|
7493
7493
|
}
|
|
7494
7494
|
}
|
|
7495
7495
|
onMessageComplete() {
|
|
@@ -7525,13 +7525,13 @@ var require_client_h1 = __commonJS({
|
|
|
7525
7525
|
if (socket[kWriting]) {
|
|
7526
7526
|
assert(client[kRunning] === 0);
|
|
7527
7527
|
util.destroy(socket, new InformationalError("reset"));
|
|
7528
|
-
return
|
|
7528
|
+
return constants2.ERROR.PAUSED;
|
|
7529
7529
|
} else if (!shouldKeepAlive) {
|
|
7530
7530
|
util.destroy(socket, new InformationalError("reset"));
|
|
7531
|
-
return
|
|
7531
|
+
return constants2.ERROR.PAUSED;
|
|
7532
7532
|
} else if (socket[kReset] && client[kRunning] === 0) {
|
|
7533
7533
|
util.destroy(socket, new InformationalError("reset"));
|
|
7534
|
-
return
|
|
7534
|
+
return constants2.ERROR.PAUSED;
|
|
7535
7535
|
} else if (client[kPipelining] == null || client[kPipelining] === 1) {
|
|
7536
7536
|
setImmediate(() => client[kResume]());
|
|
7537
7537
|
} else {
|
|
@@ -10981,9 +10981,9 @@ var require_util3 = __commonJS({
|
|
|
10981
10981
|
chunks = [];
|
|
10982
10982
|
length = 0;
|
|
10983
10983
|
}
|
|
10984
|
-
const
|
|
10984
|
+
const message2 = `Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ""}`;
|
|
10985
10985
|
if (statusCode === 204 || !contentType || !length) {
|
|
10986
|
-
queueMicrotask(() => callback(new ResponseStatusCodeError(
|
|
10986
|
+
queueMicrotask(() => callback(new ResponseStatusCodeError(message2, statusCode, headers)));
|
|
10987
10987
|
return;
|
|
10988
10988
|
}
|
|
10989
10989
|
const stackTraceLimit = Error.stackTraceLimit;
|
|
@@ -10999,7 +10999,7 @@ var require_util3 = __commonJS({
|
|
|
10999
10999
|
} finally {
|
|
11000
11000
|
Error.stackTraceLimit = stackTraceLimit;
|
|
11001
11001
|
}
|
|
11002
|
-
queueMicrotask(() => callback(new ResponseStatusCodeError(
|
|
11002
|
+
queueMicrotask(() => callback(new ResponseStatusCodeError(message2, statusCode, headers, payload)));
|
|
11003
11003
|
}
|
|
11004
11004
|
var isContentTypeApplicationJson = (contentType) => {
|
|
11005
11005
|
return contentType.length > 15 && contentType[11] === "/" && contentType[0] === "a" && contentType[1] === "p" && contentType[2] === "p" && contentType[3] === "l" && contentType[4] === "i" && contentType[5] === "c" && contentType[6] === "a" && contentType[7] === "t" && contentType[8] === "i" && contentType[9] === "o" && contentType[10] === "n" && contentType[12] === "j" && contentType[13] === "s" && contentType[14] === "o" && contentType[15] === "n";
|
|
@@ -11826,11 +11826,11 @@ var require_mock_errors = __commonJS({
|
|
|
11826
11826
|
var { UndiciError } = require_errors();
|
|
11827
11827
|
var kMockNotMatchedError = /* @__PURE__ */ Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED");
|
|
11828
11828
|
var MockNotMatchedError = class _MockNotMatchedError extends UndiciError {
|
|
11829
|
-
constructor(
|
|
11830
|
-
super(
|
|
11829
|
+
constructor(message2) {
|
|
11830
|
+
super(message2);
|
|
11831
11831
|
Error.captureStackTrace(this, _MockNotMatchedError);
|
|
11832
11832
|
this.name = "MockNotMatchedError";
|
|
11833
|
-
this.message =
|
|
11833
|
+
this.message = message2 || "The request does not match any registered mock dispatches";
|
|
11834
11834
|
this.code = "UND_MOCK_ERR_MOCK_NOT_MATCHED";
|
|
11835
11835
|
}
|
|
11836
11836
|
static [Symbol.hasInstance](instance) {
|
|
@@ -19470,15 +19470,15 @@ var require_websocket = __commonJS({
|
|
|
19470
19470
|
this.ws[kResponse].socket.resume();
|
|
19471
19471
|
}
|
|
19472
19472
|
function onParserError(err) {
|
|
19473
|
-
let
|
|
19473
|
+
let message2;
|
|
19474
19474
|
let code;
|
|
19475
19475
|
if (err instanceof CloseEvent) {
|
|
19476
|
-
|
|
19476
|
+
message2 = err.reason;
|
|
19477
19477
|
code = err.code;
|
|
19478
19478
|
} else {
|
|
19479
|
-
|
|
19479
|
+
message2 = err.message;
|
|
19480
19480
|
}
|
|
19481
|
-
fireEvent("error", this, () => new ErrorEvent("error", { error: err, message }));
|
|
19481
|
+
fireEvent("error", this, () => new ErrorEvent("error", { error: err, message: message2 }));
|
|
19482
19482
|
closeWebSocketConnection(this, code);
|
|
19483
19483
|
}
|
|
19484
19484
|
module.exports = {
|
|
@@ -20675,35 +20675,6 @@ var init_beeline_api = __esm({
|
|
|
20675
20675
|
}
|
|
20676
20676
|
});
|
|
20677
20677
|
|
|
20678
|
-
// apps/body/dist/process-exit.js
|
|
20679
|
-
import { spawn as spawn5 } from "node:child_process";
|
|
20680
|
-
function waitForProcessExit(pid, signal) {
|
|
20681
|
-
return new Promise((resolve13, reject) => {
|
|
20682
|
-
const child = spawn5("/usr/bin/python3", ["-c", WAIT, String(pid)], { stdio: "ignore", signal });
|
|
20683
|
-
child.once("error", reject);
|
|
20684
|
-
child.once("close", (code) => code === 0 ? resolve13() : reject(new Error(`process exit observer failed (${code})`)));
|
|
20685
|
-
});
|
|
20686
|
-
}
|
|
20687
|
-
var WAIT;
|
|
20688
|
-
var init_process_exit = __esm({
|
|
20689
|
-
"apps/body/dist/process-exit.js"() {
|
|
20690
|
-
"use strict";
|
|
20691
|
-
WAIT = `import os,sys,select
|
|
20692
|
-
pid=int(sys.argv[1])
|
|
20693
|
-
try:
|
|
20694
|
-
if hasattr(os,'pidfd_open'):
|
|
20695
|
-
fd=os.pidfd_open(pid)
|
|
20696
|
-
try: select.select([fd],[],[])
|
|
20697
|
-
finally: os.close(fd)
|
|
20698
|
-
else:
|
|
20699
|
-
queue=select.kqueue()
|
|
20700
|
-
try: queue.control([select.kevent(pid,filter=select.KQ_FILTER_PROC,flags=select.KQ_EV_ADD|select.KQ_EV_ONESHOT,fflags=select.KQ_NOTE_EXIT)],1)
|
|
20701
|
-
finally: queue.close()
|
|
20702
|
-
except ProcessLookupError: pass
|
|
20703
|
-
`;
|
|
20704
|
-
}
|
|
20705
|
-
});
|
|
20706
|
-
|
|
20707
20678
|
// packages/api-contract/dist/phone-types-room-live-delta.js
|
|
20708
20679
|
var init_phone_types_room_live_delta = __esm({
|
|
20709
20680
|
"packages/api-contract/dist/phone-types-room-live-delta.js"() {
|
|
@@ -24221,12 +24192,178 @@ var init_sessions = __esm({
|
|
|
24221
24192
|
}
|
|
24222
24193
|
});
|
|
24223
24194
|
|
|
24224
|
-
// apps/body/dist/
|
|
24195
|
+
// apps/body/dist/process-exit.js
|
|
24196
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
24197
|
+
function waitForProcessExit(pid, signal) {
|
|
24198
|
+
return new Promise((resolve13, reject) => {
|
|
24199
|
+
const child = spawn5("/usr/bin/python3", ["-c", WAIT, String(pid)], { stdio: "ignore", signal });
|
|
24200
|
+
child.once("error", reject);
|
|
24201
|
+
child.once("close", (code) => code === 0 ? resolve13() : reject(new Error(`process exit observer failed (${code})`)));
|
|
24202
|
+
});
|
|
24203
|
+
}
|
|
24204
|
+
var WAIT;
|
|
24205
|
+
var init_process_exit = __esm({
|
|
24206
|
+
"apps/body/dist/process-exit.js"() {
|
|
24207
|
+
"use strict";
|
|
24208
|
+
WAIT = `import os,sys,select
|
|
24209
|
+
pid=int(sys.argv[1])
|
|
24210
|
+
try:
|
|
24211
|
+
if hasattr(os,'pidfd_open'):
|
|
24212
|
+
fd=os.pidfd_open(pid)
|
|
24213
|
+
try: select.select([fd],[],[])
|
|
24214
|
+
finally: os.close(fd)
|
|
24215
|
+
else:
|
|
24216
|
+
queue=select.kqueue()
|
|
24217
|
+
try: queue.control([select.kevent(pid,filter=select.KQ_FILTER_PROC,flags=select.KQ_EV_ADD|select.KQ_EV_ONESHOT,fflags=select.KQ_NOTE_EXIT)],1)
|
|
24218
|
+
finally: queue.close()
|
|
24219
|
+
except ProcessLookupError: pass
|
|
24220
|
+
`;
|
|
24221
|
+
}
|
|
24222
|
+
});
|
|
24223
|
+
|
|
24224
|
+
// apps/body/dist/session-join/bridge-launch.js
|
|
24225
24225
|
import { execFileSync, spawn as spawn6 } from "node:child_process";
|
|
24226
|
-
import {
|
|
24227
|
-
import {
|
|
24228
|
-
import { basename as basename4, join as join7, resolve as resolve10 } from "node:path";
|
|
24226
|
+
import { closeSync as closeSync3, existsSync as existsSync2, mkdirSync as mkdirSync3, mkdtempSync, openSync as openSync3, readFileSync as readFileSync6, renameSync as renameSync2, rmSync as rmSync3, watch as watch4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
24227
|
+
import { basename as basename4, dirname as dirname7, join as join7, resolve as resolve10 } from "node:path";
|
|
24229
24228
|
import { createHash as createHash6 } from "node:crypto";
|
|
24229
|
+
function bridgeRunning(dir) {
|
|
24230
|
+
try {
|
|
24231
|
+
const pid = Number(readFileSync6(join7(dir, "bridge.pid"), "utf8"));
|
|
24232
|
+
return pid > 0 && pidAlive(pid);
|
|
24233
|
+
} catch {
|
|
24234
|
+
return false;
|
|
24235
|
+
}
|
|
24236
|
+
}
|
|
24237
|
+
function bundleDigest(runner2) {
|
|
24238
|
+
return createHash6("sha256").update(readFileSync6(runner2.bundle)).digest("hex");
|
|
24239
|
+
}
|
|
24240
|
+
function bridgeOwner(dir) {
|
|
24241
|
+
try {
|
|
24242
|
+
return JSON.parse(readFileSync6(join7(dir, "bridge-owner.json"), "utf8"));
|
|
24243
|
+
} catch {
|
|
24244
|
+
return void 0;
|
|
24245
|
+
}
|
|
24246
|
+
}
|
|
24247
|
+
function isBridgeProcess(pid) {
|
|
24248
|
+
try {
|
|
24249
|
+
if (process.platform === "linux") {
|
|
24250
|
+
const args2 = readFileSync6(`/proc/${pid}/cmdline`, "utf8").split("\0").filter(Boolean);
|
|
24251
|
+
return args2.length === 4 && /^node(?:\.exe)?$/.test(basename4(args2[0])) && /^(?:beeline|usebeeline\.mjs|recovery-cli\.mjs)$/.test(basename4(args2[1])) && args2[2] === "session" && args2[3] === "bridge";
|
|
24252
|
+
}
|
|
24253
|
+
const args = execFileSync("ps", ["-ww", "-p", String(pid), "-o", "args="], { encoding: "utf8" }).trim();
|
|
24254
|
+
return /(?:^|\/)node\s+.*\/(?:beeline|usebeeline\.mjs|recovery-cli\.mjs) session bridge$/.test(args);
|
|
24255
|
+
} catch {
|
|
24256
|
+
return false;
|
|
24257
|
+
}
|
|
24258
|
+
}
|
|
24259
|
+
function message(child, expected) {
|
|
24260
|
+
return new Promise((done, fail) => {
|
|
24261
|
+
const finish = (error) => {
|
|
24262
|
+
child.removeListener("message", received);
|
|
24263
|
+
child.removeListener("error", failed);
|
|
24264
|
+
child.removeListener("exit", exited);
|
|
24265
|
+
if (error)
|
|
24266
|
+
fail(error);
|
|
24267
|
+
else
|
|
24268
|
+
done();
|
|
24269
|
+
};
|
|
24270
|
+
const received = (value) => {
|
|
24271
|
+
if (value === expected)
|
|
24272
|
+
finish();
|
|
24273
|
+
};
|
|
24274
|
+
const failed = (error) => finish(error);
|
|
24275
|
+
const exited = () => finish(new Error(`Beeline bridge exited before ${expected}; see bridge.log`));
|
|
24276
|
+
child.on("message", received);
|
|
24277
|
+
child.once("error", failed);
|
|
24278
|
+
child.once("exit", exited);
|
|
24279
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
24280
|
+
exited();
|
|
24281
|
+
});
|
|
24282
|
+
}
|
|
24283
|
+
async function ensureBridge(dir, runner2, env = process.env) {
|
|
24284
|
+
await withKernelLock(`beeline-session-bridge:${resolve10(dir)}`, async () => {
|
|
24285
|
+
const source = runner2.candidate ?? runner2.bundle;
|
|
24286
|
+
const digest = bundleDigest({ ...runner2, bundle: source });
|
|
24287
|
+
const pidFile = join7(dir, "bridge.pid");
|
|
24288
|
+
let old;
|
|
24289
|
+
if (bridgeRunning(dir)) {
|
|
24290
|
+
old = Number(readFileSync6(pidFile, "utf8"));
|
|
24291
|
+
if (!isBridgeProcess(old))
|
|
24292
|
+
throw new Error("Beeline bridge PID belongs to an unrecognized process; refusing takeover");
|
|
24293
|
+
const owner = bridgeOwner(dir);
|
|
24294
|
+
if (owner?.pid === old && owner.digest === digest)
|
|
24295
|
+
return;
|
|
24296
|
+
}
|
|
24297
|
+
mkdirSync3(dir, { recursive: true, mode: 448 });
|
|
24298
|
+
const stable = join7(dir, "usebeeline.mjs");
|
|
24299
|
+
const previous = existsSync2(stable) ? readFileSync6(stable) : void 0;
|
|
24300
|
+
const staging = mkdtempSync(join7(dirname7(dir), ".beeline-bridge-candidate-"));
|
|
24301
|
+
const bundle = join7(staging, "usebeeline.mjs");
|
|
24302
|
+
writeFileSync3(bundle, readFileSync6(source), { mode: 384 });
|
|
24303
|
+
const out = openSync3(join7(dir, "bridge.log"), "a", 384);
|
|
24304
|
+
const child = spawn6(runner2.node, [bundle, "session", "bridge"], {
|
|
24305
|
+
detached: true,
|
|
24306
|
+
stdio: ["ignore", out, out, "ipc"],
|
|
24307
|
+
env: { ...env, BEELINE_SESSION_BUNDLE: bundle, BEELINE_SESSION_BRIDGE_STAGING: "1" }
|
|
24308
|
+
});
|
|
24309
|
+
closeSync3(out);
|
|
24310
|
+
let published = false;
|
|
24311
|
+
try {
|
|
24312
|
+
await message(child, "ready");
|
|
24313
|
+
const active = message(child, "active");
|
|
24314
|
+
void active.catch(() => void 0);
|
|
24315
|
+
if (old) {
|
|
24316
|
+
try {
|
|
24317
|
+
process.kill(old, "SIGTERM");
|
|
24318
|
+
} catch (error) {
|
|
24319
|
+
if (error.code !== "ESRCH")
|
|
24320
|
+
throw error;
|
|
24321
|
+
}
|
|
24322
|
+
await waitForProcessExit(old);
|
|
24323
|
+
if (existsSync2(pidFile) && Number(readFileSync6(pidFile, "utf8")) === old)
|
|
24324
|
+
rmSync3(pidFile);
|
|
24325
|
+
}
|
|
24326
|
+
renameSync2(bundle, stable);
|
|
24327
|
+
published = true;
|
|
24328
|
+
child.send("activate");
|
|
24329
|
+
await active;
|
|
24330
|
+
child.disconnect();
|
|
24331
|
+
child.unref();
|
|
24332
|
+
} catch (error) {
|
|
24333
|
+
if (child.pid && child.exitCode === null && child.signalCode === null) {
|
|
24334
|
+
child.kill();
|
|
24335
|
+
await waitForProcessExit(child.pid);
|
|
24336
|
+
}
|
|
24337
|
+
if (published) {
|
|
24338
|
+
if (previous) {
|
|
24339
|
+
const restore = join7(staging, "usebeeline.mjs");
|
|
24340
|
+
writeFileSync3(restore, previous, { mode: 384 });
|
|
24341
|
+
renameSync2(restore, stable);
|
|
24342
|
+
} else
|
|
24343
|
+
rmSync3(stable, { force: true });
|
|
24344
|
+
}
|
|
24345
|
+
throw error;
|
|
24346
|
+
} finally {
|
|
24347
|
+
if (child.pid)
|
|
24348
|
+
rmSync3(join7(dir, `bridge-${child.pid}.sock`), { force: true });
|
|
24349
|
+
rmSync3(staging, { recursive: true, force: true });
|
|
24350
|
+
}
|
|
24351
|
+
});
|
|
24352
|
+
}
|
|
24353
|
+
var init_bridge_launch = __esm({
|
|
24354
|
+
"apps/body/dist/session-join/bridge-launch.js"() {
|
|
24355
|
+
"use strict";
|
|
24356
|
+
init_kernel_lock();
|
|
24357
|
+
init_process_exit();
|
|
24358
|
+
init_store();
|
|
24359
|
+
}
|
|
24360
|
+
});
|
|
24361
|
+
|
|
24362
|
+
// apps/body/dist/session-join/bridge.js
|
|
24363
|
+
import { chmodSync as chmodSync2, closeSync as closeSync4, existsSync as existsSync3, mkdirSync as mkdirSync4, openSync as openSync4, readFileSync as readFileSync7, readdirSync as readdirSync5, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync4, watch as watch5 } from "node:fs";
|
|
24364
|
+
import { createConnection as createConnection4, createServer as createServer3 } from "node:net";
|
|
24365
|
+
import { join as join8 } from "node:path";
|
|
24366
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
24230
24367
|
function command(runner2, joined2, args) {
|
|
24231
24368
|
const q = (v) => /^[A-Za-z0-9_./:@=-]+$/.test(v) ? v : `"${v.replace(/(["\\$`])/g, "\\$1")}"`;
|
|
24232
24369
|
return `${q(runner2.node)} ${q(runner2.bundle)} session ${args} --as ${q(joined2.key)}`;
|
|
@@ -24327,7 +24464,7 @@ async function acceptMemberDelivery(dir, key, runner2, raw) {
|
|
|
24327
24464
|
}
|
|
24328
24465
|
function log(dir, line) {
|
|
24329
24466
|
try {
|
|
24330
|
-
|
|
24467
|
+
writeFileSync4(join8(dir, "bridge.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
24331
24468
|
`, { flag: "a", mode: 384 });
|
|
24332
24469
|
} catch {
|
|
24333
24470
|
}
|
|
@@ -24352,9 +24489,8 @@ async function flush(dir, sources, deps = realDeps) {
|
|
|
24352
24489
|
log(dir, `${joined2.key}: ${outcome}`);
|
|
24353
24490
|
}
|
|
24354
24491
|
}
|
|
24355
|
-
function serveTools(dir) {
|
|
24356
|
-
|
|
24357
|
-
rmSync3(path, { force: true });
|
|
24492
|
+
async function serveTools(dir, path = join8(dir, "bridge.sock")) {
|
|
24493
|
+
rmSync4(path, { force: true });
|
|
24358
24494
|
const server = createServer3((connection) => {
|
|
24359
24495
|
let buffer = "", taken = false;
|
|
24360
24496
|
connection.setEncoding("utf8");
|
|
@@ -24377,11 +24513,18 @@ function serveTools(dir) {
|
|
|
24377
24513
|
connection.end(JSON.stringify(answer) + "\n");
|
|
24378
24514
|
});
|
|
24379
24515
|
});
|
|
24380
|
-
|
|
24516
|
+
await new Promise((done, fail) => {
|
|
24517
|
+
server.once("error", fail);
|
|
24518
|
+
server.listen(path, () => {
|
|
24519
|
+
chmodSync2(path, 384);
|
|
24520
|
+
done();
|
|
24521
|
+
});
|
|
24522
|
+
});
|
|
24381
24523
|
server.unref();
|
|
24524
|
+
return server;
|
|
24382
24525
|
}
|
|
24383
24526
|
function outboxDir(cwd) {
|
|
24384
|
-
return
|
|
24527
|
+
return join8(cwd, ".beeline", "outbox");
|
|
24385
24528
|
}
|
|
24386
24529
|
async function serveOutboxes(dir) {
|
|
24387
24530
|
let served = 0;
|
|
@@ -24393,24 +24536,24 @@ async function serveOutboxes(dir) {
|
|
|
24393
24536
|
continue;
|
|
24394
24537
|
}
|
|
24395
24538
|
for (const name of names.filter((n) => n.endsWith(".request.json"))) {
|
|
24396
|
-
const path =
|
|
24539
|
+
const path = join8(outboxDir(joined2.cwd), name);
|
|
24397
24540
|
const taking = `${path}.taking`;
|
|
24398
24541
|
try {
|
|
24399
|
-
|
|
24542
|
+
renameSync3(path, taking);
|
|
24400
24543
|
} catch {
|
|
24401
24544
|
continue;
|
|
24402
24545
|
}
|
|
24403
24546
|
let answer;
|
|
24404
24547
|
try {
|
|
24405
|
-
const request2 = JSON.parse(
|
|
24548
|
+
const request2 = JSON.parse(readFileSync7(taking, "utf8"));
|
|
24406
24549
|
answer = { ok: true, data: await callTool(joined2, await accessToken(dir, joined2.key), request2.name, request2.args ?? {}) };
|
|
24407
24550
|
} catch (error) {
|
|
24408
24551
|
answer = { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
24409
24552
|
}
|
|
24410
24553
|
const result = path.replace(/\.request\.json$/, ".result.json");
|
|
24411
|
-
|
|
24412
|
-
|
|
24413
|
-
|
|
24554
|
+
writeFileSync4(result + ".tmp", JSON.stringify(answer), { mode: 384 });
|
|
24555
|
+
renameSync3(result + ".tmp", result);
|
|
24556
|
+
rmSync4(taking, { force: true });
|
|
24414
24557
|
served++;
|
|
24415
24558
|
}
|
|
24416
24559
|
}
|
|
@@ -24418,12 +24561,12 @@ async function serveOutboxes(dir) {
|
|
|
24418
24561
|
}
|
|
24419
24562
|
async function toolViaOutbox(cwd, name, args) {
|
|
24420
24563
|
const dirPath = outboxDir(cwd);
|
|
24421
|
-
|
|
24422
|
-
|
|
24564
|
+
mkdirSync4(dirPath, { recursive: true });
|
|
24565
|
+
writeFileSync4(join8(cwd, ".beeline", ".gitignore"), "*\n");
|
|
24423
24566
|
const id = `${Date.now()}-${process.pid}`;
|
|
24424
|
-
const request2 =
|
|
24425
|
-
|
|
24426
|
-
|
|
24567
|
+
const request2 = join8(dirPath, `${id}.request.json`), result = join8(dirPath, `${id}.result.json`);
|
|
24568
|
+
writeFileSync4(`${request2}.tmp`, JSON.stringify({ name, args }));
|
|
24569
|
+
renameSync3(`${request2}.tmp`, request2);
|
|
24427
24570
|
return new Promise((resolve13) => {
|
|
24428
24571
|
let settled = false;
|
|
24429
24572
|
const finish = (answer) => {
|
|
@@ -24435,13 +24578,13 @@ async function toolViaOutbox(cwd, name, args) {
|
|
|
24435
24578
|
};
|
|
24436
24579
|
const inspect = () => {
|
|
24437
24580
|
try {
|
|
24438
|
-
const answer = JSON.parse(
|
|
24439
|
-
|
|
24581
|
+
const answer = JSON.parse(readFileSync7(result, "utf8"));
|
|
24582
|
+
rmSync4(result, { force: true });
|
|
24440
24583
|
finish(answer);
|
|
24441
24584
|
} catch {
|
|
24442
24585
|
}
|
|
24443
24586
|
};
|
|
24444
|
-
const watcher =
|
|
24587
|
+
const watcher = watch5(dirPath, (_event, file) => {
|
|
24445
24588
|
if (String(file ?? "") === `${id}.result.json`)
|
|
24446
24589
|
inspect();
|
|
24447
24590
|
});
|
|
@@ -24450,7 +24593,7 @@ async function toolViaOutbox(cwd, name, args) {
|
|
|
24450
24593
|
}
|
|
24451
24594
|
function toolViaBridge(dir, key, name, args) {
|
|
24452
24595
|
return new Promise((resolve13) => {
|
|
24453
|
-
const connection = createConnection4(
|
|
24596
|
+
const connection = createConnection4(join8(dir, "bridge.sock"));
|
|
24454
24597
|
let text = "", sent = false, settled = false;
|
|
24455
24598
|
const unknown = { ok: false, error: "Beeline tool result is awaiting confirmation" };
|
|
24456
24599
|
const finish = (answer) => {
|
|
@@ -24479,17 +24622,44 @@ function toolViaBridge(dir, key, name, args) {
|
|
|
24479
24622
|
});
|
|
24480
24623
|
}
|
|
24481
24624
|
async function runBridge(dir, runner2) {
|
|
24482
|
-
const
|
|
24483
|
-
|
|
24484
|
-
|
|
24485
|
-
|
|
24486
|
-
|
|
24487
|
-
}
|
|
24488
|
-
|
|
24489
|
-
|
|
24490
|
-
|
|
24491
|
-
|
|
24625
|
+
const staged = process.env.BEELINE_SESSION_BRIDGE_STAGING === "1" && Boolean(process.send);
|
|
24626
|
+
let activated = !staged, stopping = false;
|
|
24627
|
+
let activate, begin;
|
|
24628
|
+
const handoff = staged ? new Promise((done) => {
|
|
24629
|
+
begin = done;
|
|
24630
|
+
}) : Promise.resolve();
|
|
24631
|
+
const activation = staged ? new Promise((done) => {
|
|
24632
|
+
activate = done;
|
|
24633
|
+
}) : Promise.resolve();
|
|
24634
|
+
if (staged) {
|
|
24635
|
+
process.once("message", (message2) => {
|
|
24636
|
+
if (message2 === "activate")
|
|
24637
|
+
begin();
|
|
24638
|
+
});
|
|
24639
|
+
process.once("disconnect", () => {
|
|
24640
|
+
if (!activated)
|
|
24641
|
+
process.exit(1);
|
|
24642
|
+
});
|
|
24492
24643
|
}
|
|
24644
|
+
const digest = bundleDigest({ ...runner2, bundle: runner2.candidate ?? runner2.bundle });
|
|
24645
|
+
const pidFile = join8(dir, "bridge.pid");
|
|
24646
|
+
const claim = () => {
|
|
24647
|
+
try {
|
|
24648
|
+
const fd = openSync4(pidFile, "wx", 384);
|
|
24649
|
+
writeFileSync4(fd, String(process.pid));
|
|
24650
|
+
closeSync4(fd);
|
|
24651
|
+
} catch {
|
|
24652
|
+
const holder = Number(readFileSync7(pidFile, "utf8"));
|
|
24653
|
+
if (holder && holder !== process.pid && pidAlive(holder))
|
|
24654
|
+
return false;
|
|
24655
|
+
writeFileSync4(pidFile, String(process.pid), { mode: 384 });
|
|
24656
|
+
}
|
|
24657
|
+
return true;
|
|
24658
|
+
};
|
|
24659
|
+
if (!staged && !claim())
|
|
24660
|
+
return;
|
|
24661
|
+
const socket = join8(dir, staged ? `bridge-${process.pid}.sock` : "bridge.sock");
|
|
24662
|
+
const tools = await serveTools(dir, socket);
|
|
24493
24663
|
const sources = machineSources(dir);
|
|
24494
24664
|
const streams = /* @__PURE__ */ new Map();
|
|
24495
24665
|
const outboxWatches = /* @__PURE__ */ new Map();
|
|
@@ -24498,28 +24668,31 @@ async function runBridge(dir, runner2) {
|
|
|
24498
24668
|
localDirty = true;
|
|
24499
24669
|
wake?.();
|
|
24500
24670
|
};
|
|
24501
|
-
|
|
24502
|
-
writeFileSync3(join7(dir, "bridge-owner.json"), JSON.stringify({ pid: process.pid, digest: bundleDigest(runner2) }), { mode: 384 });
|
|
24503
|
-
const localWatch = watch4(dir, { recursive: true }, (_event, name) => {
|
|
24671
|
+
const localWatch = watch5(dir, { recursive: true }, (_event, name) => {
|
|
24504
24672
|
const path = String(name ?? "");
|
|
24505
24673
|
if (path === "state.json" || path.startsWith("hooks/") || path.startsWith("inbox/") || path.startsWith("deliveries/"))
|
|
24506
24674
|
changed();
|
|
24507
24675
|
});
|
|
24508
24676
|
const stop = () => {
|
|
24509
|
-
|
|
24677
|
+
if (!activated)
|
|
24678
|
+
process.exit(0);
|
|
24679
|
+
stopping = true;
|
|
24680
|
+
for (const stream of streams.values())
|
|
24510
24681
|
stream.controller.abort();
|
|
24511
|
-
|
|
24512
|
-
localWatch.close();
|
|
24513
|
-
for (const watcher of outboxWatches.values())
|
|
24514
|
-
watcher.close();
|
|
24515
|
-
rmSync3(pidFile, { force: true });
|
|
24516
|
-
rmSync3(join7(dir, "bridge.sock"), { force: true });
|
|
24517
|
-
process.exit(0);
|
|
24682
|
+
changed();
|
|
24518
24683
|
};
|
|
24519
24684
|
process.once("SIGTERM", stop);
|
|
24520
24685
|
process.once("SIGINT", stop);
|
|
24521
|
-
|
|
24522
|
-
const
|
|
24686
|
+
const jobs = /* @__PURE__ */ new Set();
|
|
24687
|
+
const expected = new Set(readState(dir).sessions.map((session2) => session2.key));
|
|
24688
|
+
const openedKeys = /* @__PURE__ */ new Set();
|
|
24689
|
+
const failedStartup = (error) => {
|
|
24690
|
+
if (staged && !activated) {
|
|
24691
|
+
log(dir, `candidate startup failed: ${String(error)}`);
|
|
24692
|
+
process.exit(1);
|
|
24693
|
+
}
|
|
24694
|
+
};
|
|
24695
|
+
const fingerprint = (session2) => createHash7("sha256").update(JSON.stringify([
|
|
24523
24696
|
session2.server,
|
|
24524
24697
|
session2.clientId,
|
|
24525
24698
|
session2.refreshToken,
|
|
@@ -24530,21 +24703,43 @@ async function runBridge(dir, runner2) {
|
|
|
24530
24703
|
const start = (joined2, recovered = false) => {
|
|
24531
24704
|
const controller = new AbortController(), entry = { fingerprint: fingerprint(joined2), controller, recovered };
|
|
24532
24705
|
streams.set(joined2.key, entry);
|
|
24533
|
-
|
|
24706
|
+
const job = (async () => {
|
|
24534
24707
|
let expiredToken;
|
|
24535
24708
|
while (!controller.signal.aborted) {
|
|
24536
24709
|
let opened = false, terminal = false;
|
|
24537
24710
|
try {
|
|
24538
24711
|
const token = await accessToken(dir, joined2.key, expiredToken);
|
|
24539
24712
|
const current = readState(dir).sessions.find((session2) => session2.key === joined2.key);
|
|
24540
|
-
if (!current
|
|
24713
|
+
if (!current) {
|
|
24714
|
+
failedStartup("session disappeared");
|
|
24715
|
+
changed();
|
|
24716
|
+
return;
|
|
24717
|
+
}
|
|
24718
|
+
if (staged && !activated)
|
|
24719
|
+
entry.fingerprint = fingerprint(current);
|
|
24720
|
+
if (fingerprint(current) !== entry.fingerprint) {
|
|
24541
24721
|
changed();
|
|
24542
24722
|
return;
|
|
24543
24723
|
}
|
|
24544
24724
|
for await (const raw of memberStream(current, token, controller.signal, () => {
|
|
24545
24725
|
opened = true;
|
|
24726
|
+
if (staged && !activated) {
|
|
24727
|
+
openedKeys.add(joined2.key);
|
|
24728
|
+
if ([...expected].every((key) => openedKeys.has(key)))
|
|
24729
|
+
process.send?.("ready");
|
|
24730
|
+
}
|
|
24546
24731
|
})) {
|
|
24547
24732
|
const frame = memberStreamFrame(raw);
|
|
24733
|
+
if (frame.type === "ended" && !activated)
|
|
24734
|
+
failedStartup(`member stream ended: ${frame.reason}`);
|
|
24735
|
+
await activation;
|
|
24736
|
+
if (controller.signal.aborted)
|
|
24737
|
+
return;
|
|
24738
|
+
if (staged && frame.type === "checkpoint") {
|
|
24739
|
+
const committed = readState(dir).sessions.find((session2) => session2.key === joined2.key)?.streamCursor;
|
|
24740
|
+
if (committed?.epoch === frame.cursor.epoch && committed.through > frame.cursor.through)
|
|
24741
|
+
continue;
|
|
24742
|
+
}
|
|
24548
24743
|
if (frame.type === "ended") {
|
|
24549
24744
|
terminal = frame.reason !== "expired";
|
|
24550
24745
|
if (!terminal)
|
|
@@ -24557,17 +24752,40 @@ async function runBridge(dir, runner2) {
|
|
|
24557
24752
|
}
|
|
24558
24753
|
}
|
|
24559
24754
|
} catch (error) {
|
|
24755
|
+
failedStartup(error);
|
|
24560
24756
|
if (!controller.signal.aborted)
|
|
24561
24757
|
log(dir, `${joined2.key}: ${error instanceof Error ? error.message : String(error)}`);
|
|
24562
24758
|
}
|
|
24759
|
+
if (!activated)
|
|
24760
|
+
failedStartup("member stream ended before activation");
|
|
24563
24761
|
if (controller.signal.aborted || terminal || !opened || entry.recovered)
|
|
24564
24762
|
return;
|
|
24565
24763
|
entry.recovered = true;
|
|
24566
24764
|
}
|
|
24567
24765
|
})();
|
|
24766
|
+
jobs.add(job);
|
|
24767
|
+
void job.finally(() => jobs.delete(job));
|
|
24568
24768
|
};
|
|
24569
24769
|
try {
|
|
24570
|
-
|
|
24770
|
+
if (staged) {
|
|
24771
|
+
if (!expected.size)
|
|
24772
|
+
throw new Error("No joined sessions to activate");
|
|
24773
|
+
for (const joined2 of readState(dir).sessions)
|
|
24774
|
+
start(joined2);
|
|
24775
|
+
await handoff;
|
|
24776
|
+
runner2 = { ...runner2, bundle: join8(dir, "usebeeline.mjs") };
|
|
24777
|
+
renameSync3(socket, join8(dir, "bridge.sock"));
|
|
24778
|
+
}
|
|
24779
|
+
if (staged && !claim())
|
|
24780
|
+
throw new Error("Beeline bridge owner changed during handoff");
|
|
24781
|
+
writeFileSync4(join8(dir, "bridge-owner.json"), JSON.stringify({ pid: process.pid, digest }), { mode: 384 });
|
|
24782
|
+
if (staged) {
|
|
24783
|
+
activated = true;
|
|
24784
|
+
activate();
|
|
24785
|
+
process.send?.("active");
|
|
24786
|
+
}
|
|
24787
|
+
log(dir, `bridge ${process.pid} started`);
|
|
24788
|
+
for (; !stopping; ) {
|
|
24571
24789
|
localDirty = false;
|
|
24572
24790
|
const sessions = readState(dir).sessions;
|
|
24573
24791
|
if (!sessions.length)
|
|
@@ -24585,11 +24803,11 @@ async function runBridge(dir, runner2) {
|
|
|
24585
24803
|
}
|
|
24586
24804
|
const path = outboxDir(joined2.cwd);
|
|
24587
24805
|
if (!outboxWatches.has(path)) {
|
|
24588
|
-
|
|
24589
|
-
const ignore =
|
|
24590
|
-
if (!
|
|
24591
|
-
|
|
24592
|
-
outboxWatches.set(path,
|
|
24806
|
+
mkdirSync4(path, { recursive: true, mode: 448 });
|
|
24807
|
+
const ignore = join8(joined2.cwd, ".beeline", ".gitignore");
|
|
24808
|
+
if (!existsSync3(ignore))
|
|
24809
|
+
writeFileSync4(ignore, "*\n", { mode: 384 });
|
|
24810
|
+
outboxWatches.set(path, watch5(path, (_event, name) => {
|
|
24593
24811
|
if (String(name ?? "").endsWith(".request.json"))
|
|
24594
24812
|
changed();
|
|
24595
24813
|
}));
|
|
@@ -24603,6 +24821,9 @@ async function runBridge(dir, runner2) {
|
|
|
24603
24821
|
});
|
|
24604
24822
|
wake = void 0;
|
|
24605
24823
|
}
|
|
24824
|
+
} catch (error) {
|
|
24825
|
+
failedStartup(error);
|
|
24826
|
+
throw error;
|
|
24606
24827
|
} finally {
|
|
24607
24828
|
localWatch.close();
|
|
24608
24829
|
for (const watcher of outboxWatches.values())
|
|
@@ -24610,104 +24831,21 @@ async function runBridge(dir, runner2) {
|
|
|
24610
24831
|
for (const stream of streams.values()) {
|
|
24611
24832
|
stream.controller.abort();
|
|
24612
24833
|
}
|
|
24834
|
+
if (staged && !activated)
|
|
24835
|
+
activate();
|
|
24836
|
+
await Promise.allSettled(jobs);
|
|
24837
|
+
await new Promise((done) => tools.close(() => done()));
|
|
24613
24838
|
}
|
|
24614
|
-
log(dir, `bridge ${process.pid} stopped: no joined sessions`);
|
|
24615
|
-
|
|
24616
|
-
|
|
24839
|
+
log(dir, `bridge ${process.pid} stopped: ${stopping ? "handoff or shutdown" : "no joined sessions"}`);
|
|
24840
|
+
rmSync4(pidFile, { force: true });
|
|
24841
|
+
rmSync4(join8(dir, "bridge.sock"), { force: true });
|
|
24617
24842
|
process.exit(0);
|
|
24618
24843
|
}
|
|
24619
|
-
function bridgeRunning(dir) {
|
|
24620
|
-
try {
|
|
24621
|
-
const holder = Number(readFileSync6(join7(dir, "bridge.pid"), "utf8"));
|
|
24622
|
-
return Boolean(holder) && pidAlive(holder);
|
|
24623
|
-
} catch {
|
|
24624
|
-
return false;
|
|
24625
|
-
}
|
|
24626
|
-
}
|
|
24627
|
-
function bundleDigest(runner2) {
|
|
24628
|
-
return createHash6("sha256").update(readFileSync6(runner2.bundle)).digest("hex");
|
|
24629
|
-
}
|
|
24630
|
-
function bridgeOwner(dir) {
|
|
24631
|
-
try {
|
|
24632
|
-
return JSON.parse(readFileSync6(join7(dir, "bridge-owner.json"), "utf8"));
|
|
24633
|
-
} catch {
|
|
24634
|
-
return void 0;
|
|
24635
|
-
}
|
|
24636
|
-
}
|
|
24637
|
-
function isBridgeProcess(pid) {
|
|
24638
|
-
try {
|
|
24639
|
-
if (process.platform === "linux") {
|
|
24640
|
-
const args2 = readFileSync6(`/proc/${pid}/cmdline`, "utf8").split("\0").filter(Boolean);
|
|
24641
|
-
return args2.length === 4 && /^node(?:\.exe)?$/.test(basename4(args2[0])) && /^(?:beeline|usebeeline\.mjs|recovery-cli\.mjs)$/.test(basename4(args2[1])) && args2[2] === "session" && args2[3] === "bridge";
|
|
24642
|
-
}
|
|
24643
|
-
const args = execFileSync("ps", ["-ww", "-p", String(pid), "-o", "args="], { encoding: "utf8" }).trim();
|
|
24644
|
-
return /(?:^|\/)node\s+.*\/(?:beeline|usebeeline\.mjs|recovery-cli\.mjs) session bridge$/.test(args);
|
|
24645
|
-
} catch {
|
|
24646
|
-
return false;
|
|
24647
|
-
}
|
|
24648
|
-
}
|
|
24649
|
-
async function ensureBridge(dir, runner2, env = process.env) {
|
|
24650
|
-
await withKernelLock(`beeline-session-bridge:${resolve10(dir)}`, async () => {
|
|
24651
|
-
const digest = bundleDigest(runner2);
|
|
24652
|
-
const pidFile = join7(dir, "bridge.pid");
|
|
24653
|
-
if (bridgeRunning(dir)) {
|
|
24654
|
-
const pid = Number(readFileSync6(pidFile, "utf8"));
|
|
24655
|
-
if (!isBridgeProcess(pid))
|
|
24656
|
-
throw new Error("Beeline bridge PID belongs to an unrecognized process; refusing takeover");
|
|
24657
|
-
const owner = bridgeOwner(dir);
|
|
24658
|
-
if (owner?.pid === pid && owner.digest === digest)
|
|
24659
|
-
return;
|
|
24660
|
-
log(dir, `replacing stale bridge ${pid}`);
|
|
24661
|
-
await withLock(dir, async () => {
|
|
24662
|
-
try {
|
|
24663
|
-
process.kill(pid, "SIGTERM");
|
|
24664
|
-
} catch (error) {
|
|
24665
|
-
if (error.code !== "ESRCH")
|
|
24666
|
-
throw error;
|
|
24667
|
-
}
|
|
24668
|
-
await waitForProcessExit(pid);
|
|
24669
|
-
});
|
|
24670
|
-
if (existsSync2(pidFile) && Number(readFileSync6(pidFile, "utf8")) === pid)
|
|
24671
|
-
rmSync3(pidFile);
|
|
24672
|
-
}
|
|
24673
|
-
const out = openSync3(join7(dir, "bridge.log"), "a", 384);
|
|
24674
|
-
const child = spawn6(runner2.node, [runner2.bundle, "session", "bridge"], { detached: true, stdio: ["ignore", out, out], env });
|
|
24675
|
-
closeSync3(out);
|
|
24676
|
-
child.unref();
|
|
24677
|
-
await new Promise((done, fail) => {
|
|
24678
|
-
const finish = (error) => {
|
|
24679
|
-
watcher.close();
|
|
24680
|
-
child.removeListener("error", failed);
|
|
24681
|
-
child.removeListener("exit", exited);
|
|
24682
|
-
if (error)
|
|
24683
|
-
fail(error);
|
|
24684
|
-
else
|
|
24685
|
-
done();
|
|
24686
|
-
};
|
|
24687
|
-
const inspect = () => {
|
|
24688
|
-
const owner = bridgeOwner(dir);
|
|
24689
|
-
if (owner && owner.pid === child.pid && owner.digest === digest)
|
|
24690
|
-
finish();
|
|
24691
|
-
};
|
|
24692
|
-
const failed = (error) => finish(error);
|
|
24693
|
-
const exited = () => finish(new Error("Beeline bridge exited before readiness; see bridge.log"));
|
|
24694
|
-
const watcher = watch4(dir, (_event, name) => {
|
|
24695
|
-
if (String(name) === "bridge-owner.json")
|
|
24696
|
-
inspect();
|
|
24697
|
-
});
|
|
24698
|
-
child.once("error", failed);
|
|
24699
|
-
child.once("exit", exited);
|
|
24700
|
-
inspect();
|
|
24701
|
-
});
|
|
24702
|
-
});
|
|
24703
|
-
}
|
|
24704
24844
|
var realDeps;
|
|
24705
24845
|
var init_bridge = __esm({
|
|
24706
24846
|
"apps/body/dist/session-join/bridge.js"() {
|
|
24707
24847
|
"use strict";
|
|
24708
24848
|
init_agent_command();
|
|
24709
|
-
init_kernel_lock();
|
|
24710
|
-
init_process_exit();
|
|
24711
24849
|
init_phone();
|
|
24712
24850
|
init_beeline_api();
|
|
24713
24851
|
init_stream_frame();
|
|
@@ -24715,7 +24853,9 @@ var init_bridge = __esm({
|
|
|
24715
24853
|
init_claude();
|
|
24716
24854
|
init_claude_mcp();
|
|
24717
24855
|
init_sessions();
|
|
24856
|
+
init_bridge_launch();
|
|
24718
24857
|
init_store();
|
|
24858
|
+
init_bridge_launch();
|
|
24719
24859
|
realDeps = {
|
|
24720
24860
|
postClaude: postToClaude,
|
|
24721
24861
|
queueCodex: (bin, thread, text) => codexQueue(thread, text, bin),
|
|
@@ -24955,16 +25095,16 @@ def register(ctx):
|
|
|
24955
25095
|
|
|
24956
25096
|
// apps/body/dist/session-join/setup.js
|
|
24957
25097
|
import { spawnSync } from "node:child_process";
|
|
24958
|
-
import { copyFileSync, existsSync as
|
|
25098
|
+
import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync8, renameSync as renameSync4, rmSync as rmSync5, statSync as statSync4, writeFileSync as writeFileSync5, chmodSync as chmodSync3 } from "node:fs";
|
|
24959
25099
|
import { homedir as homedir7 } from "node:os";
|
|
24960
|
-
import { dirname as
|
|
25100
|
+
import { dirname as dirname8, join as join9 } from "node:path";
|
|
24961
25101
|
function home(env) {
|
|
24962
25102
|
return env.HOME || homedir7();
|
|
24963
25103
|
}
|
|
24964
25104
|
function readJson(path) {
|
|
24965
25105
|
let text;
|
|
24966
25106
|
try {
|
|
24967
|
-
text =
|
|
25107
|
+
text = readFileSync8(path, "utf8");
|
|
24968
25108
|
} catch (error) {
|
|
24969
25109
|
if (error.code === "ENOENT")
|
|
24970
25110
|
return {};
|
|
@@ -24988,17 +25128,17 @@ function object2(parent, key) {
|
|
|
24988
25128
|
function writeFile3(path, content, expected) {
|
|
24989
25129
|
let before;
|
|
24990
25130
|
try {
|
|
24991
|
-
before =
|
|
25131
|
+
before = readFileSync8(path, "utf8");
|
|
24992
25132
|
} catch {
|
|
24993
25133
|
}
|
|
24994
25134
|
if (before === content)
|
|
24995
25135
|
return false;
|
|
24996
|
-
|
|
25136
|
+
mkdirSync5(dirname8(path), { recursive: true });
|
|
24997
25137
|
const backup = `${path}.bak-${NAME}`;
|
|
24998
|
-
if (before !== void 0 && !
|
|
25138
|
+
if (before !== void 0 && !existsSync4(backup) && !before.includes(" session hook "))
|
|
24999
25139
|
copyFileSync(path, backup);
|
|
25000
25140
|
const temp = `${path}.${process.pid}.tmp-${NAME}`;
|
|
25001
|
-
|
|
25141
|
+
writeFileSync5(temp, content);
|
|
25002
25142
|
try {
|
|
25003
25143
|
chmodSync3(temp, statSync4(path).mode & 511);
|
|
25004
25144
|
} catch {
|
|
@@ -25006,26 +25146,26 @@ function writeFile3(path, content, expected) {
|
|
|
25006
25146
|
if (expected) {
|
|
25007
25147
|
let latest;
|
|
25008
25148
|
try {
|
|
25009
|
-
latest =
|
|
25149
|
+
latest = readFileSync8(path, "utf8");
|
|
25010
25150
|
} catch (error) {
|
|
25011
25151
|
if (error.code !== "ENOENT") {
|
|
25012
|
-
|
|
25152
|
+
rmSync5(temp, { force: true });
|
|
25013
25153
|
throw error;
|
|
25014
25154
|
}
|
|
25015
25155
|
}
|
|
25016
25156
|
if (latest !== expected.text) {
|
|
25017
|
-
|
|
25157
|
+
rmSync5(temp, { force: true });
|
|
25018
25158
|
throw new ConfigChanged();
|
|
25019
25159
|
}
|
|
25020
25160
|
}
|
|
25021
|
-
|
|
25161
|
+
renameSync4(temp, path);
|
|
25022
25162
|
return true;
|
|
25023
25163
|
}
|
|
25024
25164
|
function mergeClaudeMcp(path, context) {
|
|
25025
25165
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
25026
25166
|
let before;
|
|
25027
25167
|
try {
|
|
25028
|
-
before =
|
|
25168
|
+
before = readFileSync8(path, "utf8");
|
|
25029
25169
|
} catch (error) {
|
|
25030
25170
|
if (error.code !== "ENOENT")
|
|
25031
25171
|
throw error;
|
|
@@ -25092,10 +25232,10 @@ function hooksFile(path, agent, groups, remove, nested = true) {
|
|
|
25092
25232
|
return saveJson(path, value, remove);
|
|
25093
25233
|
}
|
|
25094
25234
|
function saveJson(path, value, remove) {
|
|
25095
|
-
if (remove && !Object.keys(value).length && !
|
|
25096
|
-
if (!
|
|
25235
|
+
if (remove && !Object.keys(value).length && !existsSync4(`${path}.bak-${NAME}`)) {
|
|
25236
|
+
if (!existsSync4(path))
|
|
25097
25237
|
return [];
|
|
25098
|
-
|
|
25238
|
+
rmSync5(path, { force: true });
|
|
25099
25239
|
return [`removed ${path}`];
|
|
25100
25240
|
}
|
|
25101
25241
|
return writeJson(path, value) ? [`${remove ? "removed Beeline from" : "updated"} ${path}`] : [];
|
|
@@ -25103,18 +25243,18 @@ function saveJson(path, value, remove) {
|
|
|
25103
25243
|
function claudeCode(context) {
|
|
25104
25244
|
const command2 = (event) => ({ hooks: [{ type: "command", command: hookCommand(context, "claude-code", event), timeout: 10 }] });
|
|
25105
25245
|
const remove = Boolean(context.remove);
|
|
25106
|
-
const path = context.env.CLAUDE_CONFIG_DIR ?
|
|
25107
|
-
return [...mergeClaudeMcp(path, context), ...hooksFile(
|
|
25246
|
+
const path = context.env.CLAUDE_CONFIG_DIR ? join9(context.env.CLAUDE_CONFIG_DIR, ".claude.json") : join9(home(context.env), ".claude.json");
|
|
25247
|
+
return [...mergeClaudeMcp(path, context), ...hooksFile(join9(claudeConfigDir(context.env), "settings.json"), "claude-code", [["SessionStart", command2("session-start")]], remove)];
|
|
25108
25248
|
}
|
|
25109
25249
|
function codex(context) {
|
|
25110
25250
|
const group = (event) => ({ matcher: "*", hooks: [{ type: "command", command: hookCommand(context, "codex", event), timeout: 10 }] });
|
|
25111
|
-
const lines = hooksFile(
|
|
25251
|
+
const lines = hooksFile(join9(codexHome(context.env), "hooks.json"), "codex", [["SessionStart", group("session-start")]], Boolean(context.remove));
|
|
25112
25252
|
if (lines.length && !context.remove)
|
|
25113
25253
|
lines.push("Codex asks once to trust Beeline\u2019s SessionStart hook if automatic trust is unavailable: open /hooks and trust only Beeline.");
|
|
25114
25254
|
return lines;
|
|
25115
25255
|
}
|
|
25116
25256
|
function geminiHome(env) {
|
|
25117
|
-
return env.GEMINI_CLI_HOME ||
|
|
25257
|
+
return env.GEMINI_CLI_HOME || join9(home(env), ".gemini");
|
|
25118
25258
|
}
|
|
25119
25259
|
function gemini(context) {
|
|
25120
25260
|
const group = (event, timeout) => ({ matcher: "*", hooks: [{
|
|
@@ -25123,7 +25263,7 @@ function gemini(context) {
|
|
|
25123
25263
|
command: hookCommand(context, "gemini", event),
|
|
25124
25264
|
timeout
|
|
25125
25265
|
}] });
|
|
25126
|
-
return hooksFile(
|
|
25266
|
+
return hooksFile(join9(geminiHome(context.env), "settings.json"), "gemini", [
|
|
25127
25267
|
["SessionStart", group("session-start", 1e4)],
|
|
25128
25268
|
["BeforeAgent", group("user-prompt-submit", 1e4)],
|
|
25129
25269
|
["AfterTool", group("post-tool-use", 1e4)],
|
|
@@ -25132,9 +25272,9 @@ function gemini(context) {
|
|
|
25132
25272
|
], Boolean(context.remove));
|
|
25133
25273
|
}
|
|
25134
25274
|
function antigravity(context) {
|
|
25135
|
-
const dir =
|
|
25275
|
+
const dir = join9(home(context.env), ".gemini/config");
|
|
25136
25276
|
const lines = [];
|
|
25137
|
-
const hooksPath =
|
|
25277
|
+
const hooksPath = join9(dir, "hooks.json");
|
|
25138
25278
|
const hooks = readJson(hooksPath);
|
|
25139
25279
|
if (context.remove)
|
|
25140
25280
|
delete hooks[NAME];
|
|
@@ -25150,13 +25290,13 @@ function antigravity(context) {
|
|
|
25150
25290
|
};
|
|
25151
25291
|
}
|
|
25152
25292
|
lines.push(...saveJson(hooksPath, hooks, Boolean(context.remove)));
|
|
25153
|
-
const sidecar =
|
|
25154
|
-
const configPath =
|
|
25293
|
+
const sidecar = join9(dir, "sidecars", NAME, "sidecar.json");
|
|
25294
|
+
const configPath = join9(dir, "config.json");
|
|
25155
25295
|
const config = readJson(configPath);
|
|
25156
25296
|
const sidecars = object2(config, "sidecars");
|
|
25157
25297
|
if (context.remove) {
|
|
25158
25298
|
delete sidecars[NAME];
|
|
25159
|
-
|
|
25299
|
+
rmSync5(dirname8(sidecar), { recursive: true, force: true });
|
|
25160
25300
|
} else {
|
|
25161
25301
|
if (writeJson(sidecar, {
|
|
25162
25302
|
command: context.node,
|
|
@@ -25175,56 +25315,56 @@ function antigravity(context) {
|
|
|
25175
25315
|
}
|
|
25176
25316
|
function pluginFile(path, content, remove) {
|
|
25177
25317
|
if (remove) {
|
|
25178
|
-
if (!
|
|
25318
|
+
if (!existsSync4(path))
|
|
25179
25319
|
return [];
|
|
25180
|
-
|
|
25320
|
+
rmSync5(path, { force: true });
|
|
25181
25321
|
return [`removed ${path}`];
|
|
25182
25322
|
}
|
|
25183
25323
|
return writeFile3(path, content) ? [`updated ${path}`] : [];
|
|
25184
25324
|
}
|
|
25185
25325
|
function opencode(context) {
|
|
25186
|
-
return pluginFile(
|
|
25326
|
+
return pluginFile(join9(home(context.env), ".config/opencode/plugins", `${NAME}.ts`), fill(OPENCODE_PLUGIN, context.node, context.bundle), Boolean(context.remove));
|
|
25187
25327
|
}
|
|
25188
25328
|
function piHome(env) {
|
|
25189
|
-
return env.PI_CODING_AGENT_DIR ||
|
|
25329
|
+
return env.PI_CODING_AGENT_DIR || join9(home(env), ".pi/agent");
|
|
25190
25330
|
}
|
|
25191
25331
|
function pi(context) {
|
|
25192
|
-
return pluginFile(
|
|
25332
|
+
return pluginFile(join9(piHome(context.env), "extensions", `${NAME}.ts`), fill(PI_EXTENSION, context.node, context.bundle), Boolean(context.remove));
|
|
25193
25333
|
}
|
|
25194
25334
|
function hermesRoot(env) {
|
|
25195
|
-
const base = env.HERMES_HOME ? env.HERMES_HOME.replace(/^~(?=\/|$)/, home(env)) :
|
|
25335
|
+
const base = env.HERMES_HOME ? env.HERMES_HOME.replace(/^~(?=\/|$)/, home(env)) : join9(home(env), `.hermes${env.HERMES_DATA_DIR_SUFFIX ?? ""}`);
|
|
25196
25336
|
let active = "";
|
|
25197
25337
|
try {
|
|
25198
|
-
active =
|
|
25338
|
+
active = readFileSync8(join9(base, "active_profile"), "utf8").trim();
|
|
25199
25339
|
} catch {
|
|
25200
25340
|
}
|
|
25201
|
-
if (active && active !== "default" && active !== "." && active !== ".." && !/[/\\]/.test(active) &&
|
|
25202
|
-
return
|
|
25341
|
+
if (active && active !== "default" && active !== "." && active !== ".." && !/[/\\]/.test(active) && existsSync4(join9(base, "profiles", active)))
|
|
25342
|
+
return join9(base, "profiles", active);
|
|
25203
25343
|
return base;
|
|
25204
25344
|
}
|
|
25205
25345
|
function hermes(context) {
|
|
25206
|
-
const dir =
|
|
25346
|
+
const dir = join9(hermesRoot(context.env), "plugins", NAME);
|
|
25207
25347
|
const remove = Boolean(context.remove);
|
|
25208
25348
|
const lines = [
|
|
25209
|
-
...pluginFile(
|
|
25210
|
-
...pluginFile(
|
|
25349
|
+
...pluginFile(join9(dir, "__init__.py"), fill(HERMES_PLUGIN, context.node, context.bundle), remove),
|
|
25350
|
+
...pluginFile(join9(dir, "plugin.yaml"), HERMES_MANIFEST, remove)
|
|
25211
25351
|
];
|
|
25212
25352
|
if (remove)
|
|
25213
|
-
|
|
25353
|
+
rmSync5(dir, { recursive: true, force: true });
|
|
25214
25354
|
const done = spawnSync("hermes", ["plugins", remove ? "disable" : "enable", NAME], { env: context.env, stdio: "ignore", timeout: 15e3 });
|
|
25215
25355
|
if (!remove && done.status !== 0)
|
|
25216
25356
|
lines.push(`Run "hermes plugins enable ${NAME}" once if Hermes does not load it.`);
|
|
25217
25357
|
return lines;
|
|
25218
25358
|
}
|
|
25219
25359
|
function zcodeIn(homeDir, context) {
|
|
25220
|
-
const native =
|
|
25360
|
+
const native = join9(homeDir, ".zcode/cli/config.json"), fallback = join9(homeDir, ".agents/mcp.json");
|
|
25221
25361
|
const servers = (value, isNative) => isNative ? object2(object2(value, "mcp"), "servers") : object2(value, "mcpServers");
|
|
25222
25362
|
const remove = Boolean(context.remove);
|
|
25223
25363
|
const toFallback = !remove && !Object.keys(servers(readJson(native), true)).some((key) => key !== NAME) && Object.keys(servers(readJson(fallback), false)).length > 0;
|
|
25224
25364
|
const targets = remove ? [[native, true], [fallback, false]] : toFallback ? [[fallback, false], [native, true]] : [[native, true]];
|
|
25225
25365
|
const lines = [];
|
|
25226
25366
|
for (const [path, isNative] of targets) {
|
|
25227
|
-
if (!
|
|
25367
|
+
if (!existsSync4(path) && (remove || isNative && toFallback))
|
|
25228
25368
|
continue;
|
|
25229
25369
|
const value = readJson(path);
|
|
25230
25370
|
const list = servers(value, isNative);
|
|
@@ -25266,12 +25406,12 @@ var init_setup = __esm({
|
|
|
25266
25406
|
});
|
|
25267
25407
|
|
|
25268
25408
|
// apps/body/dist/session-join/claude-inbound.js
|
|
25269
|
-
import { existsSync as
|
|
25270
|
-
import { join as
|
|
25409
|
+
import { existsSync as existsSync5, readFileSync as readFileSync9, rmSync as rmSync6 } from "node:fs";
|
|
25410
|
+
import { join as join10 } from "node:path";
|
|
25271
25411
|
function assertClaudePolicy(env) {
|
|
25272
25412
|
const paths = [
|
|
25273
25413
|
env.CLAUDE_CODE_MANAGED_SETTINGS_PATH,
|
|
25274
|
-
|
|
25414
|
+
join10(claudeConfigDir(env), "managed-settings.json"),
|
|
25275
25415
|
process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : "/etc/claude-code/managed-settings.json"
|
|
25276
25416
|
];
|
|
25277
25417
|
for (const path of paths) {
|
|
@@ -25286,10 +25426,10 @@ async function acceptClaudeInbound(env) {
|
|
|
25286
25426
|
const dir = stateDir(env);
|
|
25287
25427
|
await withLock(dir, () => {
|
|
25288
25428
|
assertClaudePolicy(env);
|
|
25289
|
-
const path =
|
|
25290
|
-
const saved =
|
|
25429
|
+
const path = join10(claudeConfigDir(env), "settings.json");
|
|
25430
|
+
const saved = join10(dir, "claude-inbound.json");
|
|
25291
25431
|
const value = readJson(path);
|
|
25292
|
-
if (!
|
|
25432
|
+
if (!existsSync5(saved))
|
|
25293
25433
|
writeFile3(saved, JSON.stringify({ present: Object.hasOwn(value, "crossSessionInbound"), value: value.crossSessionInbound }));
|
|
25294
25434
|
const current = readJson(path);
|
|
25295
25435
|
current.crossSessionInbound = "accept";
|
|
@@ -25301,12 +25441,12 @@ async function restoreClaudeInbound(env) {
|
|
|
25301
25441
|
await withLock(dir, () => {
|
|
25302
25442
|
if (readState(dir).sessions.length)
|
|
25303
25443
|
return;
|
|
25304
|
-
const saved =
|
|
25305
|
-
if (!
|
|
25444
|
+
const saved = join10(dir, "claude-inbound.json");
|
|
25445
|
+
if (!existsSync5(saved))
|
|
25306
25446
|
return;
|
|
25307
25447
|
assertClaudePolicy(env);
|
|
25308
|
-
const old = JSON.parse(
|
|
25309
|
-
const path =
|
|
25448
|
+
const old = JSON.parse(readFileSync9(saved, "utf8"));
|
|
25449
|
+
const path = join10(claudeConfigDir(env), "settings.json");
|
|
25310
25450
|
const value = readJson(path);
|
|
25311
25451
|
if (value.crossSessionInbound === "accept") {
|
|
25312
25452
|
if (old.present)
|
|
@@ -25315,7 +25455,7 @@ async function restoreClaudeInbound(env) {
|
|
|
25315
25455
|
delete value.crossSessionInbound;
|
|
25316
25456
|
writeFile3(path, JSON.stringify(value, null, 2) + "\n");
|
|
25317
25457
|
}
|
|
25318
|
-
|
|
25458
|
+
rmSync6(saved);
|
|
25319
25459
|
});
|
|
25320
25460
|
}
|
|
25321
25461
|
var init_claude_inbound = __esm({
|
|
@@ -25329,9 +25469,9 @@ var init_claude_inbound = __esm({
|
|
|
25329
25469
|
|
|
25330
25470
|
// apps/body/dist/session-join/codex-trust.js
|
|
25331
25471
|
import { spawn as spawn7 } from "node:child_process";
|
|
25332
|
-
import { join as
|
|
25472
|
+
import { join as join11 } from "node:path";
|
|
25333
25473
|
function beelineTrustEdits(hooks, context) {
|
|
25334
|
-
const path =
|
|
25474
|
+
const path = join11(codexHome(context.env), "hooks.json");
|
|
25335
25475
|
const expected = hookCommand(context, "codex", "session-start");
|
|
25336
25476
|
const own2 = hooks.filter((h) => h.sourcePath === path && h.source === "user" && !h.isManaged && h.pluginId === null && h.eventName === "sessionStart" && h.handlerType === "command" && h.command === expected && h.matcher === "*" && h.timeoutSec === 10 && h.key.startsWith(path) && /^:session_start:\d+:\d+$/.test(h.key.slice(path.length)) && /^sha256:[0-9a-f]{64}$/.test(h.currentHash));
|
|
25337
25477
|
if (own2.length !== 1)
|
|
@@ -25483,7 +25623,7 @@ var init_hook = __esm({
|
|
|
25483
25623
|
});
|
|
25484
25624
|
|
|
25485
25625
|
// apps/body/dist/session-join/pull-apps.js
|
|
25486
|
-
import { watch as
|
|
25626
|
+
import { watch as watch6 } from "node:fs/promises";
|
|
25487
25627
|
import { execFile as execFile4 } from "node:child_process";
|
|
25488
25628
|
import { createInterface as createInterface2 } from "node:readline";
|
|
25489
25629
|
function zcodeKey(dir, cwd) {
|
|
@@ -25549,7 +25689,7 @@ async function antigravityOnce(dir, live, send = agentapi) {
|
|
|
25549
25689
|
}
|
|
25550
25690
|
async function runAntigravitySidecar(dir) {
|
|
25551
25691
|
await antigravityOnce(dir, hookSessions(dir)).catch(() => 0);
|
|
25552
|
-
for await (const event of
|
|
25692
|
+
for await (const event of watch6(dir, { recursive: true })) {
|
|
25553
25693
|
if (event.filename?.startsWith("inbox/"))
|
|
25554
25694
|
await antigravityOnce(dir, hookSessions(dir)).catch(() => 0);
|
|
25555
25695
|
}
|
|
@@ -25572,45 +25712,45 @@ __export(command_exports, {
|
|
|
25572
25712
|
runSessionCommand: () => runSessionCommand
|
|
25573
25713
|
});
|
|
25574
25714
|
import { spawn as spawn8, spawnSync as spawnSync2 } from "node:child_process";
|
|
25575
|
-
import { closeSync as
|
|
25576
|
-
import { delimiter, dirname as
|
|
25577
|
-
import { createHash as
|
|
25715
|
+
import { closeSync as closeSync5, constants, copyFileSync as copyFileSync2, existsSync as existsSync6, fsyncSync, mkdirSync as mkdirSync6, openSync as openSync5, readFileSync as readFileSync10, readdirSync as readdirSync6, renameSync as renameSync5, rmSync as rmSync7, writeFileSync as writeFileSync6 } from "node:fs";
|
|
25716
|
+
import { delimiter, dirname as dirname9, join as join12, resolve as resolve11 } from "node:path";
|
|
25717
|
+
import { createHash as createHash8, randomUUID as randomUUID2 } from "node:crypto";
|
|
25578
25718
|
function writePending(file, pending) {
|
|
25579
25719
|
const temporary = file + "." + randomUUID2() + ".tmp";
|
|
25580
25720
|
try {
|
|
25581
|
-
const descriptor =
|
|
25721
|
+
const descriptor = openSync5(temporary, "wx", 384);
|
|
25582
25722
|
try {
|
|
25583
|
-
|
|
25723
|
+
writeFileSync6(descriptor, JSON.stringify(pending));
|
|
25584
25724
|
fsyncSync(descriptor);
|
|
25585
25725
|
} finally {
|
|
25586
|
-
|
|
25726
|
+
closeSync5(descriptor);
|
|
25587
25727
|
}
|
|
25588
|
-
|
|
25728
|
+
renameSync5(temporary, file);
|
|
25589
25729
|
if (process.platform !== "win32") {
|
|
25590
|
-
const directory =
|
|
25730
|
+
const directory = openSync5(dirname9(file), "r");
|
|
25591
25731
|
try {
|
|
25592
25732
|
fsyncSync(directory);
|
|
25593
25733
|
} finally {
|
|
25594
|
-
|
|
25734
|
+
closeSync5(directory);
|
|
25595
25735
|
}
|
|
25596
25736
|
}
|
|
25597
25737
|
} finally {
|
|
25598
|
-
|
|
25738
|
+
rmSync7(temporary, { force: true });
|
|
25599
25739
|
}
|
|
25600
25740
|
}
|
|
25601
25741
|
function existingPending(dir, own2, server) {
|
|
25602
25742
|
let names;
|
|
25603
25743
|
try {
|
|
25604
|
-
names = readdirSync6(
|
|
25744
|
+
names = readdirSync6(join12(dir, "pending"));
|
|
25605
25745
|
} catch {
|
|
25606
25746
|
return;
|
|
25607
25747
|
}
|
|
25608
25748
|
if (names.length > 256)
|
|
25609
25749
|
throw new Error("Too many pending Beeline sign-ins");
|
|
25610
25750
|
return names.filter((name) => /^[a-f0-9]{24}\.json$/.test(name)).flatMap((name) => {
|
|
25611
|
-
const file =
|
|
25751
|
+
const file = join12(dir, "pending", name);
|
|
25612
25752
|
try {
|
|
25613
|
-
const pending = JSON.parse(
|
|
25753
|
+
const pending = JSON.parse(readFileSync10(file, "utf8"));
|
|
25614
25754
|
return pending.agent === own2.agent && pending.cwd === own2.cwd && pending.server === server && (!pending.sessionId || !own2.sessionId || pending.sessionId === own2.sessionId) ? [{ file, pending }] : [];
|
|
25615
25755
|
} catch {
|
|
25616
25756
|
return [];
|
|
@@ -25633,8 +25773,8 @@ function words(args, valued) {
|
|
|
25633
25773
|
}
|
|
25634
25774
|
function which(bin, env) {
|
|
25635
25775
|
for (const dir of (env.PATH ?? "").split(delimiter)) {
|
|
25636
|
-
const path =
|
|
25637
|
-
if (dir &&
|
|
25776
|
+
const path = join12(dir, bin);
|
|
25777
|
+
if (dir && existsSync6(path))
|
|
25638
25778
|
return path;
|
|
25639
25779
|
}
|
|
25640
25780
|
return void 0;
|
|
@@ -25642,13 +25782,19 @@ function which(bin, env) {
|
|
|
25642
25782
|
function runner(dir, env) {
|
|
25643
25783
|
if (env.BEELINE_SESSION_BUNDLE)
|
|
25644
25784
|
return { node: process.execPath, bundle: env.BEELINE_SESSION_BUNDLE };
|
|
25645
|
-
const bundle =
|
|
25785
|
+
const bundle = join12(dir, "usebeeline.mjs");
|
|
25646
25786
|
const running = resolve11(process.argv[1] ?? "");
|
|
25647
25787
|
if (running !== bundle && running.endsWith(".mjs")) {
|
|
25648
|
-
|
|
25649
|
-
|
|
25788
|
+
mkdirSync6(dir, { recursive: true, mode: 448 });
|
|
25789
|
+
try {
|
|
25790
|
+
copyFileSync2(running, bundle, constants.COPYFILE_EXCL);
|
|
25791
|
+
} catch (error) {
|
|
25792
|
+
if (error.code !== "EEXIST")
|
|
25793
|
+
throw error;
|
|
25794
|
+
}
|
|
25795
|
+
return { node: process.execPath, bundle, candidate: running };
|
|
25650
25796
|
}
|
|
25651
|
-
return { node: process.execPath, bundle:
|
|
25797
|
+
return { node: process.execPath, bundle: existsSync6(bundle) ? bundle : running };
|
|
25652
25798
|
}
|
|
25653
25799
|
function gitRoot(cwd) {
|
|
25654
25800
|
const result = spawnSync2("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf8", timeout: 5e3 });
|
|
@@ -25737,13 +25883,13 @@ async function joinCommand(args, env) {
|
|
|
25737
25883
|
startedAt: Date.now(),
|
|
25738
25884
|
claudeInboundFallback: own2.claudeInboundFallback
|
|
25739
25885
|
};
|
|
25740
|
-
|
|
25741
|
-
const file =
|
|
25886
|
+
mkdirSync6(join12(dir, "pending"), { recursive: true, mode: 448 });
|
|
25887
|
+
const file = join12(dir, "pending", `${createHash8("sha256").update(signIn.state).digest("hex").slice(0, 24)}.json`);
|
|
25742
25888
|
if (!resume)
|
|
25743
25889
|
writePending(file, pending);
|
|
25744
25890
|
if (!resume && previous && previous.file !== file)
|
|
25745
|
-
|
|
25746
|
-
const out =
|
|
25891
|
+
rmSync7(previous.file, { force: true });
|
|
25892
|
+
const out = join12(dir, "bridge.log");
|
|
25747
25893
|
const child = spawn8(run2.node, [run2.bundle, "session", "finish-join", file], { detached: true, stdio: "ignore", env: { ...env, BEELINE_SESSION_BUNDLE: run2.bundle } });
|
|
25748
25894
|
child.unref();
|
|
25749
25895
|
console.log([
|
|
@@ -25764,9 +25910,9 @@ async function finishJoinOwned(file, env) {
|
|
|
25764
25910
|
const run2 = runner(dir, env);
|
|
25765
25911
|
let retain = false;
|
|
25766
25912
|
try {
|
|
25767
|
-
const pending = JSON.parse(
|
|
25913
|
+
const pending = JSON.parse(readFileSync10(file, "utf8"));
|
|
25768
25914
|
const tokens = await finishSignIn(pending.server, pending.clientId, pending.signIn, pending.startedAt + 10 * 6e4, (signIn) => {
|
|
25769
|
-
const current = JSON.parse(
|
|
25915
|
+
const current = JSON.parse(readFileSync10(file, "utf8"));
|
|
25770
25916
|
if (current.signIn.state !== signIn.state)
|
|
25771
25917
|
throw new SignInEndedError("The sign-in was superseded");
|
|
25772
25918
|
pending.signIn = signIn;
|
|
@@ -25832,7 +25978,7 @@ ${renderRules(joined2, run2)}`, dir);
|
|
|
25832
25978
|
throw error;
|
|
25833
25979
|
} finally {
|
|
25834
25980
|
if (!retain)
|
|
25835
|
-
|
|
25981
|
+
rmSync7(file, { force: true });
|
|
25836
25982
|
}
|
|
25837
25983
|
}
|
|
25838
25984
|
async function announce(joined2, text, dir) {
|
|
@@ -25869,7 +26015,7 @@ function own(args, env) {
|
|
|
25869
26015
|
}
|
|
25870
26016
|
async function ownTool(dir, joined2, name, args) {
|
|
25871
26017
|
let bridged = await toolViaBridge(dir, joined2.key, name, args);
|
|
25872
|
-
if (!bridged &&
|
|
26018
|
+
if (!bridged && existsSync6(join12(dir, "bridge.pid")) && process.cwd().startsWith(joined2.cwd))
|
|
25873
26019
|
bridged = await toolViaOutbox(joined2.cwd, name, args);
|
|
25874
26020
|
if (bridged) {
|
|
25875
26021
|
if (!bridged.ok)
|