browse 0.11.3 → 0.11.4
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 +56 -25
- package/bin/run.js +2 -5
- package/dist/commands/click.js +1 -1
- package/dist/commands/cloud/contexts/get.js +1 -1
- package/dist/commands/cloud/contexts/list.js +2 -5
- package/dist/commands/cloud/extensions/get.js +1 -1
- package/dist/commands/cloud/extensions/upload.js +34 -8
- package/dist/commands/cloud/projects/get.js +1 -1
- package/dist/commands/cloud/projects/list.js +2 -5
- package/dist/commands/cloud/projects/usage.js +1 -1
- package/dist/commands/cloud/search.js +2 -2
- package/dist/commands/cloud/secrets/list.js +1 -1
- package/dist/commands/cloud/sessions/create.js +2 -7
- package/dist/commands/cloud/sessions/debug.js +1 -1
- package/dist/commands/cloud/sessions/get.js +1 -1
- package/dist/commands/cloud/sessions/list.js +2 -2
- package/dist/commands/cloud/sessions/logs.js +2 -4
- package/dist/commands/cloud/sessions/uploads/create.js +1 -3
- package/dist/commands/cursor.js +2 -5
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/eval.js +1 -1
- package/dist/commands/fill.js +1 -1
- package/dist/commands/functions/secrets/list.js +1 -1
- package/dist/commands/get.js +1 -1
- package/dist/commands/highlight.js +1 -1
- package/dist/commands/is.js +1 -1
- package/dist/commands/network/clear.js +2 -5
- package/dist/commands/network/off.js +2 -5
- package/dist/commands/network/on.js +2 -5
- package/dist/commands/network/path.js +2 -5
- package/dist/commands/press.js +2 -6
- package/dist/commands/select.js +1 -1
- package/dist/commands/skills/find.js +1 -1
- package/dist/commands/skills/list.js +2 -2
- package/dist/commands/skills/show.js +3 -1
- package/dist/commands/snapshot.js +1 -1
- package/dist/commands/status.js +1 -4
- package/dist/commands/tab/close.js +1 -1
- package/dist/commands/tab/list.js +2 -5
- package/dist/commands/tab/new.js +1 -1
- package/dist/commands/tab/switch.js +1 -1
- package/dist/commands/templates/find.js +1 -1
- package/dist/commands/templates/list.js +1 -1
- package/dist/commands/type.js +1 -1
- package/dist/commands/upload.js +1 -1
- package/dist/hooks/command-not-found.js +2 -6
- package/dist/lib/child-process.js +22 -0
- package/dist/lib/cloud/api.js +1 -2
- package/dist/lib/cloud/reduce-logs.js +3 -6
- package/dist/lib/driver/cdp-tail.js +4 -15
- package/dist/lib/driver/command-cli.js +21 -12
- package/dist/lib/driver/commands/elements.js +2 -6
- package/dist/lib/driver/commands/navigation.js +2 -4
- package/dist/lib/driver/commands/page-info.js +1 -3
- package/dist/lib/driver/commands/runtime.js +2 -5
- package/dist/lib/driver/commands/selectors.js +2 -6
- package/dist/lib/driver/commands/tabs.js +3 -8
- package/dist/lib/driver/daemon/client.js +30 -20
- package/dist/lib/driver/daemon/paths.js +131 -9
- package/dist/lib/driver/daemon/server.js +3 -5
- package/dist/lib/driver/doctor.js +19 -8
- package/dist/lib/driver/local-cdp-discovery.js +1 -1
- package/dist/lib/driver/network-capture.js +1 -1
- package/dist/lib/driver/network-cdp-sidecar.js +14 -11
- package/dist/lib/driver/remote.js +1 -1
- package/dist/lib/driver/runtime.js +7 -3
- package/dist/lib/driver/session-manager.js +7 -5
- package/dist/lib/functions/dev.js +21 -18
- package/dist/lib/functions/init.js +8 -8
- package/dist/lib/functions/publish.js +6 -9
- package/dist/lib/functions/shared.js +4 -2
- package/dist/lib/secrets/seal.js +1 -4
- package/dist/lib/skills/catalog.js +1 -2
- package/dist/lib/skills/install.js +11 -39
- package/dist/lib/telemetry.js +5 -17
- package/dist/lib/templates/api.js +1 -2
- package/dist/lib/templates/scaffold.js +5 -7
- package/dist/lib/update.js +2 -5
- package/oclif.manifest.json +198 -191
- package/package.json +79 -66
- package/skills/browse/SKILL.md +1 -0
package/dist/lib/secrets/seal.js
CHANGED
|
@@ -19,10 +19,7 @@ export async function sealSecret(publicKey, value) {
|
|
|
19
19
|
const sender = await suite.createSenderContext({ recipientPublicKey });
|
|
20
20
|
const ciphertext = await sender.seal(new Uint8Array(value).buffer);
|
|
21
21
|
// Go's crypto/hpke.Open expects the encapsulated key followed by ciphertext.
|
|
22
|
-
return Buffer.concat([
|
|
23
|
-
Buffer.from(sender.enc),
|
|
24
|
-
Buffer.from(ciphertext),
|
|
25
|
-
]).toString("base64");
|
|
22
|
+
return Buffer.concat([Buffer.from(sender.enc), Buffer.from(ciphertext)]).toString("base64");
|
|
26
23
|
}
|
|
27
24
|
catch {
|
|
28
25
|
fail("Failed to encrypt the secret with the project's public key.");
|
|
@@ -169,8 +169,7 @@ function numberField(value, context, field) {
|
|
|
169
169
|
return value;
|
|
170
170
|
}
|
|
171
171
|
function stringArrayField(value, context, field) {
|
|
172
|
-
if (!Array.isArray(value) ||
|
|
173
|
-
value.some((entry) => typeof entry !== "string")) {
|
|
172
|
+
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
|
|
174
173
|
fail(`Invalid skills response for ${context}: ${field} must be an array of strings.`);
|
|
175
174
|
}
|
|
176
175
|
return value;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import spawn from "cross-spawn";
|
|
2
2
|
import { constants } from "node:fs";
|
|
3
|
-
import { access, mkdir, mkdtemp, rm, rename, writeFile
|
|
3
|
+
import { access, mkdir, mkdtemp, rm, rename, writeFile } from "node:fs/promises";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { delimiter, dirname, join } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { fail } from "../errors.js";
|
|
8
|
+
import { terminateChild } from "../child-process.js";
|
|
8
9
|
import { setRunTelemetryCompletion } from "../run-telemetry.js";
|
|
9
10
|
import { defaultSkillsApiBaseUrl, isRecord, responseDetail } from "./shared.js";
|
|
10
11
|
const defaultBlobBaseUrl = "https://gh0lfhlmyzhg6tww.public.blob.vercel-storage.com";
|
|
@@ -72,12 +73,7 @@ export async function installSkill(rawSkillId) {
|
|
|
72
73
|
if (files.status === "found") {
|
|
73
74
|
const result = await downloadBlobSkill(skill, files.files);
|
|
74
75
|
process.stdout.write(`Downloaded ${result.fileCount} skill file${result.fileCount === 1 ? "" : "s"} to ${result.installPath}\n`);
|
|
75
|
-
await runSkillsInstall(npxPath, [
|
|
76
|
-
"--yes",
|
|
77
|
-
"skills",
|
|
78
|
-
"add",
|
|
79
|
-
result.installPath,
|
|
80
|
-
]);
|
|
76
|
+
await runSkillsInstall(npxPath, ["--yes", "skills", "add", result.installPath]);
|
|
81
77
|
return;
|
|
82
78
|
}
|
|
83
79
|
if (files.status === "not_found") {
|
|
@@ -124,9 +120,7 @@ async function runSkillsInstall(npxPath, args) {
|
|
|
124
120
|
fail(`Skill install timed out after ${Math.round(timeoutMs / 1000)}s waiting for \`npx skills add\`. Check your network connection and rerun \`browse skills add\`.`, 1, { resultCode: "skill_install_timeout" });
|
|
125
121
|
}
|
|
126
122
|
const detail = result.output.trim();
|
|
127
|
-
const reason = detail
|
|
128
|
-
? `: ${detail}`
|
|
129
|
-
: " (see the output above for details).";
|
|
123
|
+
const reason = detail ? `: ${detail}` : " (see the output above for details).";
|
|
130
124
|
fail(`Could not install skill${reason}`, result.exitCode || 1, {
|
|
131
125
|
resultCode: "skill_install_failed",
|
|
132
126
|
});
|
|
@@ -283,9 +277,7 @@ function validateSkillFilePath(value, skillId) {
|
|
|
283
277
|
}
|
|
284
278
|
if (value.startsWith("/") ||
|
|
285
279
|
value.includes("\\") ||
|
|
286
|
-
value
|
|
287
|
-
.split("/")
|
|
288
|
-
.some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
280
|
+
value.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
289
281
|
fail(`Invalid file list for ${skillId}: unsafe file path "${value}".`);
|
|
290
282
|
}
|
|
291
283
|
return value;
|
|
@@ -348,9 +340,7 @@ async function findExecutable(command) {
|
|
|
348
340
|
return null;
|
|
349
341
|
}
|
|
350
342
|
const extensions = process.platform === "win32"
|
|
351
|
-
? (process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM")
|
|
352
|
-
.split(";")
|
|
353
|
-
.filter(Boolean)
|
|
343
|
+
? (process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean)
|
|
354
344
|
: [""];
|
|
355
345
|
for (const segment of pathEnv.split(delimiter)) {
|
|
356
346
|
for (const extension of extensions) {
|
|
@@ -366,38 +356,23 @@ async function findExecutable(command) {
|
|
|
366
356
|
}
|
|
367
357
|
return null;
|
|
368
358
|
}
|
|
369
|
-
// Quotes a single token for the command line Node hands to cmd.exe when
|
|
370
|
-
// `shell: true`. Node joins command+args UNQUOTED into `cmd.exe /d /s /c
|
|
371
|
-
// "..."`, so an unquoted `C:\Program Files\nodejs\npx.cmd` splits at the
|
|
372
|
-
// space and cmd runs `C:\Program`. Wrapping tokens that contain whitespace,
|
|
373
|
-
// quotes, or cmd metacharacters in double quotes (with embedded quotes
|
|
374
|
-
// doubled) keeps them intact; `/s` makes cmd strip only the outer quotes.
|
|
375
|
-
export function quoteForCmdShell(token) {
|
|
376
|
-
if (token === "") {
|
|
377
|
-
return '""';
|
|
378
|
-
}
|
|
379
|
-
return /[\s"^&|<>]/.test(token) ? `"${token.replaceAll('"', '""')}"` : token;
|
|
380
|
-
}
|
|
381
359
|
// Like `stdio: "inherit"` for the human watching, but the child's stdout/stderr
|
|
382
360
|
// are also buffered (tail only) so a nonzero exit can surface a real reason to
|
|
383
361
|
// telemetry instead of a bare exit code. The child is killed after `timeoutMs`
|
|
384
362
|
// (SIGTERM, then SIGKILL) so a hung `npx` cannot stall the install forever.
|
|
385
363
|
// Exported for tests.
|
|
386
364
|
export async function spawnPassthrough(command, args, timeoutMs = installTimeoutMs()) {
|
|
387
|
-
const useWindowsShell = shouldUseWindowsShell(command);
|
|
388
|
-
const spawnCommand = useWindowsShell ? quoteForCmdShell(command) : command;
|
|
389
|
-
const spawnArgs = useWindowsShell ? args.map(quoteForCmdShell) : args;
|
|
390
365
|
return await new Promise((resolvePromise) => {
|
|
391
|
-
const child = spawn(
|
|
366
|
+
const child = spawn(command, args, {
|
|
392
367
|
stdio: ["inherit", "pipe", "pipe"],
|
|
393
|
-
|
|
368
|
+
windowsHide: true,
|
|
394
369
|
});
|
|
395
370
|
let timedOut = false;
|
|
396
371
|
let killTimer;
|
|
397
372
|
const deadline = setTimeout(() => {
|
|
398
373
|
timedOut = true;
|
|
399
|
-
child
|
|
400
|
-
killTimer = setTimeout(() => child
|
|
374
|
+
terminateChild(child);
|
|
375
|
+
killTimer = setTimeout(() => terminateChild(child, "SIGKILL"), 5_000);
|
|
401
376
|
}, timeoutMs);
|
|
402
377
|
const clearTimers = () => {
|
|
403
378
|
clearTimeout(deadline);
|
|
@@ -440,6 +415,3 @@ export async function spawnPassthrough(command, args, timeoutMs = installTimeout
|
|
|
440
415
|
});
|
|
441
416
|
});
|
|
442
417
|
}
|
|
443
|
-
export function shouldUseWindowsShell(command, platform = process.platform) {
|
|
444
|
-
return platform === "win32" && /\.(?:bat|cmd)$/i.test(command);
|
|
445
|
-
}
|
package/dist/lib/telemetry.js
CHANGED
|
@@ -44,10 +44,7 @@ export async function captureCommandCompleted(cliVersion, error) {
|
|
|
44
44
|
.catch(() => {
|
|
45
45
|
// Best-effort telemetry should never affect CLI behavior.
|
|
46
46
|
});
|
|
47
|
-
await Promise.allSettled([
|
|
48
|
-
state.pendingInvokedCapture ?? Promise.resolve(),
|
|
49
|
-
completionCapture,
|
|
50
|
-
]);
|
|
47
|
+
await Promise.allSettled([state.pendingInvokedCapture ?? Promise.resolve(), completionCapture]);
|
|
51
48
|
}
|
|
52
49
|
/**
|
|
53
50
|
* Captures a `cli.command_not_found` event. Privacy: only the sanitized
|
|
@@ -57,12 +54,8 @@ export async function captureCommandCompleted(cliVersion, error) {
|
|
|
57
54
|
export async function captureCommandNotFound(cliVersion, attemptedCommand, suggestedCommand) {
|
|
58
55
|
await getCliTelemetry(cliVersion)
|
|
59
56
|
.capture("cli.command_not_found", {
|
|
60
|
-
attempted_command: attemptedCommand
|
|
61
|
-
|
|
62
|
-
: null,
|
|
63
|
-
suggested_command: suggestedCommand
|
|
64
|
-
? resolveCommandPath(suggestedCommand)
|
|
65
|
-
: null,
|
|
57
|
+
attempted_command: attemptedCommand ? resolveCommandPath(attemptedCommand) : null,
|
|
58
|
+
suggested_command: suggestedCommand ? resolveCommandPath(suggestedCommand) : null,
|
|
66
59
|
})
|
|
67
60
|
.catch(() => {
|
|
68
61
|
// Best-effort telemetry should never affect CLI behavior.
|
|
@@ -89,10 +82,7 @@ function createCliTelemetry(options) {
|
|
|
89
82
|
if (!telemetryEnabled) {
|
|
90
83
|
return;
|
|
91
84
|
}
|
|
92
|
-
const [distinctId, agent] = await Promise.all([
|
|
93
|
-
distinctIdPromise,
|
|
94
|
-
agentPromise,
|
|
95
|
-
]);
|
|
85
|
+
const [distinctId, agent] = await Promise.all([distinctIdPromise, agentPromise]);
|
|
96
86
|
await posthogCapture(transport, {
|
|
97
87
|
api_key: transport.projectToken,
|
|
98
88
|
distinct_id: distinctId,
|
|
@@ -160,9 +150,7 @@ function commandCompletedProperties(invocation, completion) {
|
|
|
160
150
|
: (completion.recordedError?.code ?? inferErrorCode(completion.error)),
|
|
161
151
|
result_code: resultCode,
|
|
162
152
|
http_status: failureTelemetry?.httpStatus ?? runTelemetry.httpStatus ?? null,
|
|
163
|
-
request_had_http_response: failureTelemetry?.requestHadHttpResponse ??
|
|
164
|
-
runTelemetry.requestHadHttpResponse ??
|
|
165
|
-
null,
|
|
153
|
+
request_had_http_response: failureTelemetry?.requestHadHttpResponse ?? runTelemetry.requestHadHttpResponse ?? null,
|
|
166
154
|
skill_id: runTelemetry.skillId ?? null,
|
|
167
155
|
};
|
|
168
156
|
}
|
|
@@ -133,8 +133,7 @@ function optionalStringArray(value, context, field) {
|
|
|
133
133
|
if (value === undefined || value === null) {
|
|
134
134
|
return [];
|
|
135
135
|
}
|
|
136
|
-
if (!Array.isArray(value) ||
|
|
137
|
-
value.some((entry) => typeof entry !== "string")) {
|
|
136
|
+
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
|
|
138
137
|
fail(`Invalid template response for ${context}: ${field} must be an array of strings.`);
|
|
139
138
|
}
|
|
140
139
|
return value;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import spawn from "cross-spawn";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { mkdir, readdir, readFile, rename, rm } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -68,14 +68,14 @@ function templateSupportsLanguage(template, language) {
|
|
|
68
68
|
const tags = new Set(template.tags.map((tag) => tag.toLowerCase()));
|
|
69
69
|
const commands = template.commands.join("\n").toLowerCase();
|
|
70
70
|
if (language === "typescript") {
|
|
71
|
-
return
|
|
71
|
+
return tags.has("typescript") || commands.includes("npx create-browser-app");
|
|
72
72
|
}
|
|
73
73
|
return (tags.has("python") ||
|
|
74
74
|
commands.includes("uvx create-browser-app") ||
|
|
75
75
|
commands.includes("uv tool run create-browser-app"));
|
|
76
76
|
}
|
|
77
77
|
function commandExists(command, args = ["--version"]) {
|
|
78
|
-
const result =
|
|
78
|
+
const result = spawn.sync(command, args, {
|
|
79
79
|
stdio: "ignore",
|
|
80
80
|
});
|
|
81
81
|
return !result.error && result.status === 0;
|
|
@@ -111,7 +111,7 @@ function getScaffolder(language) {
|
|
|
111
111
|
fail("Python templates require `uvx` or `uv` to scaffold a ready-to-run project.");
|
|
112
112
|
}
|
|
113
113
|
function runCommand(command, args, cwd) {
|
|
114
|
-
const result =
|
|
114
|
+
const result = spawn.sync(command, args, {
|
|
115
115
|
cwd,
|
|
116
116
|
encoding: "utf8",
|
|
117
117
|
stdio: "pipe",
|
|
@@ -123,9 +123,7 @@ function runCommand(command, args, cwd) {
|
|
|
123
123
|
const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
|
|
124
124
|
const stdout = typeof result.stdout === "string" ? result.stdout.trim() : "";
|
|
125
125
|
const renderedCommand = `${command} ${args.join(" ")}`;
|
|
126
|
-
throw new Error(stderr ||
|
|
127
|
-
stdout ||
|
|
128
|
-
`${renderedCommand} failed with exit code ${result.status ?? "unknown"}.`);
|
|
126
|
+
throw new Error(stderr || stdout || `${renderedCommand} failed with exit code ${result.status ?? "unknown"}.`);
|
|
129
127
|
}
|
|
130
128
|
return {
|
|
131
129
|
stderr: typeof result.stderr === "string" ? result.stderr : "",
|
package/dist/lib/update.js
CHANGED
|
@@ -8,8 +8,7 @@ const DEFAULT_NPM_REGISTRY_BASE_URL = "https://registry.npmjs.org/";
|
|
|
8
8
|
const UPDATE_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
9
9
|
const UPDATE_TIMEOUT_MS = 1500;
|
|
10
10
|
export async function maybeAutoUpdateCli(currentVersion, env = process.env, options = {}) {
|
|
11
|
-
if (env.BROWSE_DISABLE_UPDATE_CHECK === "1" ||
|
|
12
|
-
env.BB_DISABLE_UPDATE_CHECK === "1") {
|
|
11
|
+
if (env.BROWSE_DISABLE_UPDATE_CHECK === "1" || env.BB_DISABLE_UPDATE_CHECK === "1") {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
14
|
const cachePath = resolveUpdateCheckPath(env, options);
|
|
@@ -82,9 +81,7 @@ async function writeUpdateCheckCache(cachePath, cache) {
|
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
function resolveUpdateCheckPath(env, options = {}) {
|
|
85
|
-
const configured = options.cacheFile ??
|
|
86
|
-
env.BROWSE_UPDATE_CHECK_FILE ??
|
|
87
|
-
env.BB_UPDATE_CHECK_FILE;
|
|
84
|
+
const configured = options.cacheFile ?? env.BROWSE_UPDATE_CHECK_FILE ?? env.BB_UPDATE_CHECK_FILE;
|
|
88
85
|
return configured && configured.length > 0 ? configured : null;
|
|
89
86
|
}
|
|
90
87
|
function spawnBackgroundUpdateCheck(env, cachePath) {
|