@nhrbuilds/flashbrowse 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/README.md +178 -2
- package/dist/cjs/cli.d.ts +2 -0
- package/dist/cjs/cli.js +78 -0
- package/dist/cjs/cli.js.map +1 -0
- package/dist/cjs/client.d.ts +1 -0
- package/dist/cjs/client.js +6 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/controllers/flashbrowse-client.js +217 -0
- package/dist/cjs/controllers/flashbrowse-client.js.map +1 -0
- package/dist/cjs/errors.d.ts +11 -0
- package/dist/cjs/errors.js +28 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/services/binary-resolver.js +166 -0
- package/dist/cjs/services/binary-resolver.js.map +1 -0
- package/dist/cjs/services/mcp-client.js +494 -0
- package/dist/cjs/services/mcp-client.js.map +1 -0
- package/dist/cjs/services/process-runner.js +248 -0
- package/dist/cjs/services/process-runner.js.map +1 -0
- package/dist/cjs/services/session-state.js +210 -0
- package/dist/cjs/services/session-state.js.map +1 -0
- package/dist/cjs/types/index.js +3 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/cli-args.js +35 -0
- package/dist/cjs/utils/cli-args.js.map +1 -0
- package/dist/cjs/utils/environment.js +16 -0
- package/dist/cjs/utils/environment.js.map +1 -0
- package/dist/cjs/utils/mcp-line-reader.js +45 -0
- package/dist/cjs/utils/mcp-line-reader.js.map +1 -0
- package/dist/cjs/utils/platform.js +66 -0
- package/dist/cjs/utils/platform.js.map +1 -0
- package/dist/cjs/utils/terminate-process.js +26 -0
- package/dist/cjs/utils/terminate-process.js.map +1 -0
- package/dist/esm/cli.js +76 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/client.js +2 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/controllers/flashbrowse-client.js +213 -0
- package/dist/esm/controllers/flashbrowse-client.js.map +1 -0
- package/dist/esm/errors.js +24 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/services/binary-resolver.js +126 -0
- package/dist/esm/services/binary-resolver.js.map +1 -0
- package/dist/esm/services/mcp-client.js +488 -0
- package/dist/esm/services/mcp-client.js.map +1 -0
- package/dist/esm/services/process-runner.js +244 -0
- package/dist/esm/services/process-runner.js.map +1 -0
- package/dist/esm/services/session-state.js +200 -0
- package/dist/esm/services/session-state.js.map +1 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/cli-args.js +31 -0
- package/dist/esm/utils/cli-args.js.map +1 -0
- package/dist/esm/utils/environment.js +12 -0
- package/dist/esm/utils/environment.js.map +1 -0
- package/dist/esm/utils/mcp-line-reader.js +41 -0
- package/dist/esm/utils/mcp-line-reader.js.map +1 -0
- package/dist/esm/utils/platform.js +60 -0
- package/dist/esm/utils/platform.js.map +1 -0
- package/dist/esm/utils/terminate-process.js +23 -0
- package/dist/esm/utils/terminate-process.js.map +1 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/client.d.ts +1 -0
- package/dist/types/controllers/flashbrowse-client.d.ts +30 -0
- package/dist/types/errors.d.ts +11 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/services/binary-resolver.d.ts +9 -0
- package/dist/types/services/mcp-client.d.ts +87 -0
- package/dist/types/services/process-runner.d.ts +12 -0
- package/dist/types/services/session-state.d.ts +5 -0
- package/dist/types/types/index.d.ts +130 -0
- package/dist/types/utils/cli-args.d.ts +3 -0
- package/dist/types/utils/environment.d.ts +3 -0
- package/dist/types/utils/mcp-line-reader.d.ts +10 -0
- package/dist/types/utils/platform.d.ts +8 -0
- package/dist/types/utils/terminate-process.d.ts +3 -0
- package/package.json +56 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
/** Terminates a process and its descendants on Windows, or signals it on Unix. */
|
|
3
|
+
export function terminateProcess(child, signal = "SIGTERM") {
|
|
4
|
+
if (process.platform !== "win32" || child.pid === undefined) {
|
|
5
|
+
if (child.exitCode === null)
|
|
6
|
+
child.kill(signal);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const killer = spawn("taskkill.exe", ["/PID", String(child.pid), "/T", "/F"], {
|
|
10
|
+
stdio: "ignore",
|
|
11
|
+
windowsHide: true,
|
|
12
|
+
});
|
|
13
|
+
const fallback = () => {
|
|
14
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
15
|
+
child.kill("SIGKILL");
|
|
16
|
+
};
|
|
17
|
+
killer.once("error", fallback);
|
|
18
|
+
killer.once("close", (code) => {
|
|
19
|
+
if (code !== 0)
|
|
20
|
+
fallback();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=terminate-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminate-process.js","sourceRoot":"","sources":["../../../src/utils/terminate-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAE9D,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,KAAmB,EAAE,SAAyB,SAAS;IACtF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5D,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QAC5E,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,GAAS,EAAE;QAC1B,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClF,CAAC,CAAC;IACF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAC5B,IAAI,IAAI,KAAK,CAAC;YAAE,QAAQ,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Flashbrowse } from "./controllers/flashbrowse-client.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ChildProcess } from "node:child_process";
|
|
2
|
+
import { FlashbrowseMcpClient } from "../services/mcp-client.js";
|
|
3
|
+
import type { ActOptions, CloseOptions, DoctorOptions, DumpOptions, FlashbrowseOptions, McpClientOptions, McpOptions, OpenOptions, RunOptions, SetupOptions, SpawnOptions, StatsOptions, UpdateOptions } from "../types/index.js";
|
|
4
|
+
/** Typed process wrapper for the flashbrowse command line interface. */
|
|
5
|
+
export declare class Flashbrowse {
|
|
6
|
+
private readonly options;
|
|
7
|
+
private readonly binaryResolver;
|
|
8
|
+
private readonly processRunner;
|
|
9
|
+
constructor(options?: FlashbrowseOptions);
|
|
10
|
+
/** Starts a raw CLI command and returns its child process. */
|
|
11
|
+
spawn(args: readonly string[], options?: SpawnOptions): Promise<ChildProcess>;
|
|
12
|
+
/** Runs a CLI command and returns stdout without trimming or parsing it. */
|
|
13
|
+
run(args: readonly string[], options?: RunOptions): Promise<string>;
|
|
14
|
+
/** Opens a URL and returns the rendered accessibility tree from stdout. */
|
|
15
|
+
open(url: string, options?: OpenOptions): Promise<string>;
|
|
16
|
+
/** Performs an action in a persistent session and returns the refreshed tree. */
|
|
17
|
+
act(actionId: number, options: ActOptions): Promise<string>;
|
|
18
|
+
/** Dumps one of the CLI's supported representations for a URL. */
|
|
19
|
+
dump(url: string, options?: DumpOptions): Promise<string>;
|
|
20
|
+
bench(urls?: readonly string[], options?: RunOptions): Promise<string>;
|
|
21
|
+
setup(options?: SetupOptions): Promise<string>;
|
|
22
|
+
doctor(options?: DoctorOptions): Promise<string>;
|
|
23
|
+
stats(options?: StatsOptions): Promise<string>;
|
|
24
|
+
update(options?: UpdateOptions): Promise<string>;
|
|
25
|
+
close(options: CloseOptions): Promise<string>;
|
|
26
|
+
/** Starts the MCP server with piped streams for JSON-RPC communication. */
|
|
27
|
+
startMcp(options?: McpOptions, spawnOptions?: SpawnOptions): Promise<ChildProcess>;
|
|
28
|
+
/** Starts one MCP server process and initializes a reusable JSON-RPC client. */
|
|
29
|
+
startMcpClient(options?: McpOptions, spawnOptions?: SpawnOptions, clientOptions?: McpClientOptions): Promise<FlashbrowseMcpClient>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FlashbrowseErrorOptions } from "./types/index.js";
|
|
2
|
+
/** Describes a failed process launch or nonzero flashbrowse exit. */
|
|
3
|
+
export declare class FlashbrowseError extends Error {
|
|
4
|
+
readonly args: readonly string[];
|
|
5
|
+
readonly binaryPath: string;
|
|
6
|
+
readonly exitCode: number | null;
|
|
7
|
+
readonly signal: NodeJS.Signals | null;
|
|
8
|
+
readonly stderr: string;
|
|
9
|
+
constructor(message: string, options: FlashbrowseErrorOptions);
|
|
10
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Flashbrowse } from "./controllers/flashbrowse-client.js";
|
|
2
|
+
export { FlashbrowseError } from "./errors.js";
|
|
3
|
+
export { FlashbrowseMcpClient, FlashbrowseMcpError } from "./services/mcp-client.js";
|
|
4
|
+
export type { ActOptions, BrowserAction, CloseOptions, DoctorOptions, DumpFormat, DumpOptions, FlashbrowseOptions, GlobalCliOptions, LogFormat, McpClientOptions, McpInitializeResult, McpListToolsResult, McpNotification, McpOptions, McpRequestOptions, McpToolCallResult, McpToolDefinition, OpenOptions, ResourcePolicy, RunOptions, SetupOptions, SpawnOptions, StatsOptions, StealthProfile, UpdateOptions, } from "./types/index.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FlashbrowseError } from "../errors.js";
|
|
2
|
+
import type { FlashbrowseOptions } from "../types/index.js";
|
|
3
|
+
export declare class BinaryResolver {
|
|
4
|
+
private readonly options;
|
|
5
|
+
constructor(options: FlashbrowseOptions);
|
|
6
|
+
private resolveBinary;
|
|
7
|
+
resolveBinaryFor(args: readonly string[], env: NodeJS.ProcessEnv, cwd: string | undefined): Promise<string>;
|
|
8
|
+
spawnError(binaryPath: string, args: readonly string[], cause: unknown, env: NodeJS.ProcessEnv): FlashbrowseError;
|
|
9
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import type { ChildProcess } from "node:child_process";
|
|
3
|
+
import type { McpClientOptions, McpInitializeResult, McpListToolsResult, McpNotification, McpRequestOptions, McpToolCallResult } from "../types/index.js";
|
|
4
|
+
interface McpClientEvents {
|
|
5
|
+
notification: [notification: McpNotification];
|
|
6
|
+
transportError: [error: FlashbrowseMcpError];
|
|
7
|
+
exit: [result: {
|
|
8
|
+
code: number | null;
|
|
9
|
+
signal: NodeJS.Signals | null;
|
|
10
|
+
}];
|
|
11
|
+
}
|
|
12
|
+
export declare function validateMcpClientOptions(options: McpClientOptions): void;
|
|
13
|
+
/** An MCP transport or JSON-RPC error returned by the flashbrowse server. */
|
|
14
|
+
export declare class FlashbrowseMcpError extends Error {
|
|
15
|
+
readonly code?: number;
|
|
16
|
+
readonly method?: string;
|
|
17
|
+
readonly data?: unknown;
|
|
18
|
+
readonly stderr?: string;
|
|
19
|
+
constructor(message: string, options?: {
|
|
20
|
+
code?: number;
|
|
21
|
+
method?: string;
|
|
22
|
+
data?: unknown;
|
|
23
|
+
stderr?: string;
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** A persistent MCP stdio connection to one flashbrowse server process. */
|
|
28
|
+
export declare class FlashbrowseMcpClient extends EventEmitter<McpClientEvents> {
|
|
29
|
+
readonly child: ChildProcess;
|
|
30
|
+
private readonly requestTimeoutMs;
|
|
31
|
+
private readonly initializeTimeoutMs;
|
|
32
|
+
private readonly shutdownTimeoutMs;
|
|
33
|
+
private readonly maxLineBytes;
|
|
34
|
+
private readonly maxResponseLineBytes;
|
|
35
|
+
private readonly pending;
|
|
36
|
+
private readonly drainWaiters;
|
|
37
|
+
private readonly exitPromise;
|
|
38
|
+
private resolveExit;
|
|
39
|
+
private readonly lineReader;
|
|
40
|
+
private readonly stderrDecoder;
|
|
41
|
+
private stderrTail;
|
|
42
|
+
private nextRequestId;
|
|
43
|
+
private initialized;
|
|
44
|
+
private initialization?;
|
|
45
|
+
private closing;
|
|
46
|
+
private processExited;
|
|
47
|
+
private processExit?;
|
|
48
|
+
private stdoutEnded;
|
|
49
|
+
private processExitFinalized;
|
|
50
|
+
private streamsClosed;
|
|
51
|
+
private closePromise?;
|
|
52
|
+
private transportError?;
|
|
53
|
+
constructor(child: ChildProcess, options?: McpClientOptions);
|
|
54
|
+
/** Completes the MCP initialize exchange and enables requests. */
|
|
55
|
+
initialize(): Promise<McpInitializeResult>;
|
|
56
|
+
private initializeProcess;
|
|
57
|
+
/** Sends a JSON-RPC request over the persistent MCP connection. */
|
|
58
|
+
request<T = unknown>(method: string, params?: Record<string, unknown>, options?: McpRequestOptions): Promise<T>;
|
|
59
|
+
/** Sends a JSON-RPC notification over the persistent MCP connection. */
|
|
60
|
+
notify(method: string, params?: Record<string, unknown>): Promise<void>;
|
|
61
|
+
/** Returns one page of server tools. Use request for cursor pagination. */
|
|
62
|
+
listTools(params?: {
|
|
63
|
+
cursor?: string;
|
|
64
|
+
}, options?: McpRequestOptions): Promise<McpListToolsResult>;
|
|
65
|
+
/** Calls any MCP tool exposed by the server. */
|
|
66
|
+
callTool(name: string, args?: Record<string, unknown>, options?: McpRequestOptions): Promise<McpToolCallResult>;
|
|
67
|
+
/** Waits for in-flight requests, closes stdin, and stops the server if needed. */
|
|
68
|
+
close(): Promise<void>;
|
|
69
|
+
private requestRaw;
|
|
70
|
+
private notifyRaw;
|
|
71
|
+
private writeMessage;
|
|
72
|
+
private readStdout;
|
|
73
|
+
private readMessage;
|
|
74
|
+
private readStderr;
|
|
75
|
+
private handleProcessExit;
|
|
76
|
+
private handleStdoutEnd;
|
|
77
|
+
private finalizeProcessExit;
|
|
78
|
+
private handleStreamsClose;
|
|
79
|
+
private appendStderr;
|
|
80
|
+
private finishPending;
|
|
81
|
+
private failTransport;
|
|
82
|
+
private transportFailure;
|
|
83
|
+
private closeProcess;
|
|
84
|
+
private closeStreamsBounded;
|
|
85
|
+
private waitForPending;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { BinaryResolver } from "./binary-resolver.js";
|
|
3
|
+
import type { FlashbrowseOptions, RunOptions, SpawnOptions } from "../types/index.js";
|
|
4
|
+
export declare class FlashbrowseProcess {
|
|
5
|
+
private readonly options;
|
|
6
|
+
readonly binaryResolver: BinaryResolver;
|
|
7
|
+
constructor(options: FlashbrowseOptions, binaryResolver: BinaryResolver);
|
|
8
|
+
/** Starts a raw CLI command and returns its child process. */
|
|
9
|
+
spawn(args: readonly string[], options?: SpawnOptions): Promise<ChildProcess>;
|
|
10
|
+
/** Runs a CLI command and returns stdout without trimming or parsing it. */
|
|
11
|
+
run(args: readonly string[], options?: RunOptions): Promise<string>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const activeSessions: Map<string, "open" | "opening">;
|
|
2
|
+
export declare function acquireSessionLock(sessionPath: string): Promise<() => Promise<void>>;
|
|
3
|
+
export declare function sessionFileExists(sessionPath: string): Promise<boolean>;
|
|
4
|
+
export declare function persistentSessionPath(id: string, env: NodeJS.ProcessEnv, cwd?: string): string | undefined;
|
|
5
|
+
export declare function closeAttachedTarget(sessionPath: string, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { StdioOptions } from "node:child_process";
|
|
2
|
+
/** Resource loading mode accepted by the flashbrowse CLI. */
|
|
3
|
+
export type ResourcePolicy = "agent-default" | "text-only" | "full-render";
|
|
4
|
+
export type StealthProfile = "host-native" | "windows";
|
|
5
|
+
export type LogFormat = "text" | "json";
|
|
6
|
+
export type DumpFormat = "markdown" | "axtree" | "axtree-nested" | "raw" | "fidelity";
|
|
7
|
+
export type BrowserAction = "click" | "double_click" | "right_click" | "drag_and_drop" | "fill" | "hover" | "press_key" | "scroll" | "select" | "upload";
|
|
8
|
+
export interface GlobalCliOptions {
|
|
9
|
+
chromePath?: string;
|
|
10
|
+
textOnly?: boolean;
|
|
11
|
+
fullRender?: boolean;
|
|
12
|
+
resourcePolicy?: ResourcePolicy;
|
|
13
|
+
stealthProfile?: StealthProfile;
|
|
14
|
+
verbose?: boolean;
|
|
15
|
+
logFormat?: LogFormat;
|
|
16
|
+
}
|
|
17
|
+
/** Executable, process, and global CLI configuration for a client. */
|
|
18
|
+
export interface FlashbrowseOptions extends GlobalCliOptions {
|
|
19
|
+
binaryPath?: string;
|
|
20
|
+
cwd?: string;
|
|
21
|
+
env?: NodeJS.ProcessEnv;
|
|
22
|
+
}
|
|
23
|
+
/** Per-command process settings. No timeout is added unless the caller aborts. */
|
|
24
|
+
export interface RunOptions {
|
|
25
|
+
cwd?: string;
|
|
26
|
+
env?: NodeJS.ProcessEnv;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
/** Maximum captured bytes for stdout and stderr separately. Defaults to 64 MiB. */
|
|
29
|
+
maxOutputBytes?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface SpawnOptions extends RunOptions {
|
|
32
|
+
stdio?: StdioOptions;
|
|
33
|
+
}
|
|
34
|
+
export interface OpenOptions extends RunOptions {
|
|
35
|
+
sessionId?: string;
|
|
36
|
+
cdpUrl?: string;
|
|
37
|
+
userDataDir?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ActOptions extends RunOptions {
|
|
40
|
+
sessionId: string;
|
|
41
|
+
action?: BrowserAction;
|
|
42
|
+
value?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface DumpOptions extends RunOptions {
|
|
45
|
+
format?: DumpFormat;
|
|
46
|
+
noPrune?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface SetupOptions extends RunOptions {
|
|
49
|
+
force?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface DoctorOptions extends RunOptions {
|
|
52
|
+
json?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface StatsOptions extends RunOptions {
|
|
55
|
+
limit?: number;
|
|
56
|
+
json?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface UpdateOptions extends RunOptions {
|
|
59
|
+
check?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface CloseOptions extends RunOptions {
|
|
62
|
+
sessionId: string;
|
|
63
|
+
}
|
|
64
|
+
/** Options for the long-running MCP stdio server. */
|
|
65
|
+
export interface McpOptions extends RunOptions {
|
|
66
|
+
cdpUrl?: string;
|
|
67
|
+
userDataDir?: string;
|
|
68
|
+
storageStateRoot?: string;
|
|
69
|
+
fileRoot?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Timeouts and framing limits for a managed, long-running MCP client. */
|
|
72
|
+
export interface McpClientOptions {
|
|
73
|
+
/** Default timeout for each MCP request. Defaults to 125 seconds. */
|
|
74
|
+
requestTimeoutMs?: number;
|
|
75
|
+
/** Timeout for MCP initialization. Defaults to 10 seconds. */
|
|
76
|
+
initializeTimeoutMs?: number;
|
|
77
|
+
/** Time to wait for in-flight calls and graceful server shutdown. Defaults to 5 seconds. */
|
|
78
|
+
shutdownTimeoutMs?: number;
|
|
79
|
+
/** Maximum size of one outgoing message and default response limit. Defaults to 1 MiB. */
|
|
80
|
+
maxLineBytes?: number;
|
|
81
|
+
/** Maximum size of one server response. Defaults to 64 MiB. */
|
|
82
|
+
maxResponseLineBytes?: number;
|
|
83
|
+
}
|
|
84
|
+
/** Per-request cancellation and timeout settings for the MCP client. */
|
|
85
|
+
export interface McpRequestOptions {
|
|
86
|
+
signal?: AbortSignal;
|
|
87
|
+
timeoutMs?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface McpInitializeResult {
|
|
90
|
+
protocolVersion: string;
|
|
91
|
+
capabilities: Record<string, unknown>;
|
|
92
|
+
serverInfo: {
|
|
93
|
+
name: string;
|
|
94
|
+
version: string;
|
|
95
|
+
[key: string]: unknown;
|
|
96
|
+
};
|
|
97
|
+
instructions?: string;
|
|
98
|
+
[key: string]: unknown;
|
|
99
|
+
}
|
|
100
|
+
export interface McpNotification {
|
|
101
|
+
method: string;
|
|
102
|
+
params?: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
export interface McpToolDefinition {
|
|
105
|
+
name: string;
|
|
106
|
+
title?: string;
|
|
107
|
+
description?: string;
|
|
108
|
+
inputSchema?: Record<string, unknown>;
|
|
109
|
+
outputSchema?: Record<string, unknown>;
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
}
|
|
112
|
+
export interface McpListToolsResult {
|
|
113
|
+
tools: McpToolDefinition[];
|
|
114
|
+
nextCursor?: string;
|
|
115
|
+
[key: string]: unknown;
|
|
116
|
+
}
|
|
117
|
+
export interface McpToolCallResult {
|
|
118
|
+
content?: unknown[];
|
|
119
|
+
structuredContent?: unknown;
|
|
120
|
+
isError?: boolean;
|
|
121
|
+
[key: string]: unknown;
|
|
122
|
+
}
|
|
123
|
+
export interface FlashbrowseErrorOptions {
|
|
124
|
+
args: readonly string[];
|
|
125
|
+
binaryPath: string;
|
|
126
|
+
exitCode?: number | null;
|
|
127
|
+
signal?: NodeJS.Signals | null;
|
|
128
|
+
stderr?: string;
|
|
129
|
+
cause?: unknown;
|
|
130
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Splits MCP stdio output into newline terminated, size limited frames. */
|
|
2
|
+
export declare class McpLineReader {
|
|
3
|
+
private readonly maxLineBytes;
|
|
4
|
+
private readonly chunks;
|
|
5
|
+
private lineBytes;
|
|
6
|
+
constructor(maxLineBytes: number);
|
|
7
|
+
push(chunk: Buffer): Buffer[];
|
|
8
|
+
get hasIncompleteLine(): boolean;
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface PlatformTarget {
|
|
2
|
+
packageName: string;
|
|
3
|
+
executableName: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const minimumBundledGlibcVersion = "2.39";
|
|
6
|
+
export declare function supportsBundledLinuxBinary(version?: string | undefined): boolean;
|
|
7
|
+
export declare function platformTargetFor(platform: string, arch: string, hasGlibc?: boolean): PlatformTarget | undefined;
|
|
8
|
+
export declare function runtimeHasGlibc(): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nhrbuilds/flashbrowse",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript API and CLI wrapper for the flashbrowse native browser controller",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nhrbuilds/flashbrowse-js.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/nhrbuilds/flashbrowse-js#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/nhrbuilds/flashbrowse-js/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/cjs/index.js",
|
|
16
|
+
"module": "./dist/esm/index.js",
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"default": "./dist/esm/index.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/cjs/index.d.ts",
|
|
26
|
+
"default": "./dist/cjs/index.js"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"bin": {
|
|
31
|
+
"flashbrowse": "./dist/esm/cli.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@types/node": ">=20.17.6"
|
|
43
|
+
},
|
|
44
|
+
"optionalDependencies": {
|
|
45
|
+
"@nhrbuilds/flashbrowse-linux-x64-gnu": "1.0.0",
|
|
46
|
+
"@nhrbuilds/flashbrowse-linux-arm64-gnu": "1.0.0",
|
|
47
|
+
"@nhrbuilds/flashbrowse-darwin-x64": "1.0.0",
|
|
48
|
+
"@nhrbuilds/flashbrowse-darwin-arm64": "1.0.0",
|
|
49
|
+
"@nhrbuilds/flashbrowse-win32-x64": "1.0.0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "node ../../scripts/clean-build.mjs && tsc -p ../../tsconfig.esm.json && tsc -p ../../tsconfig.cjs.json && tsc -p ../../tsconfig.types.json && node ../../scripts/finalize-build.mjs",
|
|
53
|
+
"prepack": "npm run build"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
}
|
|
58
|
+
}
|