@ai-ecoverse/sliccy-browser 0.1.40 → 0.1.42

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/sliccy-browser",
3
- "version": "0.1.40",
4
- "description": "sliccy:browser for jsh, over CDP. Discovers Chrome via SLICC_CDP_URL, slicc browsers --json, DevToolsActivePort under slicc profiles, then 127.0.0.1:9222. Discovered endpoints refuse seven/vault/extension/error pages.",
3
+ "version": "0.1.42",
4
+ "description": "sliccy:browser for jsh, over CDP. Discovers Chrome via SLICC_CDP_URL, slicc browsers --json, DevToolsActivePort under slicc profiles (live /json/version must match the file's websocket path), then 127.0.0.1:9222. Discovered endpoints refuse seven/vault/extension/error pages; pre-attach websocket frames are dropped with a one-time warning.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
package/src/browser.js CHANGED
@@ -16,6 +16,8 @@ export { REFUSAL, resolveCdpEndpoint, version };
16
16
 
17
17
  const LOAD_TIMEOUT_MS = 15000;
18
18
  const HELD_FRAMES = 100;
19
+ const UNKNOWN_SOCKET_WARNING =
20
+ 'browser.websocket: frames from sockets opened before the first attach are ignored in discovered mode; reload the tab or reconnect the socket after the first attach to make them visible';
19
21
  const RECORDER = `(() => {
20
22
  if (globalThis.__sliccWsSent) return true;
21
23
  const sent = [];
@@ -191,11 +193,24 @@ function dispatchFrame(message) {
191
193
  route(targetId, url, response.payloadData, () => true);
192
194
  return;
193
195
  }
194
- if (guarded) return;
196
+ if (guarded) {
197
+ noteUnknownDrop(targetId);
198
+ return;
199
+ }
195
200
  route(targetId, url, response.payloadData, (sub) => sub.urlMatch === undefined);
196
201
  holdFrame(message.sessionId, targetId, key, response.payloadData);
197
202
  }
198
203
 
204
+ function noteUnknownDrop(targetId) {
205
+ for (const sub of subscribers.values()) {
206
+ if (sub.targetId !== targetId) continue;
207
+ sub.dropped += 1;
208
+ if (sub.warnedUnknown) continue;
209
+ sub.warnedUnknown = true;
210
+ console.warn(UNKNOWN_SOCKET_WARNING);
211
+ }
212
+ }
213
+
199
214
  function route(targetId, url, raw, which) {
200
215
  if (guarded && (typeof url !== 'string' || isProtectedUrl(url))) return;
201
216
  for (const sub of subscribers.values()) {
@@ -719,6 +734,9 @@ function toInfo(sub) {
719
734
  function makeHandle(sub) {
720
735
  return {
721
736
  ...toInfo(sub),
737
+ get dropped() {
738
+ return sub.dropped;
739
+ },
722
740
  async update(patch = {}) {
723
741
  if (patch.urlMatch === null) {
724
742
  delete sub.urlMatch;
@@ -792,6 +810,8 @@ export const websocket = {
792
810
  forward: sink,
793
811
  createdAt: new Date().toISOString(),
794
812
  writing: Promise.resolve(),
813
+ dropped: 0,
814
+ warnedUnknown: false,
795
815
  };
796
816
  if (urlMatch !== undefined) {
797
817
  sub.urlMatch = urlMatch;
package/src/discover.js CHANGED
@@ -299,16 +299,34 @@ async function fromDevToolsActivePort(options) {
299
299
  const roots = options.profileRoots ?? sliccProfileRoots(options);
300
300
  const files = await collectActivePorts(roots);
301
301
  files.sort((left, right) => right.mtimeMs - left.mtimeMs);
302
+ let identityMismatch = 0;
303
+ let probeRejected = 0;
302
304
  for (const item of files) {
303
305
  const url = await probeVersion(fetchImpl, item.port, timeoutMs);
304
- if (url === undefined) continue;
305
- if (new URL(url).pathname !== item.wsPath) continue;
306
+ if (url === undefined) {
307
+ probeRejected += 1;
308
+ continue;
309
+ }
310
+ if (new URL(url).pathname !== item.wsPath) {
311
+ identityMismatch += 1;
312
+ continue;
313
+ }
306
314
  return { ok: true, url };
307
315
  }
308
316
  if (files.length === 0) {
309
317
  return { ok: false, reason: 'no DevToolsActivePort files under slicc profile dirs' };
310
318
  }
311
- return { ok: false, reason: 'no live DevToolsActivePort (stale or rejected websocket URL)' };
319
+ const parts = [];
320
+ if (identityMismatch > 0) {
321
+ parts.push(`${identityMismatch} rejected for browser identity mismatch`);
322
+ }
323
+ if (probeRejected > 0) {
324
+ parts.push(`${probeRejected} stale or rejected websocket URL`);
325
+ }
326
+ return {
327
+ ok: false,
328
+ reason: `no live DevToolsActivePort (${parts.join('; ')})`,
329
+ };
312
330
  }
313
331
 
314
332
  async function fromFallback(options) {
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '0.1.40';
1
+ export const version = '0.1.42';