@vymalo/opencode-browser 0.12.0 → 0.14.1
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/agent-client.d.ts +36 -36
- package/dist/agent-client.js +201 -189
- package/dist/agent-client.js.map +1 -1
- package/dist/broker.d.ts +85 -87
- package/dist/broker.js +614 -599
- package/dist/broker.js.map +1 -1
- package/dist/catalog.d.ts +76 -76
- package/dist/catalog.js +826 -596
- package/dist/catalog.js.map +1 -1
- package/dist/endpoint.d.ts +42 -42
- package/dist/endpoint.js +132 -131
- package/dist/endpoint.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib.js +1 -0
- package/dist/lib.js.map +1 -1
- package/dist/logging.d.ts +6 -6
- package/dist/logging.js +60 -63
- package/dist/logging.js.map +1 -1
- package/dist/node-transport.d.ts +6 -6
- package/dist/node-transport.js +48 -44
- package/dist/node-transport.js.map +1 -1
- package/dist/opencode.d.ts +10 -10
- package/dist/opencode.js +143 -146
- package/dist/opencode.js.map +1 -1
- package/dist/protocol.d.ts +127 -127
- package/dist/protocol.js +148 -128
- package/dist/protocol.js.map +1 -1
- package/dist/schema.d.ts +32 -32
- package/dist/schema.js +39 -44
- package/dist/schema.js.map +1 -1
- package/dist/token-file.d.ts +4 -4
- package/dist/token-file.js +68 -60
- package/dist/token-file.js.map +1 -1
- package/dist/tools.d.ts +11 -11
- package/dist/tools.js +128 -123
- package/dist/tools.js.map +1 -1
- package/dist/transport.d.ts +17 -17
- package/dist/transport.js +3 -9
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +61 -61
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
package/dist/broker.d.ts
CHANGED
|
@@ -3,102 +3,100 @@ import { type BrowserAction } from "./protocol.js";
|
|
|
3
3
|
import type { BridgeTransport } from "./transport.js";
|
|
4
4
|
/** Thrown when a command can't be routed or the executor reports failure. */
|
|
5
5
|
export declare class BrokerError extends Error {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
readonly code?: string;
|
|
7
|
+
constructor(message: string, code?: string);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare const DEFAULT_MAX_COMMAND_MS =
|
|
10
|
+
* Hard ceiling for any per-command timeout, so a tool requesting a long
|
|
11
|
+
* human-paced deadline can't pin a command open indefinitely. 10 minutes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_MAX_COMMAND_MS = 6e5;
|
|
14
14
|
/** What an agent (local or remote) uses to drive browsers through the broker. */
|
|
15
15
|
export interface AgentEndpoint {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** Release this agent's browsers (detach the debugger) without closing tabs. */
|
|
20
|
-
release(): void;
|
|
16
|
+
send(action: BrowserAction, group: string, params: Record<string, unknown>, signal?: AbortSignal, target?: string, timeoutMs?: number): Promise<unknown>;
|
|
17
|
+
/** Release this agent's browsers (detach the debugger) without closing tabs. */
|
|
18
|
+
release(): void;
|
|
21
19
|
}
|
|
22
20
|
export interface BrokerOptions {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
host: string;
|
|
22
|
+
port: number;
|
|
23
|
+
token: string;
|
|
24
|
+
/** Executor preference forwarded to extensions in `ready`. */
|
|
25
|
+
executor?: "auto" | "cdp" | "content";
|
|
26
|
+
/** Default per-command timeout in ms; `<= 0` disables. */
|
|
27
|
+
timeoutMs: number;
|
|
28
|
+
/** Ceiling a per-command override can request (default `DEFAULT_MAX_COMMAND_MS`). */
|
|
29
|
+
maxCommandMs?: number;
|
|
32
30
|
}
|
|
33
31
|
export interface BrokerDeps {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
logger: Logger;
|
|
33
|
+
transport: BridgeTransport;
|
|
34
|
+
/**
|
|
35
|
+
* Optional: re-read the shared bridge token from its source of truth (the
|
|
36
|
+
* per-user `bridge.json`). Called on a bad-token handshake so a long-lived
|
|
37
|
+
* host — which resolved its token once at boot and otherwise never re-reads —
|
|
38
|
+
* can pick up a rotated token without a restart. Returns the current token, or
|
|
39
|
+
* `undefined` if unavailable. Host-only; guests/tests can omit it.
|
|
40
|
+
*/
|
|
41
|
+
reloadToken?: () => string | undefined;
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
* Hosts the WebSocket server and routes commands between **agents** (producers:
|
|
45
|
+
* the plugin, the MCP server, guest adapters) and **executors** (the browser
|
|
46
|
+
* extensions), keyed by named-group ownership. Generalizes the old single-client
|
|
47
|
+
* bridge. Runtime-agnostic via the injected transport.
|
|
48
|
+
*/
|
|
51
49
|
export declare class Broker {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
50
|
+
private readonly opts;
|
|
51
|
+
private readonly deps;
|
|
52
|
+
private readonly executors;
|
|
53
|
+
private readonly executorById;
|
|
54
|
+
private readonly agents;
|
|
55
|
+
private readonly groupOwner;
|
|
56
|
+
private readonly pending;
|
|
57
|
+
private primaryExecutorId;
|
|
58
|
+
private agentSeq;
|
|
59
|
+
private execSeq;
|
|
60
|
+
private started;
|
|
61
|
+
constructor(opts: BrokerOptions, deps: BrokerDeps);
|
|
62
|
+
get executorCount(): number;
|
|
63
|
+
start(): Promise<void>;
|
|
64
|
+
stop(): void;
|
|
65
|
+
/** An in-process agent (the host adapter's own tools), bypassing a socket. */
|
|
66
|
+
createLocalAgent(): AgentEndpoint;
|
|
67
|
+
private onMessage;
|
|
68
|
+
private handleHello;
|
|
69
|
+
/**
|
|
70
|
+
* Re-read the shared token (via the injected `reloadToken`) and adopt it if the
|
|
71
|
+
* source of truth now holds a different, non-empty value. Lets a rotation in
|
|
72
|
+
* `bridge.json` reach this running host. No-op without a `reloadToken` dep, or
|
|
73
|
+
* when the file is unchanged/unavailable — so a genuinely wrong token still
|
|
74
|
+
* gets rejected. Reads only on a mismatch, so it's not on the hot path.
|
|
75
|
+
*/
|
|
76
|
+
private adoptRotatedToken;
|
|
77
|
+
private rebuildFromExecutor;
|
|
78
|
+
private onClose;
|
|
79
|
+
private route;
|
|
80
|
+
private resolveExecutor;
|
|
81
|
+
private pickExecutor;
|
|
82
|
+
/** Effective per-command timeout: the override (or global), clamped to the ceiling. */
|
|
83
|
+
private timeoutFor;
|
|
84
|
+
private sendToExecutor;
|
|
85
|
+
private handleResult;
|
|
86
|
+
private handleAgentCommand;
|
|
87
|
+
private routeEvent;
|
|
88
|
+
private listTargets;
|
|
89
|
+
private aggregateTabs;
|
|
90
|
+
private releaseForAgent;
|
|
91
|
+
private safeSend;
|
|
92
|
+
private clearPending;
|
|
93
|
+
private settleReject;
|
|
94
|
+
/**
|
|
95
|
+
* Give up on a command the executor may still be running (abort, timeout, or
|
|
96
|
+
* the requesting agent vanishing): tell the still-connected executor to tear
|
|
97
|
+
* down via a `cancel` frame, then reject the pending promise. For an executor
|
|
98
|
+
* that's already gone the cancel is skipped — there's nothing to tear down.
|
|
99
|
+
*/
|
|
100
|
+
private abandon;
|
|
101
|
+
private rejectAllPending;
|
|
104
102
|
}
|