@moxxy/sdk 0.15.2 → 0.16.0
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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/server.d.ts +0 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +0 -1
- package/dist/server.js.map +1 -1
- package/dist/tunnel.d.ts +21 -34
- package/dist/tunnel.d.ts.map +1 -1
- package/dist/tunnel.js +11 -172
- package/dist/tunnel.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -11
- package/src/package-root.test.ts +0 -2
- package/src/plugin.ts +1 -1
- package/src/server.ts +0 -1
- package/src/tunnel.ts +19 -198
- package/src/tunnel.test.ts +0 -99
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type { DiffLine, DiffHunk, DiffRow, FileDiffDisplay, ToolDisplay, ToolDis
|
|
|
17
17
|
export { isToolDisplayResult, isToolDisplay, isFileDiffDisplay, fileDiffSummary, fileDiffVerb, diffGutterNo, toDiffRows, } from './tool-display.js';
|
|
18
18
|
export type { ViewNode, ViewAction, ViewDoc, ViewParseError, ViewParseResult, AttrType, AttrSpec, ViewTagSpec, ViewRendererDef, } from './view-renderer.js';
|
|
19
19
|
export { VIEW_PRIMITIVES, VIEW_COMPONENTS, DEFAULT_VIEW_TAGS, isSafeViewUrl, countNodes } from './view-renderer.js';
|
|
20
|
-
export type { TunnelProviderDef, TunnelHandle, TunnelOpenOptions
|
|
20
|
+
export type { TunnelProviderDef, TunnelHandle, TunnelOpenOptions } from './tunnel.js';
|
|
21
21
|
export { isRetryableError, toFriendlyError, zodToJsonSchema, estimateTextTokens, type StopReason } from './provider-utils.js';
|
|
22
22
|
export type { WriteFileAtomicOptions } from './fs-utils.js';
|
|
23
23
|
export { createMutex, type Mutex } from './mutex.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEjG,YAAY,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,qB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AAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,QAAQ,EACR,UAAU,EACV,OAAO,EACP,cAAc,EACd,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACpH,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEjG,YAAY,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,eAAe,EAC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KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ export { ISOLATION_RANK } from './isolation.js';
|
|
|
3
3
|
export { encodeLoginPrompt, decodeLoginPrompt, createLoginStreamScanner, } from './provider-login-bridge.js';
|
|
4
4
|
export { isToolDisplayResult, isToolDisplay, isFileDiffDisplay, fileDiffSummary, fileDiffVerb, diffGutterNo, toDiffRows, } from './tool-display.js';
|
|
5
5
|
export { VIEW_PRIMITIVES, VIEW_COMPONENTS, DEFAULT_VIEW_TAGS, isSafeViewUrl, countNodes } from './view-renderer.js';
|
|
6
|
-
// Node-runtime helpers (
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
6
|
+
// Node-runtime helpers (writeFileAtomic*, moxxyHome/moxxyPath,
|
|
7
|
+
// readRequestBody/bearerTokenMatches, channel-auth) are exported from the
|
|
8
|
+
// './server' subpath, NOT the main barrel — they statically reach node:*
|
|
9
|
+
// builtins and would break a browser/RN bundle. See ./server.ts.
|
|
10
10
|
export { isRetryableError, toFriendlyError, zodToJsonSchema, estimateTextTokens } from './provider-utils.js';
|
|
11
11
|
export { createMutex } from './mutex.js';
|
|
12
12
|
export { createJsonFileStore, } from './json-file-store.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UA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U,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,WAAW,EACX,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GAIlB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface PluginSpec {
|
|
|
39
39
|
readonly viewRenderers?: ReadonlyArray<ViewRendererDef>;
|
|
40
40
|
/**
|
|
41
41
|
* Tunnel providers that expose the local web surface publicly (e.g.
|
|
42
|
-
*
|
|
42
|
+
* the proxy relay). One active per session; core seeds a `localhost` no-op.
|
|
43
43
|
*/
|
|
44
44
|
readonly tunnelProviders?: ReadonlyArray<TunnelProviderDef>;
|
|
45
45
|
readonly channels?: ReadonlyArray<ChannelDef>;
|
package/dist/server.d.ts
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* on the main barrel because types are erased at build time and never reach a
|
|
15
15
|
* bundle.
|
|
16
16
|
*/
|
|
17
|
-
export { spawnCliTunnel, isCliTunnelAvailable } from './tunnel.js';
|
|
18
17
|
export { writeFileAtomic, writeFileAtomicSync, moxxyHome, moxxyPath, } from './fs-utils.js';
|
|
19
18
|
export { readRequestBody, bearerTokenMatches } from './http-utils.js';
|
|
20
19
|
export { resolveChannelToken, rotateChannelToken, bearerGuard, encodeWsBearerProtocol, tokenFromWsProtocolHeader, MOXXY_WS_SUBPROTOCOL, MOXXY_WS_BEARER_PROTOCOL_PREFIX, } from './channel-auth.js';
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,mBAAmB,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* on the main barrel because types are erased at build time and never reach a
|
|
15
15
|
* bundle.
|
|
16
16
|
*/
|
|
17
|
-
export { spawnCliTunnel, isCliTunnelAvailable } from './tunnel.js';
|
|
18
17
|
export { writeFileAtomic, writeFileAtomicSync, moxxyHome, moxxyPath, } from './fs-utils.js';
|
|
19
18
|
export { readRequestBody, bearerTokenMatches } from './http-utils.js';
|
|
20
19
|
export { resolveChannelToken, rotateChannelToken, bearerGuard, encodeWsBearerProtocol, tokenFromWsProtocolHeader, MOXXY_WS_SUBPROTOCOL, MOXXY_WS_BEARER_PROTOCOL_PREFIX, } from './channel-auth.js';
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,mBAAmB,CAAC"}
|
package/dist/tunnel.d.ts
CHANGED
|
@@ -1,49 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A swappable way to expose a locally-bound surface (the web channel, the mobile
|
|
3
|
+
* bridge, the webhooks listener) to the user over the public internet — so an
|
|
4
|
+
* agent on Telegram/TUI can hand the user a URL they can open. One provider is
|
|
5
|
+
* active per session (registered via plugins, like every other block); core
|
|
6
|
+
* seeds a `localhost` no-op provider so `getActive()` is non-null.
|
|
7
|
+
*
|
|
8
|
+
* The shipped provider is `@moxxy/plugin-tunnel-proxy` (the self-hosted proxy
|
|
9
|
+
* relay). The old cloudflared/ngrok subprocess providers — and the
|
|
10
|
+
* `spawnCliTunnel` helper that backed them — were removed.
|
|
11
|
+
*/
|
|
1
12
|
export interface TunnelOpenOptions {
|
|
2
13
|
readonly port: number;
|
|
3
14
|
readonly host: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional routing label for tunnels that multiplex several local services
|
|
17
|
+
* under one public endpoint (the proxy relay): the returned URL is
|
|
18
|
+
* `…/<label>` and inbound requests under that path segment route back to this
|
|
19
|
+
* `host:port`. Providers that expose a single port (or none) ignore it.
|
|
20
|
+
*/
|
|
21
|
+
readonly label?: string;
|
|
4
22
|
}
|
|
5
23
|
export interface TunnelHandle {
|
|
6
|
-
/** The publicly reachable base URL (e.g. https://
|
|
24
|
+
/** The publicly reachable base URL (e.g. https://abc123.proxy.moxxy.ai/mobile). */
|
|
7
25
|
readonly url: string;
|
|
8
|
-
/** Tear the tunnel down (
|
|
26
|
+
/** Tear the tunnel down (deregister the target / close the connection). */
|
|
9
27
|
close(): Promise<void>;
|
|
10
28
|
}
|
|
11
29
|
export interface TunnelProviderDef {
|
|
12
30
|
readonly name: string;
|
|
13
31
|
/** Open a tunnel to `http://host:port`, resolving once the public URL is known. */
|
|
14
32
|
open(opts: TunnelOpenOptions): Promise<TunnelHandle>;
|
|
15
|
-
/** Optional readiness gate (e.g. the
|
|
33
|
+
/** Optional readiness gate (e.g. the relay is reachable). */
|
|
16
34
|
isAvailable?(): Promise<boolean>;
|
|
17
35
|
}
|
|
18
|
-
export interface SpawnCliTunnelOptions {
|
|
19
|
-
/** Executable to spawn (e.g. `cloudflared`, `ngrok`). */
|
|
20
|
-
readonly cmd: string;
|
|
21
|
-
/** Arguments passed to the executable. */
|
|
22
|
-
readonly args: ReadonlyArray<string>;
|
|
23
|
-
/** Matches the assigned public URL in a chunk of the CLI's stdout/stderr. */
|
|
24
|
-
readonly urlRegex: RegExp;
|
|
25
|
-
/** How long to wait for the URL before giving up. Default 30s. */
|
|
26
|
-
readonly timeoutMs?: number;
|
|
27
|
-
/** Human-readable name used in error messages. Defaults to `cmd`. */
|
|
28
|
-
readonly name?: string;
|
|
29
|
-
}
|
|
30
|
-
/** A spawned CLI tunnel: the public-URL handle plus the child's pid. */
|
|
31
|
-
export interface CliTunnelHandle extends TunnelHandle {
|
|
32
|
-
/** Spawned process id (-1 if the platform didn't assign one). */
|
|
33
|
-
readonly pid: number;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Spawn a CLI tunnel, parse the assigned public URL out of its output, and
|
|
37
|
-
* resolve a {@link CliTunnelHandle}. The child is tracked so it is killed on
|
|
38
|
-
* `close()`, on tunnel-switch, and on process exit (no orphans). Rejects on
|
|
39
|
-
* timeout, spawn error, or premature exit (the child is killed in every reject
|
|
40
|
-
* path). This is the single spawn-and-parse implementation behind the
|
|
41
|
-
* cloudflared/ngrok tunnel providers and the webhooks tunnel.
|
|
42
|
-
*/
|
|
43
|
-
export declare function spawnCliTunnel(opts: SpawnCliTunnelOptions): Promise<CliTunnelHandle>;
|
|
44
|
-
/**
|
|
45
|
-
* Probe whether a tunnel CLI is installed and runnable (`<cmd> --version`
|
|
46
|
-
* exits 0). Used as the `isAvailable()` gate by CLI-backed tunnel providers.
|
|
47
|
-
*/
|
|
48
|
-
export declare function isCliTunnelAvailable(cmd: string): Promise<boolean>;
|
|
49
36
|
//# sourceMappingURL=tunnel.d.ts.map
|
package/dist/tunnel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel.d.ts","sourceRoot":"","sources":["../src/tunnel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tunnel.d.ts","sourceRoot":"","sources":["../src/tunnel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,IAAI,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACrD,6DAA6D;IAC7D,WAAW,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC"}
|
package/dist/tunnel.js
CHANGED
|
@@ -1,174 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A swappable way to expose a locally-bound surface (the web channel
|
|
3
|
-
* user over the public internet — so an
|
|
4
|
-
* a URL they can open. One provider is
|
|
5
|
-
* plugins, like every other block); core
|
|
6
|
-
* `getActive()` is non-null.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// thing: spawn a CLI, watch its stdout/stderr for the assigned public URL,
|
|
14
|
-
// resolve once it's seen (or reject on timeout/exit/error), and guarantee the
|
|
15
|
-
// child is killed on close *and* on process exit (Node does not reap children).
|
|
16
|
-
// `spawnCliTunnel` is the single implementation they all share.
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
/**
|
|
19
|
-
* Guarantees spawned tunnel children (cloudflared/ngrok/…) never orphan or
|
|
20
|
-
* leak. Node does NOT kill child processes when the parent exits, so we track
|
|
21
|
-
* every live child and kill any survivors on process teardown — in addition to
|
|
22
|
-
* the explicit `close()` path. Each tracked child is also force-killed
|
|
23
|
-
* (SIGKILL) if it ignores SIGTERM, so a wedged tunnel can't drain
|
|
24
|
-
* memory/handles.
|
|
25
|
-
*/
|
|
26
|
-
const liveChildren = new Set();
|
|
27
|
-
let exitHookInstalled = false;
|
|
28
|
-
function killChild(child) {
|
|
29
|
-
if (child.exitCode != null || child.signalCode != null)
|
|
30
|
-
return;
|
|
31
|
-
try {
|
|
32
|
-
child.kill('SIGTERM');
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
/* already gone */
|
|
36
|
-
}
|
|
37
|
-
// Escalate if it doesn't exit promptly. unref so this timer never holds the
|
|
38
|
-
// event loop open on its own.
|
|
39
|
-
const t = setTimeout(() => {
|
|
40
|
-
try {
|
|
41
|
-
child.kill('SIGKILL');
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
/* gone */
|
|
45
|
-
}
|
|
46
|
-
}, 2000);
|
|
47
|
-
t.unref?.();
|
|
48
|
-
child.once('exit', () => clearTimeout(t));
|
|
49
|
-
}
|
|
50
|
-
function ensureExitHook() {
|
|
51
|
-
if (exitHookInstalled)
|
|
52
|
-
return;
|
|
53
|
-
exitHookInstalled = true;
|
|
54
|
-
const killAll = () => {
|
|
55
|
-
for (const child of liveChildren) {
|
|
56
|
-
try {
|
|
57
|
-
child.kill('SIGKILL'); // process is exiting; be decisive, no async escalation
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
/* gone */
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
liveChildren.clear();
|
|
64
|
-
};
|
|
65
|
-
process.once('exit', killAll);
|
|
66
|
-
// Registering a SIGINT/SIGTERM listener suppresses Node's default
|
|
67
|
-
// terminate-on-signal behavior, so an entrypoint that spawns a tunnel but
|
|
68
|
-
// installs no exit handler of its own would swallow the first Ctrl-C and hang
|
|
69
|
-
// with the process still alive. Re-raise the signal after cleanup so the
|
|
70
|
-
// default termination still fires. `process.once` removes the listener before
|
|
71
|
-
// it runs, so re-raising hits Node's default disposition (terminate).
|
|
72
|
-
const onSignal = (sig) => () => {
|
|
73
|
-
killAll();
|
|
74
|
-
process.kill(process.pid, sig);
|
|
75
|
-
};
|
|
76
|
-
process.once('SIGINT', onSignal('SIGINT'));
|
|
77
|
-
process.once('SIGTERM', onSignal('SIGTERM'));
|
|
78
|
-
}
|
|
79
|
-
/** Track a spawned child; returns an `untrack()` that also kills it cleanly. */
|
|
80
|
-
function trackChild(child) {
|
|
81
|
-
ensureExitHook();
|
|
82
|
-
liveChildren.add(child);
|
|
83
|
-
child.once('exit', () => liveChildren.delete(child));
|
|
84
|
-
return () => new Promise((resolve) => {
|
|
85
|
-
liveChildren.delete(child);
|
|
86
|
-
if (child.exitCode != null || child.signalCode != null)
|
|
87
|
-
return resolve();
|
|
88
|
-
child.once('exit', () => resolve());
|
|
89
|
-
killChild(child);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
const DEFAULT_TUNNEL_URL_TIMEOUT_MS = 30_000;
|
|
93
|
-
/**
|
|
94
|
-
* Spawn a CLI tunnel, parse the assigned public URL out of its output, and
|
|
95
|
-
* resolve a {@link CliTunnelHandle}. The child is tracked so it is killed on
|
|
96
|
-
* `close()`, on tunnel-switch, and on process exit (no orphans). Rejects on
|
|
97
|
-
* timeout, spawn error, or premature exit (the child is killed in every reject
|
|
98
|
-
* path). This is the single spawn-and-parse implementation behind the
|
|
99
|
-
* cloudflared/ngrok tunnel providers and the webhooks tunnel.
|
|
100
|
-
*/
|
|
101
|
-
export function spawnCliTunnel(opts) {
|
|
102
|
-
const { cmd, args, urlRegex } = opts;
|
|
103
|
-
const name = opts.name ?? cmd;
|
|
104
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_TUNNEL_URL_TIMEOUT_MS;
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
let child;
|
|
107
|
-
try {
|
|
108
|
-
child = spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
reject(new Error(`failed to spawn ${name} — is it installed? (${err instanceof Error ? err.message : String(err)})`));
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const untrack = trackChild(child);
|
|
115
|
-
let settled = false;
|
|
116
|
-
const timer = setTimeout(() => {
|
|
117
|
-
if (settled)
|
|
118
|
-
return;
|
|
119
|
-
settled = true;
|
|
120
|
-
void untrack();
|
|
121
|
-
reject(new Error(`${name}: timed out after ${timeoutMs}ms waiting for the tunnel URL`));
|
|
122
|
-
}, timeoutMs);
|
|
123
|
-
timer.unref?.();
|
|
124
|
-
// 'data' events are not line-buffered: the assigned URL can straddle two
|
|
125
|
-
// chunk boundaries (large URL, fragmented flush). Match against a rolling
|
|
126
|
-
// accumulation rather than each lone chunk, capped so a chatty tunnel that
|
|
127
|
-
// never prints a URL can't grow this unboundedly while we wait.
|
|
128
|
-
const MAX_BUF = 8192;
|
|
129
|
-
let acc = '';
|
|
130
|
-
const onData = (buf) => {
|
|
131
|
-
if (settled)
|
|
132
|
-
return; // drain quietly once resolved so the pipe never fills
|
|
133
|
-
acc += buf.toString('utf8');
|
|
134
|
-
if (acc.length > MAX_BUF)
|
|
135
|
-
acc = acc.slice(acc.length - MAX_BUF);
|
|
136
|
-
const url = urlRegex.exec(acc)?.[0] ?? null;
|
|
137
|
-
if (!url)
|
|
138
|
-
return;
|
|
139
|
-
settled = true;
|
|
140
|
-
acc = '';
|
|
141
|
-
clearTimeout(timer);
|
|
142
|
-
resolve({ url, pid: child.pid ?? -1, close: untrack });
|
|
143
|
-
};
|
|
144
|
-
child.stdout?.on('data', onData);
|
|
145
|
-
child.stderr?.on('data', onData);
|
|
146
|
-
child.on('error', (err) => {
|
|
147
|
-
if (settled)
|
|
148
|
-
return;
|
|
149
|
-
settled = true;
|
|
150
|
-
clearTimeout(timer);
|
|
151
|
-
void untrack();
|
|
152
|
-
reject(err);
|
|
153
|
-
});
|
|
154
|
-
child.on('exit', (code) => {
|
|
155
|
-
if (settled)
|
|
156
|
-
return;
|
|
157
|
-
settled = true;
|
|
158
|
-
clearTimeout(timer);
|
|
159
|
-
reject(new Error(`${name} exited (code ${code ?? 'null'}) before emitting a URL`));
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Probe whether a tunnel CLI is installed and runnable (`<cmd> --version`
|
|
165
|
-
* exits 0). Used as the `isAvailable()` gate by CLI-backed tunnel providers.
|
|
166
|
-
*/
|
|
167
|
-
export function isCliTunnelAvailable(cmd) {
|
|
168
|
-
return new Promise((resolve) => {
|
|
169
|
-
const child = spawn(cmd, ['--version'], { stdio: 'ignore' });
|
|
170
|
-
child.once('error', () => resolve(false));
|
|
171
|
-
child.once('exit', (code) => resolve(code === 0));
|
|
172
|
-
});
|
|
173
|
-
}
|
|
2
|
+
* A swappable way to expose a locally-bound surface (the web channel, the mobile
|
|
3
|
+
* bridge, the webhooks listener) to the user over the public internet — so an
|
|
4
|
+
* agent on Telegram/TUI can hand the user a URL they can open. One provider is
|
|
5
|
+
* active per session (registered via plugins, like every other block); core
|
|
6
|
+
* seeds a `localhost` no-op provider so `getActive()` is non-null.
|
|
7
|
+
*
|
|
8
|
+
* The shipped provider is `@moxxy/plugin-tunnel-proxy` (the self-hosted proxy
|
|
9
|
+
* relay). The old cloudflared/ngrok subprocess providers — and the
|
|
10
|
+
* `spawnCliTunnel` helper that backed them — were removed.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
174
13
|
//# sourceMappingURL=tunnel.js.map
|
package/dist/tunnel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../src/tunnel.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../src/tunnel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -175,17 +175,11 @@ export type {
|
|
|
175
175
|
ViewRendererDef,
|
|
176
176
|
} from './view-renderer.js';
|
|
177
177
|
export { VIEW_PRIMITIVES, VIEW_COMPONENTS, DEFAULT_VIEW_TAGS, isSafeViewUrl, countNodes } from './view-renderer.js';
|
|
178
|
-
export type {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
CliTunnelHandle,
|
|
184
|
-
} from './tunnel.js';
|
|
185
|
-
// Node-runtime helpers (spawnCliTunnel/isCliTunnelAvailable, writeFileAtomic*,
|
|
186
|
-
// moxxyHome/moxxyPath, readRequestBody/bearerTokenMatches, channel-auth) are
|
|
187
|
-
// exported from the './server' subpath, NOT the main barrel — they statically
|
|
188
|
-
// reach node:* builtins and would break a browser/RN bundle. See ./server.ts.
|
|
178
|
+
export type { TunnelProviderDef, TunnelHandle, TunnelOpenOptions } from './tunnel.js';
|
|
179
|
+
// Node-runtime helpers (writeFileAtomic*, moxxyHome/moxxyPath,
|
|
180
|
+
// readRequestBody/bearerTokenMatches, channel-auth) are exported from the
|
|
181
|
+
// './server' subpath, NOT the main barrel — they statically reach node:*
|
|
182
|
+
// builtins and would break a browser/RN bundle. See ./server.ts.
|
|
189
183
|
export { isRetryableError, toFriendlyError, zodToJsonSchema, estimateTextTokens, type StopReason } from './provider-utils.js';
|
|
190
184
|
export type { WriteFileAtomicOptions } from './fs-utils.js';
|
|
191
185
|
export { createMutex, type Mutex } from './mutex.js';
|
package/src/package-root.test.ts
CHANGED
|
@@ -44,8 +44,6 @@ describe('@moxxy/sdk package root', () => {
|
|
|
44
44
|
// re-export on the main barrel is caught (see .dependency-cruiser.cjs
|
|
45
45
|
// `no-node-builtins-in-renderer`).
|
|
46
46
|
const NODE_ONLY_VALUE_EXPORTS = [
|
|
47
|
-
'spawnCliTunnel',
|
|
48
|
-
'isCliTunnelAvailable',
|
|
49
47
|
'writeFileAtomic',
|
|
50
48
|
'writeFileAtomicSync',
|
|
51
49
|
'moxxyHome',
|
package/src/plugin.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface PluginSpec {
|
|
|
41
41
|
readonly viewRenderers?: ReadonlyArray<ViewRendererDef>;
|
|
42
42
|
/**
|
|
43
43
|
* Tunnel providers that expose the local web surface publicly (e.g.
|
|
44
|
-
*
|
|
44
|
+
* the proxy relay). One active per session; core seeds a `localhost` no-op.
|
|
45
45
|
*/
|
|
46
46
|
readonly tunnelProviders?: ReadonlyArray<TunnelProviderDef>;
|
|
47
47
|
readonly channels?: ReadonlyArray<ChannelDef>;
|
package/src/server.ts
CHANGED
package/src/tunnel.ts
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A swappable way to expose a locally-bound surface (the web channel
|
|
3
|
-
* user over the public internet — so an
|
|
4
|
-
* a URL they can open. One provider is
|
|
5
|
-
* plugins, like every other block); core
|
|
6
|
-
* `getActive()` is non-null.
|
|
2
|
+
* A swappable way to expose a locally-bound surface (the web channel, the mobile
|
|
3
|
+
* bridge, the webhooks listener) to the user over the public internet — so an
|
|
4
|
+
* agent on Telegram/TUI can hand the user a URL they can open. One provider is
|
|
5
|
+
* active per session (registered via plugins, like every other block); core
|
|
6
|
+
* seeds a `localhost` no-op provider so `getActive()` is non-null.
|
|
7
|
+
*
|
|
8
|
+
* The shipped provider is `@moxxy/plugin-tunnel-proxy` (the self-hosted proxy
|
|
9
|
+
* relay). The old cloudflared/ngrok subprocess providers — and the
|
|
10
|
+
* `spawnCliTunnel` helper that backed them — were removed.
|
|
7
11
|
*/
|
|
8
|
-
import { spawn, type ChildProcess } from 'node:child_process';
|
|
9
12
|
|
|
10
13
|
export interface TunnelOpenOptions {
|
|
11
14
|
readonly port: number;
|
|
12
15
|
readonly host: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional routing label for tunnels that multiplex several local services
|
|
18
|
+
* under one public endpoint (the proxy relay): the returned URL is
|
|
19
|
+
* `…/<label>` and inbound requests under that path segment route back to this
|
|
20
|
+
* `host:port`. Providers that expose a single port (or none) ignore it.
|
|
21
|
+
*/
|
|
22
|
+
readonly label?: string;
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
export interface TunnelHandle {
|
|
16
|
-
/** The publicly reachable base URL (e.g. https://
|
|
26
|
+
/** The publicly reachable base URL (e.g. https://abc123.proxy.moxxy.ai/mobile). */
|
|
17
27
|
readonly url: string;
|
|
18
|
-
/** Tear the tunnel down (
|
|
28
|
+
/** Tear the tunnel down (deregister the target / close the connection). */
|
|
19
29
|
close(): Promise<void>;
|
|
20
30
|
}
|
|
21
31
|
|
|
@@ -23,195 +33,6 @@ export interface TunnelProviderDef {
|
|
|
23
33
|
readonly name: string;
|
|
24
34
|
/** Open a tunnel to `http://host:port`, resolving once the public URL is known. */
|
|
25
35
|
open(opts: TunnelOpenOptions): Promise<TunnelHandle>;
|
|
26
|
-
/** Optional readiness gate (e.g. the
|
|
36
|
+
/** Optional readiness gate (e.g. the relay is reachable). */
|
|
27
37
|
isAvailable?(): Promise<boolean>;
|
|
28
38
|
}
|
|
29
|
-
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
// Shared CLI-tunnel subprocess management
|
|
32
|
-
//
|
|
33
|
-
// cloudflared/ngrok (channel-web) and the webhooks tunnel all do the same
|
|
34
|
-
// thing: spawn a CLI, watch its stdout/stderr for the assigned public URL,
|
|
35
|
-
// resolve once it's seen (or reject on timeout/exit/error), and guarantee the
|
|
36
|
-
// child is killed on close *and* on process exit (Node does not reap children).
|
|
37
|
-
// `spawnCliTunnel` is the single implementation they all share.
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Guarantees spawned tunnel children (cloudflared/ngrok/…) never orphan or
|
|
42
|
-
* leak. Node does NOT kill child processes when the parent exits, so we track
|
|
43
|
-
* every live child and kill any survivors on process teardown — in addition to
|
|
44
|
-
* the explicit `close()` path. Each tracked child is also force-killed
|
|
45
|
-
* (SIGKILL) if it ignores SIGTERM, so a wedged tunnel can't drain
|
|
46
|
-
* memory/handles.
|
|
47
|
-
*/
|
|
48
|
-
const liveChildren = new Set<ChildProcess>();
|
|
49
|
-
let exitHookInstalled = false;
|
|
50
|
-
|
|
51
|
-
function killChild(child: ChildProcess): void {
|
|
52
|
-
if (child.exitCode != null || child.signalCode != null) return;
|
|
53
|
-
try {
|
|
54
|
-
child.kill('SIGTERM');
|
|
55
|
-
} catch {
|
|
56
|
-
/* already gone */
|
|
57
|
-
}
|
|
58
|
-
// Escalate if it doesn't exit promptly. unref so this timer never holds the
|
|
59
|
-
// event loop open on its own.
|
|
60
|
-
const t = setTimeout(() => {
|
|
61
|
-
try {
|
|
62
|
-
child.kill('SIGKILL');
|
|
63
|
-
} catch {
|
|
64
|
-
/* gone */
|
|
65
|
-
}
|
|
66
|
-
}, 2000);
|
|
67
|
-
t.unref?.();
|
|
68
|
-
child.once('exit', () => clearTimeout(t));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function ensureExitHook(): void {
|
|
72
|
-
if (exitHookInstalled) return;
|
|
73
|
-
exitHookInstalled = true;
|
|
74
|
-
const killAll = (): void => {
|
|
75
|
-
for (const child of liveChildren) {
|
|
76
|
-
try {
|
|
77
|
-
child.kill('SIGKILL'); // process is exiting; be decisive, no async escalation
|
|
78
|
-
} catch {
|
|
79
|
-
/* gone */
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
liveChildren.clear();
|
|
83
|
-
};
|
|
84
|
-
process.once('exit', killAll);
|
|
85
|
-
// Registering a SIGINT/SIGTERM listener suppresses Node's default
|
|
86
|
-
// terminate-on-signal behavior, so an entrypoint that spawns a tunnel but
|
|
87
|
-
// installs no exit handler of its own would swallow the first Ctrl-C and hang
|
|
88
|
-
// with the process still alive. Re-raise the signal after cleanup so the
|
|
89
|
-
// default termination still fires. `process.once` removes the listener before
|
|
90
|
-
// it runs, so re-raising hits Node's default disposition (terminate).
|
|
91
|
-
const onSignal = (sig: 'SIGINT' | 'SIGTERM') => (): void => {
|
|
92
|
-
killAll();
|
|
93
|
-
process.kill(process.pid, sig);
|
|
94
|
-
};
|
|
95
|
-
process.once('SIGINT', onSignal('SIGINT'));
|
|
96
|
-
process.once('SIGTERM', onSignal('SIGTERM'));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** Track a spawned child; returns an `untrack()` that also kills it cleanly. */
|
|
100
|
-
function trackChild(child: ChildProcess): () => Promise<void> {
|
|
101
|
-
ensureExitHook();
|
|
102
|
-
liveChildren.add(child);
|
|
103
|
-
child.once('exit', () => liveChildren.delete(child));
|
|
104
|
-
return () =>
|
|
105
|
-
new Promise<void>((resolve) => {
|
|
106
|
-
liveChildren.delete(child);
|
|
107
|
-
if (child.exitCode != null || child.signalCode != null) return resolve();
|
|
108
|
-
child.once('exit', () => resolve());
|
|
109
|
-
killChild(child);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface SpawnCliTunnelOptions {
|
|
114
|
-
/** Executable to spawn (e.g. `cloudflared`, `ngrok`). */
|
|
115
|
-
readonly cmd: string;
|
|
116
|
-
/** Arguments passed to the executable. */
|
|
117
|
-
readonly args: ReadonlyArray<string>;
|
|
118
|
-
/** Matches the assigned public URL in a chunk of the CLI's stdout/stderr. */
|
|
119
|
-
readonly urlRegex: RegExp;
|
|
120
|
-
/** How long to wait for the URL before giving up. Default 30s. */
|
|
121
|
-
readonly timeoutMs?: number;
|
|
122
|
-
/** Human-readable name used in error messages. Defaults to `cmd`. */
|
|
123
|
-
readonly name?: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** A spawned CLI tunnel: the public-URL handle plus the child's pid. */
|
|
127
|
-
export interface CliTunnelHandle extends TunnelHandle {
|
|
128
|
-
/** Spawned process id (-1 if the platform didn't assign one). */
|
|
129
|
-
readonly pid: number;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const DEFAULT_TUNNEL_URL_TIMEOUT_MS = 30_000;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Spawn a CLI tunnel, parse the assigned public URL out of its output, and
|
|
136
|
-
* resolve a {@link CliTunnelHandle}. The child is tracked so it is killed on
|
|
137
|
-
* `close()`, on tunnel-switch, and on process exit (no orphans). Rejects on
|
|
138
|
-
* timeout, spawn error, or premature exit (the child is killed in every reject
|
|
139
|
-
* path). This is the single spawn-and-parse implementation behind the
|
|
140
|
-
* cloudflared/ngrok tunnel providers and the webhooks tunnel.
|
|
141
|
-
*/
|
|
142
|
-
export function spawnCliTunnel(opts: SpawnCliTunnelOptions): Promise<CliTunnelHandle> {
|
|
143
|
-
const { cmd, args, urlRegex } = opts;
|
|
144
|
-
const name = opts.name ?? cmd;
|
|
145
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_TUNNEL_URL_TIMEOUT_MS;
|
|
146
|
-
|
|
147
|
-
return new Promise<CliTunnelHandle>((resolve, reject) => {
|
|
148
|
-
let child: ChildProcess;
|
|
149
|
-
try {
|
|
150
|
-
child = spawn(cmd, args as string[], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
151
|
-
} catch (err) {
|
|
152
|
-
reject(
|
|
153
|
-
new Error(
|
|
154
|
-
`failed to spawn ${name} — is it installed? (${err instanceof Error ? err.message : String(err)})`,
|
|
155
|
-
),
|
|
156
|
-
);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const untrack = trackChild(child);
|
|
161
|
-
let settled = false;
|
|
162
|
-
|
|
163
|
-
const timer = setTimeout(() => {
|
|
164
|
-
if (settled) return;
|
|
165
|
-
settled = true;
|
|
166
|
-
void untrack();
|
|
167
|
-
reject(new Error(`${name}: timed out after ${timeoutMs}ms waiting for the tunnel URL`));
|
|
168
|
-
}, timeoutMs);
|
|
169
|
-
timer.unref?.();
|
|
170
|
-
|
|
171
|
-
// 'data' events are not line-buffered: the assigned URL can straddle two
|
|
172
|
-
// chunk boundaries (large URL, fragmented flush). Match against a rolling
|
|
173
|
-
// accumulation rather than each lone chunk, capped so a chatty tunnel that
|
|
174
|
-
// never prints a URL can't grow this unboundedly while we wait.
|
|
175
|
-
const MAX_BUF = 8192;
|
|
176
|
-
let acc = '';
|
|
177
|
-
const onData = (buf: Buffer): void => {
|
|
178
|
-
if (settled) return; // drain quietly once resolved so the pipe never fills
|
|
179
|
-
acc += buf.toString('utf8');
|
|
180
|
-
if (acc.length > MAX_BUF) acc = acc.slice(acc.length - MAX_BUF);
|
|
181
|
-
const url = urlRegex.exec(acc)?.[0] ?? null;
|
|
182
|
-
if (!url) return;
|
|
183
|
-
settled = true;
|
|
184
|
-
acc = '';
|
|
185
|
-
clearTimeout(timer);
|
|
186
|
-
resolve({ url, pid: child.pid ?? -1, close: untrack });
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
child.stdout?.on('data', onData);
|
|
190
|
-
child.stderr?.on('data', onData);
|
|
191
|
-
child.on('error', (err) => {
|
|
192
|
-
if (settled) return;
|
|
193
|
-
settled = true;
|
|
194
|
-
clearTimeout(timer);
|
|
195
|
-
void untrack();
|
|
196
|
-
reject(err);
|
|
197
|
-
});
|
|
198
|
-
child.on('exit', (code) => {
|
|
199
|
-
if (settled) return;
|
|
200
|
-
settled = true;
|
|
201
|
-
clearTimeout(timer);
|
|
202
|
-
reject(new Error(`${name} exited (code ${code ?? 'null'}) before emitting a URL`));
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Probe whether a tunnel CLI is installed and runnable (`<cmd> --version`
|
|
209
|
-
* exits 0). Used as the `isAvailable()` gate by CLI-backed tunnel providers.
|
|
210
|
-
*/
|
|
211
|
-
export function isCliTunnelAvailable(cmd: string): Promise<boolean> {
|
|
212
|
-
return new Promise<boolean>((resolve) => {
|
|
213
|
-
const child = spawn(cmd, ['--version'], { stdio: 'ignore' });
|
|
214
|
-
child.once('error', () => resolve(false));
|
|
215
|
-
child.once('exit', (code) => resolve(code === 0));
|
|
216
|
-
});
|
|
217
|
-
}
|
package/src/tunnel.test.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isCliTunnelAvailable, spawnCliTunnel } from './tunnel.js';
|
|
3
|
-
|
|
4
|
-
const URL_RE = /https:\/\/[a-z0-9-]+\.example\.test/i;
|
|
5
|
-
|
|
6
|
-
describe('spawnCliTunnel', () => {
|
|
7
|
-
it('resolves the parsed URL + pid when the child prints a matching line', async () => {
|
|
8
|
-
const handle = await spawnCliTunnel({
|
|
9
|
-
cmd: process.execPath,
|
|
10
|
-
// Print a noise line, then the URL, then stay alive so close() can kill it.
|
|
11
|
-
args: ['-e', 'console.log("starting up"); console.log("url=https://abc-123.example.test ready"); setInterval(()=>{}, 1000);'],
|
|
12
|
-
urlRegex: URL_RE,
|
|
13
|
-
name: 'faketunnel',
|
|
14
|
-
timeoutMs: 5_000,
|
|
15
|
-
});
|
|
16
|
-
expect(handle.url).toBe('https://abc-123.example.test');
|
|
17
|
-
expect(handle.pid).toBeGreaterThan(0);
|
|
18
|
-
await handle.close();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('parses URLs printed on stderr too', async () => {
|
|
22
|
-
const handle = await spawnCliTunnel({
|
|
23
|
-
cmd: process.execPath,
|
|
24
|
-
args: ['-e', 'console.error("https://err-host.example.test"); setInterval(()=>{}, 1000);'],
|
|
25
|
-
urlRegex: URL_RE,
|
|
26
|
-
timeoutMs: 5_000,
|
|
27
|
-
});
|
|
28
|
-
expect(handle.url).toBe('https://err-host.example.test');
|
|
29
|
-
await handle.close();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('u125-1: resolves a URL split across two stdout chunks', async () => {
|
|
33
|
-
// Write the URL in two separate process.stdout.write calls, split
|
|
34
|
-
// mid-host, with a tick gap so they surface as distinct 'data' events.
|
|
35
|
-
// Matching each chunk in isolation would miss it; the rolling buffer must
|
|
36
|
-
// stitch them.
|
|
37
|
-
const handle = await spawnCliTunnel({
|
|
38
|
-
cmd: process.execPath,
|
|
39
|
-
args: [
|
|
40
|
-
'-e',
|
|
41
|
-
'process.stdout.write("ready https://abc-1");' +
|
|
42
|
-
'setTimeout(()=>{process.stdout.write("23.example.test\\n");},50);' +
|
|
43
|
-
'setInterval(()=>{}, 1000);',
|
|
44
|
-
],
|
|
45
|
-
urlRegex: URL_RE,
|
|
46
|
-
name: 'splittunnel',
|
|
47
|
-
timeoutMs: 5_000,
|
|
48
|
-
});
|
|
49
|
-
expect(handle.url).toBe('https://abc-123.example.test');
|
|
50
|
-
await handle.close();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('rejects when the child exits before emitting a URL', async () => {
|
|
54
|
-
await expect(
|
|
55
|
-
spawnCliTunnel({
|
|
56
|
-
cmd: process.execPath,
|
|
57
|
-
args: ['-e', 'process.exit(3)'],
|
|
58
|
-
urlRegex: URL_RE,
|
|
59
|
-
name: 'faketunnel',
|
|
60
|
-
timeoutMs: 5_000,
|
|
61
|
-
}),
|
|
62
|
-
).rejects.toThrow(/faketunnel exited \(code 3\) before emitting a URL/);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('rejects when the executable cannot be spawned', async () => {
|
|
66
|
-
await expect(
|
|
67
|
-
spawnCliTunnel({
|
|
68
|
-
cmd: 'definitely-not-a-real-binary-xyz',
|
|
69
|
-
args: [],
|
|
70
|
-
urlRegex: URL_RE,
|
|
71
|
-
name: 'nope',
|
|
72
|
-
timeoutMs: 2_000,
|
|
73
|
-
}),
|
|
74
|
-
).rejects.toThrow();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('rejects on timeout when no URL is ever printed (and kills the child)', async () => {
|
|
78
|
-
await expect(
|
|
79
|
-
spawnCliTunnel({
|
|
80
|
-
cmd: process.execPath,
|
|
81
|
-
args: ['-e', 'setInterval(()=>{}, 1000);'],
|
|
82
|
-
urlRegex: URL_RE,
|
|
83
|
-
name: 'slowtunnel',
|
|
84
|
-
timeoutMs: 150,
|
|
85
|
-
}),
|
|
86
|
-
).rejects.toThrow(/slowtunnel: timed out after 150ms/);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('isCliTunnelAvailable', () => {
|
|
91
|
-
it('resolves true for an installed runnable binary', async () => {
|
|
92
|
-
// node is always present in the test runtime and supports --version.
|
|
93
|
-
expect(await isCliTunnelAvailable(process.execPath)).toBe(true);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('resolves false for a missing binary', async () => {
|
|
97
|
-
expect(await isCliTunnelAvailable('definitely-not-a-real-binary-xyz')).toBe(false);
|
|
98
|
-
});
|
|
99
|
-
});
|