@vymalo/opencode-browser 0.11.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.
- 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/opencode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"AAAA,SAAS,mBAAmB;AAI5B,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,sBAAsB;AAC/B,SACE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wB;KAClC,sBAAsB;KACtB;KACA,MAAM;IACR,CAAC;GACH;EACF;;EAGA,MAAM,WAAW,MAAM,eACrB;GACE,MAAM,QAAQ;GACd,MAAM,QAAQ;GACd;GACA,UAAU,mBAAmB,QAAQ,WAAW;GAChD,WAAW,QAAQ;GACnB,OAAO;GACP,QAAQ;;;;;GAKR,aAAa,WAAW,aAAa,kBAAkB,eAAe,CAAC,EAAE;EAC3E,GACA;GACE;GACA,uBAAuB,eAAe,yBAAyB;GAC/D,mBAAmB,eAAe,qBAAqB;EACzD,CACF;;;EAIA,QAAQ,KAAK,cAAc;GACzB,IAAI;IACF,SAAS,SAAS;GACpB,QAAQ,CAER;EACF,CAAC;EAED,MAAM,QAAQ,mBAAmB;GAC/B,MAAM,SAAS;GACf;GACA;GACA,gBAAgB,eAAe;EACjC,CAAC;EAED,OAAO;GACL,MAAM;GACN,QAAQ,OAAO,WAA2B;IACxC,kBAAkB,qBAAqB,OAAO,QAAQ,KAAK;GAC7D;EACF;CACF;AACF;AAEA,OAAO,MAAM,wBAAgC,oBAAoB;AAEjE,eAAe","names":[],"sources":["../src/opencode.ts"],"version":3,"file":"opencode.js","sourceRoot":""}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
* Wire protocol shared by the OpenCode plugin (the bridge **server**) and the
|
|
3
|
+
* browser extension (the **client**). This module is intentionally
|
|
4
|
+
* dependency-free and runtime-agnostic so the extension can mirror it verbatim
|
|
5
|
+
* into a browser bundle without pulling in any Bun/Node code.
|
|
6
|
+
*
|
|
7
|
+
* Canonical copy lives here (`packages/opencode-browser/src/protocol.ts`); the
|
|
8
|
+
* extension keeps a byte-for-byte copy at
|
|
9
|
+
* `apps/browser-extension/src/shared/protocol.ts`. Keep them in sync.
|
|
10
|
+
*
|
|
11
|
+
* Topology: extensions cannot host servers, so the plugin opens the WebSocket
|
|
12
|
+
* server on 127.0.0.1 and the extension's background worker dials out to it.
|
|
13
|
+
* The extension authenticates with a `hello`; the server replies `ready`. From
|
|
14
|
+
* then on the server issues `command` frames and the extension answers with a
|
|
15
|
+
* matching `result` frame (correlated by `id`). The extension may also push
|
|
16
|
+
* unsolicited `event` frames. Heartbeats use `ping`/`pong`.
|
|
17
|
+
*/
|
|
18
18
|
/** Bump when the frame shapes change incompatibly. */
|
|
19
19
|
export declare const PROTOCOL_VERSION = 1;
|
|
20
20
|
/** Every browser action the plugin can ask the extension to perform. */
|
|
@@ -24,157 +24,157 @@ export declare const BROWSER_ACTIONS: readonly BrowserAction[];
|
|
|
24
24
|
export type ClientRole = "agent" | "extension";
|
|
25
25
|
/** Client → broker: first frame after the socket opens. */
|
|
26
26
|
export interface HelloFrame {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
v: number;
|
|
28
|
+
type: "hello";
|
|
29
|
+
/** Shared secret; must equal the bridge token. */
|
|
30
|
+
token: string;
|
|
31
|
+
/** "extension" (executor) or "agent" (producer). Default extension. */
|
|
32
|
+
role?: ClientRole;
|
|
33
|
+
/** Free-form client descriptor for logging (browser name/version, agent name). */
|
|
34
|
+
client?: string;
|
|
35
|
+
/** Extensions: stable per-install id (persisted), usable as a routing target. */
|
|
36
|
+
id?: string;
|
|
37
|
+
/** Extensions: user-editable label from the dashboard (defaults to id). */
|
|
38
|
+
label?: string;
|
|
39
|
+
/** Extensions: "chrome" | "firefox" | UA hint. */
|
|
40
|
+
browser?: string;
|
|
41
41
|
}
|
|
42
42
|
/** Broker → client: handshake accepted. */
|
|
43
43
|
export interface ReadyFrame {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
v: number;
|
|
45
|
+
type: "ready";
|
|
46
|
+
server: "opencode-browser";
|
|
47
|
+
protocol: number;
|
|
48
|
+
/** Role the broker accepted this connection as. */
|
|
49
|
+
role?: ClientRole;
|
|
50
|
+
/** Id the broker assigned/echoed for this client. */
|
|
51
|
+
clientId?: string;
|
|
52
|
+
/** Operator's executor preference, if configured plugin-side (extensions only). */
|
|
53
|
+
executor?: "auto" | "cdp" | "content";
|
|
54
54
|
}
|
|
55
55
|
/** Server → extension: perform an action, expect a matching `result`. */
|
|
56
56
|
export interface CommandFrame {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
v: number;
|
|
58
|
+
type: "command";
|
|
59
|
+
/** Correlation id; the `result` echoes it. */
|
|
60
|
+
id: string;
|
|
61
|
+
action: BrowserAction;
|
|
62
|
+
/** Named tab group the action targets. */
|
|
63
|
+
group: string;
|
|
64
|
+
/** Action-specific arguments (already validated plugin-side). */
|
|
65
|
+
params: Record<string, unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Optional executor selector (browser label or id) used by the broker when a
|
|
68
|
+
* command creates a new group; ignored by executors.
|
|
69
|
+
*/
|
|
70
|
+
target?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Optional per-command timeout in ms. Broker-only: a guest agent puts it here
|
|
73
|
+
* so the host broker honors a longer (or shorter) deadline than its global
|
|
74
|
+
* `timeoutMs` for this one command (clamped to the broker's `maxCommandMs`).
|
|
75
|
+
* Executors ignore it — they rely on a `cancel` frame for early teardown.
|
|
76
|
+
*/
|
|
77
|
+
timeoutMs?: number;
|
|
78
78
|
}
|
|
79
79
|
/** Extension → server: response to a `command`. */
|
|
80
80
|
export interface ResultFrame {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
v: number;
|
|
82
|
+
type: "result";
|
|
83
|
+
id: string;
|
|
84
|
+
ok: boolean;
|
|
85
|
+
/** Present when `ok` is true. */
|
|
86
|
+
data?: unknown;
|
|
87
|
+
/** Present when `ok` is false. */
|
|
88
|
+
error?: {
|
|
89
|
+
message: string;
|
|
90
|
+
code?: string;
|
|
91
|
+
};
|
|
92
92
|
}
|
|
93
93
|
/** Names of unsolicited events the extension can push. */
|
|
94
94
|
export type BrowserEventName = "tab_closed" | "navigated" | "group_removed" | "tab_created";
|
|
95
95
|
/** Extension → server: unsolicited notification (not correlated to a command). */
|
|
96
96
|
export interface EventFrame {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
v: number;
|
|
98
|
+
type: "event";
|
|
99
|
+
name: BrowserEventName;
|
|
100
|
+
group?: string;
|
|
101
|
+
data?: Record<string, unknown>;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
* Server → extension: stop driving and release control (detach the CDP
|
|
105
|
+
* debugger) without closing tabs. The next command re-attaches. Lets the plugin
|
|
106
|
+
* hand the browser back without waiting for the socket to drop.
|
|
107
|
+
*/
|
|
108
108
|
export interface ReleaseFrame {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
v: number;
|
|
110
|
+
type: "release";
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
* Server → extension: abandon an in-flight command. The `id` matches a prior
|
|
114
|
+
* `command`; the executor should tear down any UI/work for it (e.g. an open
|
|
115
|
+
* feedback overlay) and need not send a `result`. Sent when the broker gives up
|
|
116
|
+
* on a command early — agent abort, per-command timeout, or the requesting
|
|
117
|
+
* agent disconnecting — so a blocking command never orphans state in the page.
|
|
118
|
+
* A `cancel` for an unknown/completed id is a harmless no-op.
|
|
119
|
+
*/
|
|
120
120
|
export interface CancelFrame {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
v: number;
|
|
122
|
+
type: "cancel";
|
|
123
|
+
/** The id of the command being abandoned. */
|
|
124
|
+
id: string;
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
* Server → client: the handshake was refused; the socket is about to close.
|
|
128
|
+
* Sent just before `conn.close()` so the dialer can tell a *rejection* (bad
|
|
129
|
+
* token, wrong protocol) apart from a plain network drop — and surface an
|
|
130
|
+
* actionable error ("re-paste the token") instead of retrying forever. `reason`
|
|
131
|
+
* is a stable machine code (e.g. `"bad_token"`), not a human sentence.
|
|
132
|
+
*/
|
|
133
133
|
export interface RejectedFrame {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
v: number;
|
|
135
|
+
type: "rejected";
|
|
136
|
+
reason: string;
|
|
137
137
|
}
|
|
138
138
|
export interface PingFrame {
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
v: number;
|
|
140
|
+
type: "ping";
|
|
141
141
|
}
|
|
142
142
|
export interface PongFrame {
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
v: number;
|
|
144
|
+
type: "pong";
|
|
145
145
|
}
|
|
146
146
|
export type Frame = HelloFrame | ReadyFrame | CommandFrame | ResultFrame | EventFrame | ReleaseFrame | CancelFrame | RejectedFrame | PingFrame | PongFrame;
|
|
147
147
|
/** Serialize a frame for the wire. */
|
|
148
148
|
export declare function encodeFrame(frame: Frame): string;
|
|
149
149
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
* Parse and shape-check an inbound frame. Returns the typed frame, or `null` if
|
|
151
|
+
* the payload is not a recognizable frame (caller decides whether to drop or
|
|
152
|
+
* log). Validation is deliberately lightweight — both ends are trusted once the
|
|
153
|
+
* token handshake succeeds; this guards against malformed JSON and version skew,
|
|
154
|
+
* not a hostile peer.
|
|
155
|
+
*/
|
|
156
156
|
export declare function decodeFrame(raw: string): Frame | null;
|
|
157
157
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
* Monotonic correlation id for command frames. Process-local and collision-free
|
|
159
|
+
* within a single bridge instance, which is all that's required (the server is
|
|
160
|
+
* the only id minter).
|
|
161
|
+
*/
|
|
162
162
|
export declare function nextId(): string;
|
|
163
163
|
export declare function helloFrame(token: string, opts?: {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
role?: ClientRole;
|
|
165
|
+
client?: string;
|
|
166
|
+
id?: string;
|
|
167
|
+
label?: string;
|
|
168
|
+
browser?: string;
|
|
169
169
|
}): HelloFrame;
|
|
170
170
|
export declare function resultFrame(id: string, data: unknown): ResultFrame;
|
|
171
171
|
export declare function errorFrame(id: string, message: string, code?: string): ResultFrame;
|
|
172
172
|
export declare function rejectedFrame(reason: string): RejectedFrame;
|
|
173
173
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
* A short, **non-secret** fingerprint of a bridge token, safe to log. It never
|
|
175
|
+
* reveals the token: just its length plus a base36 digest, so two sides can log
|
|
176
|
+
* `tokenFingerprint(...)` and a human can see at a glance whether the executor's
|
|
177
|
+
* token matches the broker's — the whole point when debugging `bad_token`.
|
|
178
|
+
*/
|
|
179
179
|
export declare function tokenFingerprint(token: string): string;
|
|
180
180
|
export declare function cancelFrame(id: string): CancelFrame;
|