@myrialabs/clopen 0.4.21 → 0.4.22
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/README.md +2 -1
- package/backend/artifacts/generate.ts +11 -5
- package/backend/auth/permissions.ts +8 -8
- package/backend/engine/README.md +11 -8
- package/backend/engine/adapters/codex/error-handler.ts +1 -1
- package/backend/engine/adapters/qwen/error-handler.ts +1 -1
- package/backend/engine/docs/adapter-contract.md +66 -2
- package/backend/engine/docs/adding-an-engine.md +46 -7
- package/backend/engine/docs/frontend-and-chat.md +80 -17
- package/backend/engine/docs/lessons-learned.md +126 -7
- package/backend/engine/docs/quick-reference.md +12 -3
- package/backend/engine/docs/{system-tools.md → stack.md} +35 -6
- package/backend/engine/docs/websocket-routes.md +54 -15
- package/backend/engine/install-runner.ts +4 -4
- package/backend/engine/resolve-model.ts +87 -0
- package/backend/engine/structured-helpers.test.ts +64 -0
- package/backend/engine/structured-helpers.ts +105 -13
- package/backend/mcp/README.md +32 -11
- package/backend/mcp/internal/config.ts +3 -20
- package/backend/mcp/internal/servers/browser-automation/actions/console.ts +65 -0
- package/backend/mcp/internal/servers/browser-automation/actions/dom-analyze.ts +202 -0
- package/backend/mcp/internal/servers/browser-automation/actions/index.ts +31 -0
- package/backend/mcp/internal/servers/browser-automation/actions/input.ts +332 -0
- package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +158 -0
- package/backend/mcp/internal/servers/browser-automation/actions/navigation.ts +157 -0
- package/backend/mcp/internal/servers/browser-automation/actions/shared.ts +60 -0
- package/backend/mcp/internal/servers/browser-automation/actions/tabs.ts +146 -0
- package/backend/mcp/internal/servers/browser-automation/actions/types.ts +63 -0
- package/backend/mcp/internal/servers/browser-automation/context.ts +82 -0
- package/backend/mcp/internal/servers/browser-automation/description.ts +59 -0
- package/backend/mcp/internal/servers/browser-automation/format.ts +56 -0
- package/backend/mcp/internal/servers/browser-automation/index.ts +36 -784
- package/backend/mcp/internal/servers/browser-automation/paths.ts +71 -0
- package/backend/mcp/internal/servers/browser-automation/runner.ts +260 -0
- package/backend/mcp/internal/servers/browser-automation/schema.ts +26 -0
- package/backend/preview/browser/browser-console-manager.ts +310 -156
- package/backend/preview/browser/browser-dialog-handler.ts +45 -16
- package/backend/preview/browser/browser-host-bridge.ts +471 -0
- package/backend/preview/browser/browser-interaction-handler.ts +868 -297
- package/backend/preview/browser/browser-mcp-control.ts +7 -2
- package/backend/preview/browser/browser-native-ui-handler.ts +455 -81
- package/backend/preview/browser/browser-navigation-tracker.ts +56 -0
- package/backend/preview/browser/browser-pool.ts +83 -9
- package/backend/preview/browser/browser-preview-service.ts +432 -53
- package/backend/preview/browser/browser-tab-manager.ts +16 -16
- package/backend/preview/browser/browser-video-capture.ts +1334 -386
- package/backend/preview/browser/capture-profile.ts +213 -0
- package/backend/preview/browser/element-locator.ts +357 -0
- package/backend/preview/browser/frame-targeting.ts +92 -0
- package/backend/preview/browser/scripts/audio-stream.ts +258 -78
- package/backend/preview/browser/scripts/host-bridge.ts +1277 -0
- package/backend/preview/browser/scripts/video-stream.ts +803 -177
- package/backend/preview/browser/types.ts +397 -37
- package/backend/utils/cli.ts +1 -1
- package/backend/utils/path-enrich.ts +2 -2
- package/backend/ws/README.md +1 -1
- package/backend/ws/artifacts/generate.ts +2 -1
- package/backend/ws/engine/codex/accounts.ts +1 -1
- package/backend/ws/engine/codex/status.ts +1 -1
- package/backend/ws/git/branch-name.ts +11 -5
- package/backend/ws/git/commit-message.ts +11 -5
- package/backend/ws/index.ts +3 -3
- package/backend/ws/preview/browser/host.ts +95 -0
- package/backend/ws/preview/browser/interact.ts +204 -10
- package/backend/ws/preview/browser/native-ui.ts +31 -1
- package/backend/ws/preview/browser/tab-info.ts +10 -1
- package/backend/ws/preview/browser/tab.ts +43 -0
- package/backend/ws/preview/browser/webcodecs.ts +180 -53
- package/backend/ws/preview/index.ts +58 -1
- package/backend/ws/{system-tools → stack}/access.ts +1 -1
- package/backend/ws/stack/index.ts +16 -0
- package/backend/ws/{system-tools → stack}/install.ts +7 -7
- package/backend/ws/{system-tools → stack}/status.ts +7 -7
- package/dist/assets/{index-CEGW8vEt.js → index-DH_GO0Lf.js} +1 -1
- package/dist/assets/{index-B8YRz8wG.js → index-igSQ3JaM.js} +1 -1
- package/dist/assets/main-BD3-qPfT.css +1 -0
- package/dist/assets/{main-D-2ByODy.js → main-D-d8SFfW.js} +384 -358
- package/dist/assets/preview-video.worker-DcpDhCWL.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/types/stores/settings.ts +6 -0
- package/backend/mcp/internal/servers/browser-automation/actions.ts +0 -159
- package/backend/mcp/internal/servers/browser-automation/browser.ts +0 -375
- package/backend/mcp/internal/servers/browser-automation/inspection.ts +0 -495
- package/backend/ws/system-tools/index.ts +0 -16
- package/dist/assets/main-D8I0MfRQ.css +0 -1
|
@@ -4,17 +4,57 @@ import type { DeviceSize, Rotation } from '$shared/constants/preview.js';
|
|
|
4
4
|
// Re-export types from preview config
|
|
5
5
|
export type { DeviceSize, Rotation };
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A console argument rendered for display.
|
|
9
|
+
*
|
|
10
|
+
* `jsonValue()` cannot represent most of what a page logs — DOM nodes, class
|
|
11
|
+
* instances, functions and anything circular all throw — so values are
|
|
12
|
+
* flattened in the page to a shape the console panel can render and expand
|
|
13
|
+
* without holding a live handle to the object.
|
|
14
|
+
*/
|
|
15
|
+
export interface BrowserConsoleValue {
|
|
16
|
+
type:
|
|
17
|
+
| 'string'
|
|
18
|
+
| 'number'
|
|
19
|
+
| 'boolean'
|
|
20
|
+
| 'null'
|
|
21
|
+
| 'undefined'
|
|
22
|
+
| 'bigint'
|
|
23
|
+
| 'symbol'
|
|
24
|
+
| 'function'
|
|
25
|
+
| 'array'
|
|
26
|
+
| 'object'
|
|
27
|
+
| 'error'
|
|
28
|
+
| 'node'
|
|
29
|
+
| 'date'
|
|
30
|
+
| 'regexp'
|
|
31
|
+
| 'map'
|
|
32
|
+
| 'set';
|
|
33
|
+
/** Single-line rendering, e.g. `Array(3)` or `<div class="row">`. */
|
|
34
|
+
preview: string;
|
|
35
|
+
/** Expandable children, present for arrays/objects/maps/sets. */
|
|
36
|
+
entries?: Array<{ key: string; value: BrowserConsoleValue }>;
|
|
37
|
+
/** True when `entries` was cut short by the size cap. */
|
|
38
|
+
truncated?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
7
41
|
export interface BrowserConsoleMessage {
|
|
8
42
|
id: string;
|
|
9
|
-
type: 'log' | 'info' | 'warn' | 'error' | 'debug' | 'trace' | 'clear';
|
|
43
|
+
type: 'log' | 'info' | 'warn' | 'error' | 'debug' | 'trace' | 'clear' | 'input' | 'result';
|
|
10
44
|
text: string;
|
|
11
45
|
args?: unknown[];
|
|
46
|
+
/** Structured rendering of `args`, used by the console panel. */
|
|
47
|
+
values?: BrowserConsoleValue[];
|
|
12
48
|
location?: {
|
|
13
49
|
url: string;
|
|
14
50
|
lineNumber: number;
|
|
15
51
|
columnNumber: number;
|
|
16
52
|
};
|
|
17
53
|
stackTrace?: string;
|
|
54
|
+
/** Network status for messages raised from a failed response. */
|
|
55
|
+
status?: number;
|
|
56
|
+
/** Repeat counter for identical consecutive messages, as in DevTools. */
|
|
57
|
+
count?: number;
|
|
18
58
|
timestamp: number;
|
|
19
59
|
}
|
|
20
60
|
|
|
@@ -56,6 +96,12 @@ export interface BrowserTab {
|
|
|
56
96
|
isLoading: boolean;
|
|
57
97
|
canGoBack: boolean;
|
|
58
98
|
canGoForward: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* CDP history index the tab started at, captured after its first real
|
|
101
|
+
* navigation. Back is only offered beyond this point so a fresh tab behaves
|
|
102
|
+
* like a real browser — you cannot walk back into its initial about:blank.
|
|
103
|
+
*/
|
|
104
|
+
historyBaseIndex?: number;
|
|
59
105
|
lastNavigationTime?: number;
|
|
60
106
|
currentUrl?: string;
|
|
61
107
|
|
|
@@ -65,7 +111,7 @@ export interface BrowserTab {
|
|
|
65
111
|
lastUniqueFrameTime?: number;
|
|
66
112
|
stableFrameStartTime?: number;
|
|
67
113
|
lastCursorInfo?: { x: number; y: number; cursor: string };
|
|
68
|
-
scale?: number; // Frontend display fit-scale
|
|
114
|
+
scale?: number; // Frontend display fit-scale — with the viewer's devicePixelRatio, this sets capture resolution
|
|
69
115
|
|
|
70
116
|
// Interaction tracking
|
|
71
117
|
lastInteractionTime?: number;
|
|
@@ -109,57 +155,191 @@ export interface TabNavigatedEvent {
|
|
|
109
155
|
timestamp: number;
|
|
110
156
|
}
|
|
111
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Live tab metadata pushed after every navigation.
|
|
160
|
+
*
|
|
161
|
+
* Bundles the three things the toolbar needs and cannot derive from the URL:
|
|
162
|
+
* the page's own title, its favicon, and whether Back/Forward are available.
|
|
163
|
+
*/
|
|
164
|
+
export interface BrowserTabMeta {
|
|
165
|
+
tabId: string;
|
|
166
|
+
url: string;
|
|
167
|
+
title: string;
|
|
168
|
+
favicon?: string;
|
|
169
|
+
canGoBack: boolean;
|
|
170
|
+
canGoForward: boolean;
|
|
171
|
+
timestamp: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** A single entry in a tab's CDP navigation history. */
|
|
175
|
+
export interface BrowserHistoryEntry {
|
|
176
|
+
id: number;
|
|
177
|
+
url: string;
|
|
178
|
+
title: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface BrowserHistoryState {
|
|
182
|
+
entries: BrowserHistoryEntry[];
|
|
183
|
+
currentIndex: number;
|
|
184
|
+
canGoBack: boolean;
|
|
185
|
+
canGoForward: boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
112
188
|
export interface BrowserTabInfo {
|
|
113
189
|
id: string;
|
|
114
190
|
url: string;
|
|
115
191
|
title: string;
|
|
192
|
+
/**
|
|
193
|
+
* Carried through recovery so a page refresh restores the tab strip as it
|
|
194
|
+
* looked, instead of falling back to the placeholder until the next reload.
|
|
195
|
+
*/
|
|
196
|
+
favicon?: string;
|
|
116
197
|
quality: 'perfect' | 'good';
|
|
117
198
|
isStreaming: boolean;
|
|
118
199
|
deviceSize: DeviceSize;
|
|
119
200
|
rotation: Rotation;
|
|
120
201
|
isActive: boolean;
|
|
202
|
+
canGoBack: boolean;
|
|
203
|
+
canGoForward: boolean;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** A point in page (emulated viewport) coordinates. */
|
|
207
|
+
export interface BrowserPoint {
|
|
208
|
+
x: number;
|
|
209
|
+
y: number;
|
|
121
210
|
}
|
|
122
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Where an action should land. Either explicit page coordinates or an element
|
|
214
|
+
* to resolve — resolution scrolls the element into view and aims at its centre,
|
|
215
|
+
* so the agent never has to guess a pixel it cannot see.
|
|
216
|
+
*/
|
|
217
|
+
export interface BrowserActionTarget {
|
|
218
|
+
x?: number;
|
|
219
|
+
y?: number;
|
|
220
|
+
/** CSS selector, resolved across every frame including iframes. */
|
|
221
|
+
selector?: string;
|
|
222
|
+
/** Visible text to match when no selector is given. */
|
|
223
|
+
text?: string;
|
|
224
|
+
/** Nth match when the query is ambiguous (0-based, default 0). */
|
|
225
|
+
nth?: number;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type BrowserAutonomousActionType =
|
|
229
|
+
| 'click'
|
|
230
|
+
| 'type'
|
|
231
|
+
| 'move'
|
|
232
|
+
| 'scroll'
|
|
233
|
+
| 'wait'
|
|
234
|
+
| 'extract_data'
|
|
235
|
+
| 'drag'
|
|
236
|
+
| 'press'
|
|
237
|
+
| 'long_press'
|
|
238
|
+
| 'tap'
|
|
239
|
+
| 'swipe'
|
|
240
|
+
| 'pinch'
|
|
241
|
+
| 'select_option'
|
|
242
|
+
| 'upload'
|
|
243
|
+
| 'paste'
|
|
244
|
+
| 'focus'
|
|
245
|
+
| 'clear';
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* One primitive input gesture, executed against a tab's page.
|
|
249
|
+
*
|
|
250
|
+
* Everything here drives native browser input (CDP mouse / keyboard / touch).
|
|
251
|
+
* The only DOM-level actions are the ones that cannot be expressed as input at
|
|
252
|
+
* all: `extract_data`, `select_option`, `upload` and element resolution.
|
|
253
|
+
*/
|
|
123
254
|
export interface BrowserAutonomousAction {
|
|
124
|
-
|
|
125
|
-
* Action types (minimal, native-only, no DOM):
|
|
126
|
-
* - 'click': Mouse click at coordinates (x, y)
|
|
127
|
-
* - 'type': Keyboard input - type text OR press single key
|
|
128
|
-
* - 'move': Move mouse to coordinates (x, y)
|
|
129
|
-
* - 'scroll': Scroll by delta amount, optionally at target area (x, y)
|
|
130
|
-
* - 'wait': Wait for specified delay
|
|
131
|
-
* - 'extract_data': Extract data from DOM element using CSS selector
|
|
132
|
-
*
|
|
133
|
-
* All interactions use native browser input (no DOM manipulation except extract_data)
|
|
134
|
-
*/
|
|
135
|
-
type: 'click' | 'type' | 'move' | 'scroll' | 'wait' | 'extract_data';
|
|
255
|
+
type: BrowserAutonomousActionType;
|
|
136
256
|
|
|
137
|
-
// Coordinates for click/move, or target area for scroll
|
|
257
|
+
// Coordinates for click/move/tap, or target area for scroll
|
|
138
258
|
x?: number;
|
|
139
259
|
y?: number;
|
|
140
260
|
|
|
261
|
+
/** Element-or-coordinate target. Takes precedence over bare x/y. */
|
|
262
|
+
target?: BrowserActionTarget;
|
|
263
|
+
|
|
141
264
|
// For scroll action - scroll delta amounts
|
|
142
265
|
deltaX?: number;
|
|
143
266
|
deltaY?: number;
|
|
144
267
|
|
|
145
|
-
|
|
146
|
-
|
|
268
|
+
/** Mouse button (default: 'left'). */
|
|
269
|
+
button?: 'left' | 'right' | 'middle';
|
|
270
|
+
/** 1 = single, 2 = double, 3 = triple. */
|
|
271
|
+
clickCount?: number;
|
|
147
272
|
|
|
148
273
|
// For type action - either text OR key, not both
|
|
149
274
|
text?: string; // Type a string of text
|
|
150
275
|
key?: string; // Press a single key (Enter, Tab, Escape, ArrowUp, etc.)
|
|
276
|
+
/** Chord for `press`, e.g. "Control+Shift+K". */
|
|
277
|
+
keys?: string;
|
|
151
278
|
clearFirst?: boolean; // Clear existing input before typing (default: true for MCP, false for user)
|
|
152
279
|
|
|
153
280
|
// For extract_data action
|
|
154
281
|
selector?: string; // Element identifier - tool automatically tries all selector patterns and attributes
|
|
282
|
+
/** Read a specific attribute instead of auto-detecting one. */
|
|
283
|
+
attribute?: string;
|
|
284
|
+
/** Return every match rather than the first. */
|
|
285
|
+
all?: boolean;
|
|
286
|
+
|
|
287
|
+
// Drag / swipe endpoints
|
|
288
|
+
from?: BrowserActionTarget;
|
|
289
|
+
to?: BrowserActionTarget;
|
|
290
|
+
/**
|
|
291
|
+
* 'pointer' drives mousedown → move → mouseup, which is what JS drag
|
|
292
|
+
* implementations (sliders, canvases, sortable lists) listen for.
|
|
293
|
+
* 'native' goes through CDP drag interception, needed for HTML5
|
|
294
|
+
* `draggable="true"` sources, which ignore plain mouse events.
|
|
295
|
+
* Omit to pick automatically from the source element.
|
|
296
|
+
*/
|
|
297
|
+
mode?: 'pointer' | 'native';
|
|
298
|
+
|
|
299
|
+
// For select_option
|
|
300
|
+
value?: string;
|
|
301
|
+
label?: string;
|
|
302
|
+
index?: number;
|
|
303
|
+
|
|
304
|
+
// For upload — absolute paths, resolved and access-checked by the caller
|
|
305
|
+
files?: string[];
|
|
306
|
+
|
|
307
|
+
// For pinch
|
|
308
|
+
center?: BrowserPoint;
|
|
309
|
+
scale?: number;
|
|
155
310
|
|
|
156
311
|
// Timing options
|
|
157
312
|
delay?: number;
|
|
158
313
|
steps?: number; // For mouse movement interpolation
|
|
314
|
+
/** How long to hold (long_press, drag pause before moving). */
|
|
315
|
+
holdMs?: number;
|
|
316
|
+
/** How long to linger after moving (hover dwell, tooltip reveal). */
|
|
317
|
+
dwellMs?: number;
|
|
318
|
+
/** Gesture duration for swipe/pinch. */
|
|
319
|
+
durationMs?: number;
|
|
159
320
|
|
|
160
321
|
// Behavior options
|
|
161
322
|
humanLike?: boolean; // Simulate human-like movement/typing
|
|
162
323
|
smooth?: boolean; // For smooth scrolling
|
|
324
|
+
/** Skip scrolling a resolved element into view before acting on it. */
|
|
325
|
+
noScroll?: boolean;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Per-action outcome, returned in order so a batch can be reported honestly —
|
|
330
|
+
* including which actions never ran.
|
|
331
|
+
*/
|
|
332
|
+
export interface BrowserActionResult {
|
|
333
|
+
action: BrowserAutonomousActionType;
|
|
334
|
+
ok: boolean;
|
|
335
|
+
/** Human-readable one-liner, e.g. `click (640, 300)`. */
|
|
336
|
+
detail?: string;
|
|
337
|
+
error?: string;
|
|
338
|
+
/** Payload for actions that read something back. */
|
|
339
|
+
data?: unknown;
|
|
340
|
+
selector?: string;
|
|
341
|
+
attribute?: string;
|
|
342
|
+
timestamp: number;
|
|
163
343
|
}
|
|
164
344
|
|
|
165
345
|
export interface BrowserNavigationEvent {
|
|
@@ -197,6 +377,83 @@ export interface BrowserScreenshotFrame {
|
|
|
197
377
|
duplicatesSkipped: number;
|
|
198
378
|
}
|
|
199
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Wire codec identifiers.
|
|
382
|
+
*
|
|
383
|
+
* Every video packet carries one of these so the viewer can configure the
|
|
384
|
+
* matching decoder without a side-channel. Values are part of the wire format —
|
|
385
|
+
* append only, never renumber.
|
|
386
|
+
*/
|
|
387
|
+
export const VIDEO_CODEC_ID = {
|
|
388
|
+
vp8: 0,
|
|
389
|
+
vp9: 1,
|
|
390
|
+
avc: 2
|
|
391
|
+
} as const;
|
|
392
|
+
|
|
393
|
+
export type VideoCodecName = keyof typeof VIDEO_CODEC_ID;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* A candidate the in-page encoder may use, in preference order.
|
|
397
|
+
*
|
|
398
|
+
* `quantizerKey` selects per-frame quality control (Chrome-Remote-Desktop
|
|
399
|
+
* style): cheap frames during motion, near-lossless when the page goes still.
|
|
400
|
+
* Candidates without it fall back to fixed-bitrate mode, where the still-page
|
|
401
|
+
* refresh is a forced keyframe at a temporarily raised bitrate instead.
|
|
402
|
+
*/
|
|
403
|
+
export interface VideoCodecCandidate {
|
|
404
|
+
/** WebCodecs codec string, identical on encoder and decoder. */
|
|
405
|
+
codec: string;
|
|
406
|
+
name: VideoCodecName;
|
|
407
|
+
id: number;
|
|
408
|
+
quantizerKey?: 'vp9';
|
|
409
|
+
/**
|
|
410
|
+
* H.264 must be emitted as Annex-B: we ship raw chunk bytes with no
|
|
411
|
+
* `description`, so an AVCC-formatted stream would be undecodable.
|
|
412
|
+
*/
|
|
413
|
+
annexb?: boolean;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Client decode capabilities, negotiated at stream start.
|
|
418
|
+
*
|
|
419
|
+
* The headless browser can encode far more than a given viewer can decode —
|
|
420
|
+
* an iPhone or a low-end Android has hardware H.264 but only software VP9,
|
|
421
|
+
* which is exactly the case where software decoding wrecks the frame rate.
|
|
422
|
+
*/
|
|
423
|
+
export interface ClientCodecSupport {
|
|
424
|
+
vp8: boolean;
|
|
425
|
+
vp9: boolean;
|
|
426
|
+
avc: boolean;
|
|
427
|
+
/** Codecs the viewer reports a hardware decoder for. */
|
|
428
|
+
hardware: VideoCodecName[];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Viewer display metrics — drives capture resolution (see computeCaptureSize).
|
|
433
|
+
*/
|
|
434
|
+
export interface ClientDisplayMetrics {
|
|
435
|
+
/** CSS fit-scale applied to the preview (0-1). */
|
|
436
|
+
scale?: number;
|
|
437
|
+
/** Viewer screen density. */
|
|
438
|
+
dpr?: number;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Runtime feedback from the viewer's decoder.
|
|
443
|
+
*
|
|
444
|
+
* Backpressure used to be network-only (`bufferedAmount`). A viewer that
|
|
445
|
+
* cannot decode fast enough shows the same symptom — growing latency and
|
|
446
|
+
* stutter — with an empty network buffer, so the decode queue has to travel
|
|
447
|
+
* back to the source as well.
|
|
448
|
+
*/
|
|
449
|
+
export interface ClientStreamFeedback {
|
|
450
|
+
decodeQueueSize: number;
|
|
451
|
+
/** Mean decode-to-render latency over the reporting window (ms). */
|
|
452
|
+
decodeLatencyMs: number;
|
|
453
|
+
/** Frames dropped before render, as a fraction of frames received. */
|
|
454
|
+
dropRatio: number;
|
|
455
|
+
}
|
|
456
|
+
|
|
200
457
|
/**
|
|
201
458
|
* Unified Streaming Configuration
|
|
202
459
|
*
|
|
@@ -207,17 +464,26 @@ export interface BrowserScreenshotFrame {
|
|
|
207
464
|
*/
|
|
208
465
|
export interface StreamingConfig {
|
|
209
466
|
video: {
|
|
210
|
-
codec: string; // Fallback codec (VP8, fixed-bitrate mode) when
|
|
467
|
+
codec: string; // Fallback codec (VP8, fixed-bitrate mode) when nothing better is negotiated
|
|
211
468
|
width: number;
|
|
212
469
|
height: number;
|
|
213
|
-
framerate: number; //
|
|
470
|
+
framerate: number; // Target encode fps — the screencast is throttled to this at the source
|
|
471
|
+
minFramerate: number; // Floor of the adaptive framerate ladder
|
|
214
472
|
bitrate: number;
|
|
215
473
|
keyframeInterval: number; // Seconds between periodic keyframes; 0 = on-demand only (start/reconnect/client request)
|
|
216
474
|
screenshotQuality: number;
|
|
217
475
|
hardwareAcceleration: 'no-preference' | 'prefer-hardware' | 'prefer-software';
|
|
218
476
|
latencyMode: 'quality' | 'realtime';
|
|
219
|
-
motionQuantizer: number; //
|
|
220
|
-
topOffQuantizer: number; //
|
|
477
|
+
motionQuantizer: number; // Per-frame quantizer (0-63) while the page is moving — cheap, allowed to be soft
|
|
478
|
+
topOffQuantizer: number; // Quantizer for still-page refresh frames — near-lossless so text stays crisp
|
|
479
|
+
/** Ordered encoder candidates resolved from the viewer's capabilities. */
|
|
480
|
+
codecCandidates: VideoCodecCandidate[];
|
|
481
|
+
/**
|
|
482
|
+
* Attempt in-page capture (getDisplayMedia + MediaStreamTrackProcessor)
|
|
483
|
+
* before falling back to the CDP screencast push path. Removes a JPEG
|
|
484
|
+
* encode/decode round-trip and the base64 CDP hop per frame.
|
|
485
|
+
*/
|
|
486
|
+
nativeCapture: boolean;
|
|
221
487
|
};
|
|
222
488
|
audio: {
|
|
223
489
|
codec: string
|
|
@@ -237,13 +503,17 @@ export interface StreamingConfig {
|
|
|
237
503
|
* goes still a near-lossless refresh frame is sent (topOffQuantizer) so
|
|
238
504
|
* text stays crisp. Idle pages cost ~0 bandwidth (CDP screencast only
|
|
239
505
|
* fires on damage).
|
|
506
|
+
* - H.264 when the viewer has a hardware decoder for it but not for VP9
|
|
507
|
+
* (phones, tablets, low-end laptops) — fixed-bitrate mode with a bitrate
|
|
508
|
+
* bump on the still-page refresh.
|
|
240
509
|
* - Fallback: VP8 at a resolution-scaled bitrate (see computeBitrate).
|
|
241
510
|
* - Keyframes on demand only (keyframeInterval 0) — the DataChannel is
|
|
242
511
|
* reliable, and the client requests a keyframe on decoder errors.
|
|
243
|
-
* - Encode rate capped at `framerate
|
|
244
|
-
*
|
|
245
|
-
* -
|
|
246
|
-
*
|
|
512
|
+
* - Encode rate capped at `framerate`, enforced at the source by withholding
|
|
513
|
+
* the screencast ack so Chrome never rasters frames we would discard.
|
|
514
|
+
* - Resolution, framerate and quantizers are overridden per session from the
|
|
515
|
+
* host capture profile and the viewer's display metrics; the values here
|
|
516
|
+
* are only the shape and the fallback for non-streaming call sites.
|
|
247
517
|
* - Opus for audio (efficient and widely supported)
|
|
248
518
|
*/
|
|
249
519
|
export const DEFAULT_STREAMING_CONFIG: StreamingConfig = {
|
|
@@ -252,23 +522,76 @@ export const DEFAULT_STREAMING_CONFIG: StreamingConfig = {
|
|
|
252
522
|
width: 0,
|
|
253
523
|
height: 0,
|
|
254
524
|
framerate: 24,
|
|
525
|
+
minFramerate: 8,
|
|
255
526
|
bitrate: 1_000_000,
|
|
256
527
|
keyframeInterval: 0,
|
|
257
528
|
screenshotQuality: 75,
|
|
258
529
|
hardwareAcceleration: 'no-preference',
|
|
259
530
|
latencyMode: 'realtime',
|
|
260
531
|
motionQuantizer: 40,
|
|
261
|
-
topOffQuantizer: 10
|
|
532
|
+
topOffQuantizer: 10,
|
|
533
|
+
codecCandidates: [],
|
|
534
|
+
nativeCapture: false
|
|
262
535
|
},
|
|
263
536
|
audio: {
|
|
264
537
|
codec: 'opus',
|
|
265
538
|
sampleRate: 48_000,
|
|
266
|
-
bitrate:
|
|
539
|
+
bitrate: 96_000,
|
|
267
540
|
numberOfChannels: 2,
|
|
268
541
|
bufferSize: 4096
|
|
269
542
|
}
|
|
270
543
|
};
|
|
271
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Build the ordered encoder candidate list for a viewer.
|
|
547
|
+
*
|
|
548
|
+
* **VP9 wins whenever the viewer can decode it at all**, including in software.
|
|
549
|
+
* Only VP9 supports per-frame quantizer control, and that is what the whole
|
|
550
|
+
* quality model rests on: coarse frames while the page moves, a near-lossless
|
|
551
|
+
* refresh the moment it stops. A fixed-bitrate codec has no equivalent — it has
|
|
552
|
+
* to be run at a bitrate high enough for motion (wasteful) or low enough for
|
|
553
|
+
* bandwidth (blocky), and its still-page refresh is just a keyframe.
|
|
554
|
+
*
|
|
555
|
+
* H.264 is therefore reserved for viewers that cannot decode VP9 at all —
|
|
556
|
+
* typically Safari and iOS, which is also where hardware H.264 is guaranteed.
|
|
557
|
+
* Preferring it merely because the viewer *also* has hardware H.264 trades a
|
|
558
|
+
* working quality model for a decode saving the viewer usually doesn't need;
|
|
559
|
+
* viewers that genuinely can't keep up are handled by the decode-feedback
|
|
560
|
+
* ladder instead, which lowers framerate and resolution without changing codec.
|
|
561
|
+
*
|
|
562
|
+
* VP8 is the universal floor and is always appended last.
|
|
563
|
+
*/
|
|
564
|
+
export function resolveCodecCandidates(support: ClientCodecSupport): VideoCodecCandidate[] {
|
|
565
|
+
const vp9: VideoCodecCandidate = {
|
|
566
|
+
codec: 'vp09.00.10.08',
|
|
567
|
+
name: 'vp9',
|
|
568
|
+
id: VIDEO_CODEC_ID.vp9,
|
|
569
|
+
quantizerKey: 'vp9'
|
|
570
|
+
};
|
|
571
|
+
// Constrained Baseline @ 5.1 — a level ceiling, not a request, so one
|
|
572
|
+
// string covers every viewport we capture and both ends stay in sync
|
|
573
|
+
// without negotiating dimensions first.
|
|
574
|
+
const avc: VideoCodecCandidate = {
|
|
575
|
+
codec: 'avc1.42E033',
|
|
576
|
+
name: 'avc',
|
|
577
|
+
id: VIDEO_CODEC_ID.avc,
|
|
578
|
+
annexb: true
|
|
579
|
+
};
|
|
580
|
+
const vp8: VideoCodecCandidate = {
|
|
581
|
+
codec: 'vp8',
|
|
582
|
+
name: 'vp8',
|
|
583
|
+
id: VIDEO_CODEC_ID.vp8
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
const candidates: VideoCodecCandidate[] = [];
|
|
587
|
+
|
|
588
|
+
if (support.vp9) candidates.push(vp9);
|
|
589
|
+
if (support.avc) candidates.push(avc);
|
|
590
|
+
if (support.vp8 !== false) candidates.push(vp8);
|
|
591
|
+
|
|
592
|
+
return candidates.length > 0 ? candidates : [vp8];
|
|
593
|
+
}
|
|
594
|
+
|
|
272
595
|
/**
|
|
273
596
|
* Native UI Dialog Types
|
|
274
597
|
* Intercepted from headless browser and re-rendered as native dialogs
|
|
@@ -308,6 +631,33 @@ export interface BrowserSelectOption {
|
|
|
308
631
|
text: string;
|
|
309
632
|
selected: boolean;
|
|
310
633
|
disabled?: boolean;
|
|
634
|
+
/** `<optgroup>` label this option belongs to, if any. */
|
|
635
|
+
group?: string;
|
|
636
|
+
groupDisabled?: boolean;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* An input whose picker Chrome draws outside the page.
|
|
641
|
+
*
|
|
642
|
+
* Colour swatches and the date/time family open browser-process popups that the
|
|
643
|
+
* screencast cannot see, so the viewer renders the equivalent native control
|
|
644
|
+
* over the canvas and writes the result back.
|
|
645
|
+
*/
|
|
646
|
+
export interface BrowserNativePickerInfo {
|
|
647
|
+
tabId: string;
|
|
648
|
+
pickerId: string;
|
|
649
|
+
inputType: 'color' | 'date' | 'datetime-local' | 'month' | 'time' | 'week';
|
|
650
|
+
value: string;
|
|
651
|
+
min?: string;
|
|
652
|
+
max?: string;
|
|
653
|
+
step?: string;
|
|
654
|
+
boundingBox: {
|
|
655
|
+
x: number;
|
|
656
|
+
y: number;
|
|
657
|
+
width: number;
|
|
658
|
+
height: number;
|
|
659
|
+
};
|
|
660
|
+
timestamp: number;
|
|
311
661
|
}
|
|
312
662
|
|
|
313
663
|
export interface BrowserSelectInfo {
|
|
@@ -345,22 +695,32 @@ export interface BrowserContextMenuItem {
|
|
|
345
695
|
submenu?: BrowserContextMenuItem[];
|
|
346
696
|
}
|
|
347
697
|
|
|
698
|
+
export interface BrowserContextMenuElementInfo {
|
|
699
|
+
tagName: string;
|
|
700
|
+
isLink: boolean;
|
|
701
|
+
isImage: boolean;
|
|
702
|
+
isInput: boolean;
|
|
703
|
+
/** Inputs plus contenteditable regions — everything the edit commands apply to. */
|
|
704
|
+
isEditable: boolean;
|
|
705
|
+
isTextSelected: boolean;
|
|
706
|
+
/** Truncated selection, used only to label the "Search for…" item. */
|
|
707
|
+
selectedText?: string;
|
|
708
|
+
linkUrl?: string;
|
|
709
|
+
linkText?: string;
|
|
710
|
+
imageUrl?: string;
|
|
711
|
+
mediaUrl?: string;
|
|
712
|
+
mediaType?: string;
|
|
713
|
+
inputType?: string;
|
|
714
|
+
pageUrl?: string;
|
|
715
|
+
}
|
|
716
|
+
|
|
348
717
|
export interface BrowserContextMenuInfo {
|
|
349
718
|
tabId: string;
|
|
350
719
|
menuId: string;
|
|
351
720
|
x: number; // Click coordinates
|
|
352
721
|
y: number;
|
|
353
722
|
items: BrowserContextMenuItem[];
|
|
354
|
-
elementInfo:
|
|
355
|
-
tagName: string;
|
|
356
|
-
isLink: boolean;
|
|
357
|
-
isImage: boolean;
|
|
358
|
-
isInput: boolean;
|
|
359
|
-
isTextSelected: boolean;
|
|
360
|
-
linkUrl?: string;
|
|
361
|
-
imageUrl?: string;
|
|
362
|
-
inputType?: string;
|
|
363
|
-
};
|
|
723
|
+
elementInfo: BrowserContextMenuElementInfo;
|
|
364
724
|
timestamp: number;
|
|
365
725
|
}
|
|
366
726
|
|
package/backend/utils/cli.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Resolution strategy:
|
|
7
7
|
* 1. Enrich process.env.PATH with known install directories (and, on Unix
|
|
8
8
|
* desktops, the user's interactive-shell PATH) so binaries installed
|
|
9
|
-
* via our
|
|
9
|
+
* via our Stack installer, nvm/fnm/volta/asdf/bun/homebrew, or
|
|
10
10
|
* by the user become visible without a clopen restart.
|
|
11
11
|
* 2. Call `Bun.which(binary, { PATH: process.env.PATH })` — the explicit
|
|
12
12
|
* PATH option is critical: without it, Bun.which uses a cached startup
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Strategy (in order, dedup'd, prepended so new entries win):
|
|
11
11
|
* 1. Known install directories: deterministic list of locations used by
|
|
12
|
-
* common installers and package managers (our
|
|
12
|
+
* common installers and package managers (our Stack installer,
|
|
13
13
|
* `curl | bash` scripts, Homebrew, Scoop, winget links, cargo, bun,
|
|
14
14
|
* deno, volta, yarn, nvm/fnm node versions, …). Existing entries only.
|
|
15
15
|
* 2. Harvested shell PATH: on Unix desktops where the user has custom
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* Concurrency: refreshProcessPath() dedups via an in-flight promise so
|
|
25
25
|
* parallel callers share one pass. Known-dir enumeration happens every
|
|
26
|
-
* call so tools installed at runtime (via
|
|
26
|
+
* call so tools installed at runtime (via Stack) become visible
|
|
27
27
|
* without a restart.
|
|
28
28
|
*/
|
|
29
29
|
|
package/backend/ws/README.md
CHANGED
|
@@ -1323,7 +1323,7 @@ Guards live in **two tiers**:
|
|
|
1323
1323
|
| `preview` | `requireBrowserPreviewAccess` | the connection's current project — adds membership check + service lookup |
|
|
1324
1324
|
| `preview` | `requireBrowserTabAccess` | an optional `tabId` — combines membership check with active/explicit tab lookup |
|
|
1325
1325
|
| `db-client` | `requireDbClientConnectionAccess` | a connection id from `db_client_connections` (admin override + owner check) |
|
|
1326
|
-
| `
|
|
1326
|
+
| `stack` | `requireInstallSessionAccess` | a Stack install `sessionId` — owner check |
|
|
1327
1327
|
| `engine` | `requireSetupSessionAccess` | a setup-flow `setupId` — admin who started the flow only |
|
|
1328
1328
|
|
|
1329
1329
|
**DO:**
|
|
@@ -27,7 +27,8 @@ export const artifactGenerateHandler = createRouter()
|
|
|
27
27
|
]),
|
|
28
28
|
purpose: t.String(),
|
|
29
29
|
engine: t.String(),
|
|
30
|
-
|
|
30
|
+
/** Hint only — the provider is re-derived from the engine catalog. */
|
|
31
|
+
providerSlug: t.Optional(t.String()),
|
|
31
32
|
modelId: t.String(),
|
|
32
33
|
projectId: t.Optional(t.String())
|
|
33
34
|
}),
|
|
@@ -341,7 +341,7 @@ export const codexAccountsHandler = createRouter()
|
|
|
341
341
|
if (!codexCmd) {
|
|
342
342
|
ws.emit.user(userId, 'engine:codex-account-setup-error', {
|
|
343
343
|
setupId,
|
|
344
|
-
message: 'Codex CLI not found on PATH. Install it via Settings →
|
|
344
|
+
message: 'Codex CLI not found on PATH. Install it via Settings → Stack.'
|
|
345
345
|
});
|
|
346
346
|
return;
|
|
347
347
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Reports SDK availability + active account state. Codex differs from
|
|
5
5
|
* Copilot in that the SDK does NOT bundle a CLI internally — the CLI must
|
|
6
|
-
* be installed on PATH (
|
|
6
|
+
* be installed on PATH (Stack → Codex CLI). `installed` reflects
|
|
7
7
|
* whether the `codex` binary resolves on the host's PATH.
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -8,6 +8,7 @@ import { t } from 'elysia';
|
|
|
8
8
|
import { createRouter } from '$shared/utils/ws-server';
|
|
9
9
|
import { execGit } from '../../git/git-executor';
|
|
10
10
|
import { initializeEngine } from '../../engine';
|
|
11
|
+
import { resolveGenerationTarget } from '../../engine/resolve-model';
|
|
11
12
|
import type { EngineType } from '$shared/types/unified';
|
|
12
13
|
import type { GeneratedBranchName } from '$shared/types/git';
|
|
13
14
|
import {
|
|
@@ -131,7 +132,8 @@ export const branchNameHandler = createRouter()
|
|
|
131
132
|
data: t.Object({
|
|
132
133
|
projectId: t.String(),
|
|
133
134
|
engine: t.String(),
|
|
134
|
-
|
|
135
|
+
/** Hint only — the provider is re-derived from the engine catalog. */
|
|
136
|
+
providerSlug: t.Optional(t.String()),
|
|
135
137
|
modelId: t.String(),
|
|
136
138
|
branchSeparator: t.Optional(t.String()),
|
|
137
139
|
maxWords: t.Optional(t.Number()),
|
|
@@ -167,14 +169,18 @@ export const branchNameHandler = createRouter()
|
|
|
167
169
|
const extra = data.customPrompt?.trim();
|
|
168
170
|
const prompt = `${instructions}${extra ? `\n\nAdditional constraints:\n${extra}` : ''}\n\nGit diff:\n${rawDiff}`;
|
|
169
171
|
|
|
170
|
-
|
|
172
|
+
// The caller's providerSlug/account can be stale (see resolve-model.ts).
|
|
173
|
+
const target = await resolveGenerationTarget(engine, data.modelId, data.providerSlug);
|
|
174
|
+
|
|
175
|
+
debug.log('git', `Generating branch name via ${engineType}/${target.providerSlug}/${target.modelId}`);
|
|
171
176
|
|
|
172
177
|
const result = await engine.generateStructured<GeneratedBranchName>({
|
|
173
178
|
prompt,
|
|
174
|
-
providerSlug:
|
|
175
|
-
modelId:
|
|
179
|
+
providerSlug: target.providerSlug,
|
|
180
|
+
modelId: target.modelId,
|
|
176
181
|
schema: BRANCH_NAME_SCHEMA,
|
|
177
|
-
projectPath: cwd
|
|
182
|
+
projectPath: cwd,
|
|
183
|
+
...(target.accountId != null && { accountId: target.accountId })
|
|
178
184
|
});
|
|
179
185
|
|
|
180
186
|
const description = sanitizeBranchDescription(result.description, data.maxWords ?? MAX_BRANCH_DESCRIPTION_WORDS);
|