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