@vellumai/assistant 0.12.1-dev.202609142113.d1590bc → 0.12.1-dev.202609142313.e3dac74
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
|
@@ -31,10 +31,18 @@ test("preserves unrelated policies and does not rewrite on repeated startup", ()
|
|
|
31
31
|
const otherPath = join(directory, "organization.json");
|
|
32
32
|
const unrelated = '{ "HomepageLocation": "https://example.com" }\n';
|
|
33
33
|
writeFileSync(otherPath, unrelated);
|
|
34
|
-
writeFileSync(
|
|
34
|
+
writeFileSync(
|
|
35
|
+
path,
|
|
36
|
+
JSON.stringify({
|
|
37
|
+
CommandLineFlagSecurityWarningsEnabled: false,
|
|
38
|
+
DownloadRestrictions: 1,
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
const original = statSync(path);
|
|
35
42
|
|
|
36
43
|
writeDesktopChromePolicy(directory);
|
|
37
44
|
const content = readFileSync(path, "utf8");
|
|
45
|
+
expect(statSync(path).ino).not.toBe(original.ino);
|
|
38
46
|
expect(JSON.parse(content).DownloadRestrictions).toBe(1);
|
|
39
47
|
expect(readFileSync(otherPath, "utf8")).toBe(unrelated);
|
|
40
48
|
expect(readdirSync(directory).sort()).toEqual([
|
|
@@ -22,12 +22,17 @@ export function writeDesktopChromePolicy(policyDir: string): void {
|
|
|
22
22
|
throw err;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
if (
|
|
25
|
+
if (
|
|
26
|
+
policy.CommandLineFlagSecurityWarningsEnabled === false &&
|
|
27
|
+
policy.PasswordManagerEnabled === false
|
|
28
|
+
) {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
// This suppresses command-line warnings; Chrome's sandbox stays unchanged.
|
|
30
33
|
policy.CommandLineFlagSecurityWarningsEnabled = false;
|
|
34
|
+
// Suppress save prompts while keeping previously saved passwords usable.
|
|
35
|
+
policy.PasswordManagerEnabled = false;
|
|
31
36
|
mkdirSync(policyDir, { recursive: true });
|
|
32
37
|
const staging = mkdtempSync(join(policyDir, ".vellum-desktop-"));
|
|
33
38
|
try {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
export function shouldRestoreDesktopChromeSession(profileDir: string): boolean {
|
|
5
|
+
const lastUsed = readProfileMetadata(
|
|
6
|
+
join(profileDir, "Local State"),
|
|
7
|
+
)?.last_used;
|
|
8
|
+
const profileName =
|
|
9
|
+
typeof lastUsed === "string" &&
|
|
10
|
+
lastUsed !== "" &&
|
|
11
|
+
lastUsed !== "." &&
|
|
12
|
+
lastUsed !== ".." &&
|
|
13
|
+
basename(lastUsed) === lastUsed
|
|
14
|
+
? lastUsed
|
|
15
|
+
: "Default";
|
|
16
|
+
return (
|
|
17
|
+
readProfileMetadata(join(profileDir, profileName, "Preferences"))
|
|
18
|
+
?.exit_type === "Crashed"
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function readProfileMetadata(
|
|
23
|
+
path: string,
|
|
24
|
+
): { last_used?: unknown; exit_type?: unknown } | undefined {
|
|
25
|
+
try {
|
|
26
|
+
const value: unknown = JSON.parse(readFileSync(path, "utf8"));
|
|
27
|
+
if (value && typeof value === "object" && "profile" in value) {
|
|
28
|
+
const profile = value.profile;
|
|
29
|
+
if (profile && typeof profile === "object" && !Array.isArray(profile)) {
|
|
30
|
+
return profile;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
34
|
+
// Leave missing or unreadable session metadata to Chrome's normal startup.
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
mkdirSync,
|
|
3
|
+
mkdtempSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
rmSync,
|
|
6
|
+
writeFileSync,
|
|
7
|
+
} from "node:fs";
|
|
2
8
|
import { tmpdir } from "node:os";
|
|
3
9
|
import { join } from "node:path";
|
|
4
10
|
import { afterAll, describe, expect, test } from "bun:test";
|
|
@@ -481,6 +487,57 @@ describe("DesktopSessionManager process tree", () => {
|
|
|
481
487
|
expect(h.count("browser")).toBe(2);
|
|
482
488
|
});
|
|
483
489
|
|
|
490
|
+
test.each(["Default", "Profile 1"])(
|
|
491
|
+
"restores a crashed %s session but preserves a subsequent clean close",
|
|
492
|
+
async (profileName) => {
|
|
493
|
+
const dir = mkdtempSync(join(tmpdir(), "desktop-crash-test-"));
|
|
494
|
+
const h = newFakeDesktop({ profileDir: dir, exitOnTerm: true });
|
|
495
|
+
try {
|
|
496
|
+
mkdirSync(join(dir, profileName));
|
|
497
|
+
writeFileSync(
|
|
498
|
+
join(dir, "Local State"),
|
|
499
|
+
JSON.stringify({ profile: { last_used: profileName } }),
|
|
500
|
+
);
|
|
501
|
+
const preferences = join(dir, profileName, "Preferences");
|
|
502
|
+
const crashed = JSON.stringify({ profile: { exit_type: "Crashed" } });
|
|
503
|
+
writeFileSync(preferences, crashed);
|
|
504
|
+
h.manager.acquireViewerSlot(newViewer().viewer);
|
|
505
|
+
await h.manager.ensureDesktopRunning();
|
|
506
|
+
expect(h.child("browser").request.cmd).toContain(
|
|
507
|
+
"--restore-last-session",
|
|
508
|
+
);
|
|
509
|
+
expect(h.child("browser").request.cmd).toContain(
|
|
510
|
+
"--hide-crash-restore-bubble",
|
|
511
|
+
);
|
|
512
|
+
expect(readFileSync(preferences, "utf8")).toBe(crashed);
|
|
513
|
+
|
|
514
|
+
h.child("browser").exit(1);
|
|
515
|
+
await settle();
|
|
516
|
+
expect(h.count("browser")).toBe(2);
|
|
517
|
+
expect(h.child("browser").request.cmd).toContain(
|
|
518
|
+
"--restore-last-session",
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
writeFileSync(
|
|
522
|
+
preferences,
|
|
523
|
+
JSON.stringify({ profile: { exit_type: "Normal" } }),
|
|
524
|
+
);
|
|
525
|
+
h.child("browser").exit(0);
|
|
526
|
+
await settle();
|
|
527
|
+
expect(h.count("browser")).toBe(3);
|
|
528
|
+
expect(h.child("browser").request.cmd).not.toContain(
|
|
529
|
+
"--restore-last-session",
|
|
530
|
+
);
|
|
531
|
+
expect(h.child("browser").request.cmd).not.toContain(
|
|
532
|
+
"--hide-crash-restore-bubble",
|
|
533
|
+
);
|
|
534
|
+
} finally {
|
|
535
|
+
await h.manager.destroy();
|
|
536
|
+
rmSync(dir, { recursive: true, force: true });
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
);
|
|
540
|
+
|
|
484
541
|
test("a browser exit under a viewer relaunches it, until it crash loops", async () => {
|
|
485
542
|
const h = newManager();
|
|
486
543
|
const { viewer, lost } = newViewer();
|
|
@@ -17,6 +17,7 @@ import { getLogger } from "../util/logger.js";
|
|
|
17
17
|
import { getDataDir } from "../util/platform.js";
|
|
18
18
|
import { sleep } from "../util/retry.js";
|
|
19
19
|
import { writeDesktopChromePolicy } from "./desktop-chrome-policy.js";
|
|
20
|
+
import { shouldRestoreDesktopChromeSession } from "./desktop-chrome-session.js";
|
|
20
21
|
import {
|
|
21
22
|
desktopChromePath,
|
|
22
23
|
resolveDesktopBinaries,
|
|
@@ -717,6 +718,10 @@ function browserCommand(executable: string, profileDir: string): string[] {
|
|
|
717
718
|
"--no-sandbox",
|
|
718
719
|
"--no-first-run",
|
|
719
720
|
"--disable-dev-shm-usage",
|
|
721
|
+
// Crash recovery requires both flags; clean exits use normal startup.
|
|
722
|
+
...(shouldRestoreDesktopChromeSession(profileDir)
|
|
723
|
+
? ["--restore-last-session", "--hide-crash-restore-bubble"]
|
|
724
|
+
: []),
|
|
720
725
|
"--start-maximized",
|
|
721
726
|
"--window-position=0,0",
|
|
722
727
|
`--window-size=${DESKTOP_WIDTH},${DESKTOP_HEIGHT}`,
|