@jini-ai/desktop-host 0.7.3-next.1 → 0.7.3-next.3

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +217 -1
  3. package/dist/electron/electron-shell.js +5 -7
  4. package/dist/electron/handoff/index.d.ts +54 -0
  5. package/dist/electron/handoff/index.js +32 -0
  6. package/dist/electron/memory-sampler.d.ts +28 -0
  7. package/dist/electron/memory-sampler.js +41 -0
  8. package/dist/electron/partitions/cache-maintenance.d.ts +280 -0
  9. package/dist/electron/partitions/cache-maintenance.js +239 -0
  10. package/dist/electron/partitions/claim-sources.d.ts +54 -0
  11. package/dist/electron/partitions/claim-sources.js +36 -0
  12. package/dist/electron/partitions/holder-registry.d.ts +116 -0
  13. package/dist/electron/partitions/holder-registry.js +130 -0
  14. package/dist/electron/partitions/index.d.ts +10 -0
  15. package/dist/electron/partitions/index.js +10 -0
  16. package/dist/electron/partitions/maintenance-marker.d.ts +61 -0
  17. package/dist/electron/partitions/maintenance-marker.js +85 -0
  18. package/dist/electron/partitions/partition-inventory.d.ts +23 -0
  19. package/dist/electron/partitions/partition-inventory.js +19 -0
  20. package/dist/electron/partitions/partition-pass.d.ts +114 -0
  21. package/dist/electron/partitions/partition-pass.js +414 -0
  22. package/dist/electron/partitions/partition-root.d.ts +42 -0
  23. package/dist/electron/partitions/partition-root.js +52 -0
  24. package/dist/electron/partitions/profile-interlock.d.ts +141 -0
  25. package/dist/electron/partitions/profile-interlock.js +273 -0
  26. package/dist/electron/partitions/retirement-ledger.d.ts +116 -0
  27. package/dist/electron/partitions/retirement-ledger.js +149 -0
  28. package/dist/electron/preferences/index.d.ts +5 -0
  29. package/dist/electron/preferences/index.js +5 -0
  30. package/dist/electron/preferences/ipc.d.ts +35 -0
  31. package/dist/electron/preferences/ipc.js +21 -0
  32. package/dist/electron/preferences/menu.d.ts +103 -0
  33. package/dist/electron/preferences/menu.js +67 -0
  34. package/dist/electron/preferences/preference-file.d.ts +63 -0
  35. package/dist/electron/preferences/preference-file.js +51 -0
  36. package/dist/electron/preferences/values.d.ts +25 -0
  37. package/dist/electron/preferences/values.js +18 -0
  38. package/dist/electron/preload/index.d.ts +3 -0
  39. package/dist/electron/preload/index.js +2 -0
  40. package/dist/electron/preload/ipc-subscribe.d.ts +34 -0
  41. package/dist/electron/preload/ipc-subscribe.js +18 -0
  42. package/dist/electron/selftest/index.d.ts +3 -0
  43. package/dist/electron/selftest/index.js +3 -0
  44. package/dist/electron/selftest/selftest-tracker.d.ts +82 -0
  45. package/dist/electron/selftest/selftest-tracker.js +67 -0
  46. package/dist/electron/session-bootstrap/exchange.d.ts +50 -0
  47. package/dist/electron/session-bootstrap/exchange.js +41 -0
  48. package/dist/electron/session-bootstrap/header-arming.d.ts +18 -0
  49. package/dist/electron/session-bootstrap/header-arming.js +13 -0
  50. package/dist/electron/session-bootstrap/index.d.ts +11 -0
  51. package/dist/electron/session-bootstrap/index.js +10 -0
  52. package/dist/electron/session-bootstrap/partition.d.ts +17 -0
  53. package/dist/electron/session-bootstrap/partition.js +24 -0
  54. package/dist/electron/session-bootstrap/probe.d.ts +40 -0
  55. package/dist/electron/session-bootstrap/probe.js +29 -0
  56. package/dist/electron/session-bootstrap/types.d.ts +62 -0
  57. package/dist/electron/session-bootstrap/types.js +7 -0
  58. package/dist/electron/updates/desktop-updater.d.ts +90 -0
  59. package/dist/electron/updates/desktop-updater.js +124 -0
  60. package/dist/electron/updates/index.d.ts +4 -0
  61. package/dist/electron/updates/index.js +4 -0
  62. package/dist/electron/updates/instance-presence-strict.d.ts +27 -0
  63. package/dist/electron/updates/instance-presence-strict.js +46 -0
  64. package/dist/electron/updates/native-notices.d.ts +89 -0
  65. package/dist/electron/updates/native-notices.js +41 -0
  66. package/dist/electron/updates/update-check-now.d.ts +117 -0
  67. package/dist/electron/updates/update-check-now.js +88 -0
  68. package/dist/electron/usability/find-in-page-ipc.d.ts +3 -6
  69. package/dist/electron/usability/window-bounds-store.js +14 -12
  70. package/dist/electron/usability/zoom-menu.d.ts +1 -1
  71. package/dist/electron/webview/index.d.ts +2 -0
  72. package/dist/electron/webview/index.js +2 -0
  73. package/dist/electron/webview/webview-types.d.ts +66 -0
  74. package/dist/electron/webview/webview-types.js +12 -0
  75. package/dist/electron/windows/app-window.d.ts +83 -0
  76. package/dist/electron/windows/app-window.js +62 -0
  77. package/dist/electron/windows/dock-icon.d.ts +34 -0
  78. package/dist/electron/windows/dock-icon.js +32 -0
  79. package/dist/electron/windows/index.d.ts +3 -0
  80. package/dist/electron/windows/index.js +3 -0
  81. package/dist/logging.js +3 -1
  82. package/dist/node-toolchain/boot-setup.d.ts +63 -0
  83. package/dist/node-toolchain/boot-setup.js +59 -0
  84. package/dist/node-toolchain/index.d.ts +2 -0
  85. package/dist/node-toolchain/index.js +1 -0
  86. package/dist/shell/auto-update-controller.d.ts +34 -0
  87. package/dist/shell/auto-update-controller.js +27 -0
  88. package/dist/shell/copied-site-databases.d.ts +71 -0
  89. package/dist/shell/copied-site-databases.js +60 -0
  90. package/dist/shell/find-in-page-verify.d.ts +33 -0
  91. package/dist/shell/find-in-page-verify.js +30 -0
  92. package/dist/shell/find-menu.d.ts +33 -0
  93. package/dist/shell/find-menu.js +36 -0
  94. package/dist/shell/guest-navigation.d.ts +47 -0
  95. package/dist/shell/guest-navigation.js +58 -0
  96. package/dist/shell/instance-presence.d.ts +20 -0
  97. package/dist/shell/instance-presence.js +26 -0
  98. package/dist/shell/js-backslide-guard.d.ts +42 -0
  99. package/dist/shell/js-backslide-guard.js +44 -0
  100. package/dist/shell/node-toolchain.d.ts +34 -0
  101. package/dist/shell/node-toolchain.js +50 -0
  102. package/dist/shell/pty-helpers.d.ts +25 -0
  103. package/dist/shell/pty-helpers.js +50 -0
  104. package/dist/shell/site-presence.d.ts +32 -0
  105. package/dist/shell/site-presence.js +42 -0
  106. package/dist/shell/speech/mac-on-device-transcriber.d.ts +24 -0
  107. package/dist/shell/speech/mac-on-device-transcriber.js +81 -0
  108. package/dist/shell/speech/speech-ipc.d.ts +52 -0
  109. package/dist/shell/speech/speech-ipc.js +40 -0
  110. package/dist/shell/spellcheck-menu.d.ts +84 -0
  111. package/dist/shell/spellcheck-menu.js +63 -0
  112. package/dist/shell/supervised-site-url.d.ts +20 -0
  113. package/dist/shell/supervised-site-url.js +22 -0
  114. package/dist/speech/macos/mac-on-device-transcriber.d.ts +2 -1
  115. package/dist/speech/speech-bridge.d.ts +1 -8
  116. package/dist/speech/transcription-port.d.ts +1 -9
  117. package/dist/tauri/tauri-shell.js +8 -10
  118. package/package.json +154 -7
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @file The TypeScript-only backslide guard for the host's desktop app: the shell was converted from
3
+ * JavaScript to TypeScript on 2026-09-12
4
+ * (`ADS-memory/reports/2026-09-12-desktop-typescript-migration-plan.md`, Phase 5 item 2 —
5
+ * "Backslide guard"), and this is the gate that keeps a `.js`/`.mjs`/`.cjs` file from silently
6
+ * reappearing anywhere under the host's desktop app. Pure decision logic only, so the policy is testable
7
+ * under plain `node --test` — the filesystem/git listing that gathers candidate paths lives in
8
+ * `scripts/check-js-backslide.ts`.
9
+ *
10
+ * ## Why an allowlist of exact paths, not a directory or filename-pattern exemption
11
+ *
12
+ * The migration left one JavaScript-family file, `src/speech/preload-speech.cjs`: Electron's
13
+ * sandboxed preload loader never strips types and rejects ESM (migration plan Phase 0, probe P2), so
14
+ * a `.ts`/`.cts` preload cannot be loaded directly. That file is now `src/speech/preload-speech.cts`,
15
+ * compiled by `tsconfig.preload.json` to the gitignored `dist/speech/preload-speech.cjs` the same way
16
+ * `src/preload/preload.mts` already was (the migration's rule 1 bars a compile step for the MAIN
17
+ * process, not for a preload). Its allowlist entry is transitional — see `scripts/check-js-backslide.ts`'s
18
+ * `ALLOWLIST`. Naming a file exactly — never "anything under src/speech" or "anything named
19
+ * preload-*" — means a second `.cjs` landing anywhere, including a sibling in the very same
20
+ * directory, still fails the gate instead of riding in on an existing exemption.
21
+ */
22
+ /**
23
+ * Every path in `paths` that is a JavaScript-family file and is not named exactly in `allowlist`.
24
+ *
25
+ * @param paths repo-relative file paths to check — the shape `git ls-files -co --exclude-standard`
26
+ * produces, so gitignored build output (`dist/`, `node_modules/`, packaged release output) never
27
+ * reaches this function at all.
28
+ * @param allowlist exact repo-relative paths that may stay JavaScript-family, matched verbatim
29
+ * against the whole path — never a prefix, directory, or filename pattern — so a new offender
30
+ * cannot ride in on an existing exemption's directory or naming shape. Defaults to empty: no
31
+ * implicit exemption exists unless the caller states one.
32
+ * @returns the offending paths, in the order they were given.
33
+ * @complexity O(n * m) in `paths` and `allowlist`; both are single digits in practice (one
34
+ * allowlist entry today), so a `Set` lookup would only trade a trivially cheap linear scan for
35
+ * more code.
36
+ */
37
+ export declare function jsBackslideOffenders({ paths }: {
38
+ paths: readonly string[];
39
+ }, { allowlist }?: {
40
+ allowlist?: readonly string[];
41
+ }): string[];
42
+ //# sourceMappingURL=js-backslide-guard.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @file The TypeScript-only backslide guard for the host's desktop app: the shell was converted from
3
+ * JavaScript to TypeScript on 2026-09-12
4
+ * (`ADS-memory/reports/2026-09-12-desktop-typescript-migration-plan.md`, Phase 5 item 2 —
5
+ * "Backslide guard"), and this is the gate that keeps a `.js`/`.mjs`/`.cjs` file from silently
6
+ * reappearing anywhere under the host's desktop app. Pure decision logic only, so the policy is testable
7
+ * under plain `node --test` — the filesystem/git listing that gathers candidate paths lives in
8
+ * `scripts/check-js-backslide.ts`.
9
+ *
10
+ * ## Why an allowlist of exact paths, not a directory or filename-pattern exemption
11
+ *
12
+ * The migration left one JavaScript-family file, `src/speech/preload-speech.cjs`: Electron's
13
+ * sandboxed preload loader never strips types and rejects ESM (migration plan Phase 0, probe P2), so
14
+ * a `.ts`/`.cts` preload cannot be loaded directly. That file is now `src/speech/preload-speech.cts`,
15
+ * compiled by `tsconfig.preload.json` to the gitignored `dist/speech/preload-speech.cjs` the same way
16
+ * `src/preload/preload.mts` already was (the migration's rule 1 bars a compile step for the MAIN
17
+ * process, not for a preload). Its allowlist entry is transitional — see `scripts/check-js-backslide.ts`'s
18
+ * `ALLOWLIST`. Naming a file exactly — never "anything under src/speech" or "anything named
19
+ * preload-*" — means a second `.cjs` landing anywhere, including a sibling in the very same
20
+ * directory, still fails the gate instead of riding in on an existing exemption.
21
+ */
22
+ /** Extensions this guard treats as JavaScript-family. Deliberately excludes `.jsx`/`.tsx` — the
23
+ * migration converted the main process, not the renderer's component files, and those are out of
24
+ * this gate's scope. */
25
+ const JS_FAMILY_EXTENSIONS = [".js", ".mjs", ".cjs"];
26
+ /**
27
+ * Every path in `paths` that is a JavaScript-family file and is not named exactly in `allowlist`.
28
+ *
29
+ * @param paths repo-relative file paths to check — the shape `git ls-files -co --exclude-standard`
30
+ * produces, so gitignored build output (`dist/`, `node_modules/`, packaged release output) never
31
+ * reaches this function at all.
32
+ * @param allowlist exact repo-relative paths that may stay JavaScript-family, matched verbatim
33
+ * against the whole path — never a prefix, directory, or filename pattern — so a new offender
34
+ * cannot ride in on an existing exemption's directory or naming shape. Defaults to empty: no
35
+ * implicit exemption exists unless the caller states one.
36
+ * @returns the offending paths, in the order they were given.
37
+ * @complexity O(n * m) in `paths` and `allowlist`; both are single digits in practice (one
38
+ * allowlist entry today), so a `Set` lookup would only trade a trivially cheap linear scan for
39
+ * more code.
40
+ */
41
+ export function jsBackslideOffenders({ paths }, { allowlist = [] } = {}) {
42
+ return paths.filter((path) => JS_FAMILY_EXTENSIONS.some((extension) => path.endsWith(extension)) && !allowlist.includes(path));
43
+ }
44
+ //# sourceMappingURL=js-backslide-guard.js.map
@@ -0,0 +1,34 @@
1
+ import { type NodeToolchainPaths } from "../node-toolchain/index.js";
2
+ export interface NodeToolchainNames {
3
+ /** The `#` comment line written into every POSIX shim. */
4
+ generatedComment: string;
5
+ /** Env name carrying the toolchain directory to the launch resolver. */
6
+ toolchainEnvName: string;
7
+ /** Env name carrying the bundled npm root to the launch resolver. */
8
+ npmRootEnvName: string;
9
+ }
10
+ export interface BuildNodeToolchainShimsInput {
11
+ electronPath: string;
12
+ npmRoot: string;
13
+ platform?: NodeJS.Platform;
14
+ }
15
+ export interface WriteNodeToolchainInput extends BuildNodeToolchainShimsInput {
16
+ userDataDir: string;
17
+ isReadOnlyVolume?: (volumeRoot: string) => boolean;
18
+ }
19
+ export interface BuildNodeToolchainEnvInput {
20
+ toolchainDir: string;
21
+ npmRoot: string;
22
+ }
23
+ export interface BoundNodeToolchain {
24
+ buildNodeToolchainShims(input: BuildNodeToolchainShimsInput): Record<string, string>;
25
+ writeNodeToolchain(input: WriteNodeToolchainInput): NodeToolchainPaths | null;
26
+ buildNodeToolchainEnv(input: BuildNodeToolchainEnvInput): Record<string, string>;
27
+ }
28
+ /**
29
+ * Bind the host's banner and env names to the native filesystem. I/O failures from the writer
30
+ * propagate; it returns `null` for a transient launch. @complexity O(1) to bind.
31
+ */
32
+ export declare function bindNodeToolchain({ generatedComment, toolchainEnvName, npmRootEnvName }: NodeToolchainNames, _optional?: Record<string, never>): BoundNodeToolchain;
33
+ export type { NodeToolchainPaths };
34
+ //# sourceMappingURL=node-toolchain.d.ts.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Node-native binding of `../node-toolchain`: the real filesystem port, `path.join`, this process's
3
+ * pid and the durable-install probes, with the host's generated-launcher banner and its two
4
+ * environment-variable names injected.
5
+ *
6
+ * The `node-toolchain/{bin,npm-cache,npm-prefix}` directory names and the two injected env names are
7
+ * a cross-process contract with the host's stdio MCP launch resolver (`@jini-ai/mcp` federation
8
+ * stdio). Renaming one side can silently fall back to system tooling; these private env names are
9
+ * not forwarded to MCP children.
10
+ */
11
+ import fs from "node:fs";
12
+ import path from "node:path";
13
+ import { buildNodeToolchainEnv as buildEnvironment, buildNodeToolchainShims as buildShims, writeNodeToolchain as writeToolchain, isReadOnlyVolumeRoot, isTransientAppPath, launcherNamesDurableInstall, } from "../node-toolchain/index.js";
14
+ const joinPath = ({ parts }) => path.join(...parts);
15
+ const filesystem = {
16
+ mkdirSync: ({ path }, options = {}) => fs.mkdirSync(path, options),
17
+ chmodSync: ({ path, mode }) => fs.chmodSync(path, mode),
18
+ writeFileSync: ({ path, data }, options = {}) => fs.writeFileSync(path, data, options),
19
+ renameSync: ({ oldPath, newPath }) => fs.renameSync(oldPath, newPath),
20
+ unlinkSync: ({ path }) => fs.unlinkSync(path),
21
+ };
22
+ /**
23
+ * Bind the host's banner and env names to the native filesystem. I/O failures from the writer
24
+ * propagate; it returns `null` for a transient launch. @complexity O(1) to bind.
25
+ */
26
+ export function bindNodeToolchain({ generatedComment, toolchainEnvName, npmRootEnvName }, _optional = {}) {
27
+ return {
28
+ buildNodeToolchainShims: ({ electronPath, npmRoot, platform = process.platform }) => buildShims({ electronPath, npmRoot, platform, generatedComment, joinPath }),
29
+ writeNodeToolchain: ({ userDataDir, electronPath, npmRoot, platform = process.platform, isReadOnlyVolume = (volumeRoot) => isReadOnlyVolumeRoot({ volumeRoot }), }) => {
30
+ const toolchainDir = path.join(userDataDir, "node-toolchain");
31
+ return writeToolchain({
32
+ electronPath, npmRoot, platform, generatedComment, joinPath,
33
+ paths: {
34
+ toolchainDir,
35
+ binDir: path.join(toolchainDir, "bin"),
36
+ npmCacheDir: path.join(toolchainDir, "npm-cache"),
37
+ npmPrefixDir: path.join(toolchainDir, "npm-prefix"),
38
+ },
39
+ filesystem,
40
+ writerPid: process.pid,
41
+ isTransientPath: ({ executablePath }) => isTransientAppPath({ executablePath }, { isReadOnlyVolume }),
42
+ launcherNamesDurableInstall: ({ launcherPath }) => launcherNamesDurableInstall({ launcherPath }, { isReadOnlyVolume }),
43
+ // The node shim names Electron alone in the MCP launcher's exec form, so that same durable-path
44
+ // parser can inspect it; npm/npx also include their CLI script paths and are not the probe target.
45
+ });
46
+ },
47
+ buildNodeToolchainEnv: (input) => buildEnvironment({ ...input, toolchainEnvName, npmRootEnvName }),
48
+ };
49
+ }
50
+ //# sourceMappingURL=node-toolchain.js.map
@@ -0,0 +1,25 @@
1
+ /** Every `spawn-helper` present under a node-pty package dir: the from-source build plus one per
2
+ * prebuild platform. No node-pty dir means none.
3
+ * @complexity O(p) in prebuild directories. */
4
+ export declare function ptyHelperPaths({ ptyDir }: {
5
+ ptyDir: string;
6
+ }): string[];
7
+ /** Whether `mode` lacks any of the user/group/other execute bits. */
8
+ export declare function lacksExecuteBits({ mode }: {
9
+ mode: number;
10
+ }, _options?: {}): boolean;
11
+ /**
12
+ * The packaging-backstop check: in a macOS bundle every `spawn-helper` electron-builder unpacked
13
+ * must be executable, and there must be at least one (node-pty is unpacked whole, electron-builder.yml
14
+ * `asarUnpack`). Other targets are not checked: node-pty's tarball carries the darwin helpers into
15
+ * Windows packages too, Windows cannot hold POSIX modes (`chmod` cannot set them), and conpty never
16
+ * execs spawn-helper.
17
+ *
18
+ * @param required.resourcesDirs - packaged `Resources` dirs (each holds `app.asar` and `app.asar.unpacked`).
19
+ * @returns one line per failure; empty when every dir passes.
20
+ * @complexity O(d * p) for d dirs and p prebuild platforms.
21
+ */
22
+ export declare function packagedPtyHelperFailures({ resourcesDirs }: {
23
+ resourcesDirs: string[];
24
+ }, _options?: {}): string[];
25
+ //# sourceMappingURL=pty-helpers.d.ts.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @file Where node-pty's `spawn-helper`s live and whether they can be executed — one list shared by
3
+ * staging (`ensurePtyHelpersExecutable` sets the bits) and the packaging backstop
4
+ * (`scripts/verify-package.ts` proves the packaged copy kept them).
5
+ *
6
+ * node-pty execs `spawn-helper` to start every terminal; a copy without execute bits fails every
7
+ * terminal with `posix_spawnp failed` (open-bugs 10-31). Plain `node:fs` reads only, so the
8
+ * verifier script can load this file without staging's dependencies.
9
+ */
10
+ import { existsSync, readdirSync, statSync } from "node:fs";
11
+ import path from "node:path";
12
+ /** Every `spawn-helper` present under a node-pty package dir: the from-source build plus one per
13
+ * prebuild platform. No node-pty dir means none.
14
+ * @complexity O(p) in prebuild directories. */
15
+ export function ptyHelperPaths({ ptyDir }) {
16
+ const prebuilds = path.join(ptyDir, "prebuilds");
17
+ const platforms = existsSync(prebuilds) ? readdirSync(prebuilds).sort() : [];
18
+ const helpers = [path.join(ptyDir, "build", "Release", "spawn-helper"), ...platforms.map((dir) => path.join(prebuilds, dir, "spawn-helper"))];
19
+ return helpers.filter((file) => existsSync(file));
20
+ }
21
+ /** Whether `mode` lacks any of the user/group/other execute bits. */
22
+ export function lacksExecuteBits({ mode }, _options = {}) {
23
+ return (mode & 0o111) !== 0o111;
24
+ }
25
+ /**
26
+ * The packaging-backstop check: in a macOS bundle every `spawn-helper` electron-builder unpacked
27
+ * must be executable, and there must be at least one (node-pty is unpacked whole, electron-builder.yml
28
+ * `asarUnpack`). Other targets are not checked: node-pty's tarball carries the darwin helpers into
29
+ * Windows packages too, Windows cannot hold POSIX modes (`chmod` cannot set them), and conpty never
30
+ * execs spawn-helper.
31
+ *
32
+ * @param required.resourcesDirs - packaged `Resources` dirs (each holds `app.asar` and `app.asar.unpacked`).
33
+ * @returns one line per failure; empty when every dir passes.
34
+ * @complexity O(d * p) for d dirs and p prebuild platforms.
35
+ */
36
+ export function packagedPtyHelperFailures({ resourcesDirs }, _options = {}) {
37
+ return resourcesDirs.flatMap((dir) => {
38
+ if (!dir.endsWith(path.join("Contents", "Resources")))
39
+ return [];
40
+ const ptyDir = path.join(dir, "app.asar.unpacked", "node_modules", "node-pty");
41
+ const helpers = ptyHelperPaths({ ptyDir });
42
+ if (helpers.length === 0)
43
+ return [`no node-pty spawn-helper under ${ptyDir}`];
44
+ return helpers.flatMap((file) => {
45
+ const mode = statSync(file).mode;
46
+ return lacksExecuteBits({ mode }) ? [`${file} (mode ${(mode & 0o777).toString(8)})`] : [];
47
+ });
48
+ });
49
+ }
50
+ //# sourceMappingURL=pty-helpers.js.map
@@ -0,0 +1,32 @@
1
+ export interface PresenceSender {
2
+ isDestroyed(): boolean;
3
+ once(name: 'destroyed' | 'render-process-gone', listener: () => void): unknown;
4
+ removeListener(name: 'destroyed' | 'render-process-gone', listener: () => void): unknown;
5
+ }
6
+ /** The maintenance owner can query presence without learning about renderer senders. */
7
+ export interface SitePresence<Sender extends PresenceSender = PresenceSender> {
8
+ replace(input: {
9
+ sender: Sender;
10
+ siteIds: unknown;
11
+ }, options?: {}): void;
12
+ has(input: {
13
+ siteId: string;
14
+ }, options?: {}): boolean;
15
+ dispose(): void;
16
+ }
17
+ /** Retain complete lists per shell, never per loaded guest. Invalid updates reject atomically.
18
+ * Sender loss removes only that sender's claim, so another window can keep the same site present.
19
+ * @returns Replace/query/dispose operations; each sender owns one pair of cleanup listeners.
20
+ * @complexity Replacement O(t + n), where t is tracked sites and n is reported ids; lookup O(s)
21
+ * for s shells. Stored claims are bounded by tracked sites per live sender. No per-id I/O.
22
+ */
23
+ export declare function createSitePresence<Sender extends PresenceSender>({ allowed, trackedIds }: {
24
+ allowed: (sender: Sender) => boolean;
25
+ trackedIds: () => ReadonlySet<string>;
26
+ }, { hasSiteWindow, onRelease }?: {
27
+ hasSiteWindow?: (required: {
28
+ siteId: string;
29
+ }, options?: {}) => boolean;
30
+ onRelease?: () => void;
31
+ }): SitePresence<Sender>;
32
+ //# sourceMappingURL=site-presence.d.ts.map
@@ -0,0 +1,42 @@
1
+ /** Retain complete lists per shell, never per loaded guest. Invalid updates reject atomically.
2
+ * Sender loss removes only that sender's claim, so another window can keep the same site present.
3
+ * @returns Replace/query/dispose operations; each sender owns one pair of cleanup listeners.
4
+ * @complexity Replacement O(t + n), where t is tracked sites and n is reported ids; lookup O(s)
5
+ * for s shells. Stored claims are bounded by tracked sites per live sender. No per-id I/O.
6
+ */
7
+ export function createSitePresence({ allowed, trackedIds }, { hasSiteWindow = () => false, onRelease = () => { } } = {}) {
8
+ const owners = new Map();
9
+ const release = (sender) => {
10
+ const owner = owners.get(sender);
11
+ if (!owner)
12
+ return;
13
+ onRelease();
14
+ owners.delete(sender);
15
+ sender.removeListener('destroyed', owner.release);
16
+ sender.removeListener('render-process-gone', owner.release);
17
+ };
18
+ const replace = ({ sender, siteIds }) => {
19
+ if (sender.isDestroyed() || !allowed(sender))
20
+ throw new Error('UNTRUSTED_SITE_PRESENCE_SENDER');
21
+ const tracked = trackedIds();
22
+ if (!Array.isArray(siteIds) || !siteIds.every(id => typeof id === 'string' && tracked.has(id)))
23
+ throw new Error('INVALID_SITE_PRESENCE');
24
+ const ids = new Set(siteIds);
25
+ const owner = owners.get(sender);
26
+ if (owner) {
27
+ owner.siteIds = ids;
28
+ return;
29
+ }
30
+ const created = { siteIds: ids, release: () => release(sender) };
31
+ owners.set(sender, created);
32
+ sender.once('destroyed', created.release);
33
+ sender.once('render-process-gone', created.release);
34
+ };
35
+ return {
36
+ replace,
37
+ has: ({ siteId }) => hasSiteWindow({ siteId }) || [...owners.values()].some(owner => owner.siteIds.has(siteId)),
38
+ dispose: () => { for (const sender of owners.keys())
39
+ release(sender); },
40
+ };
41
+ }
42
+ //# sourceMappingURL=site-presence.js.map
@@ -0,0 +1,24 @@
1
+ import { type MacTranscriberDeps, type MacTranscriberMessages } from "../../speech/macos/index.js";
2
+ import type { TranscriptionPort } from "../../speech/index.js";
3
+ export interface NativeMacTranscriberConfig {
4
+ /** Where the compiled helper is cached; a separate cache per helper protocol version. */
5
+ binaryPath: string;
6
+ messages: MacTranscriberMessages;
7
+ /** Basename prefix of each temporary WAV under `os.tmpdir()`, before a random UUID. */
8
+ tempFilePrefix: string;
9
+ }
10
+ /**
11
+ * Resolve the published Swift asset only when macOS speech is constructed: the same file the
12
+ * `./speech/macos/speech-helper.swift` export names (the build copies it beside `speech/macos`).
13
+ * @complexity O(1).
14
+ */
15
+ export declare function speechHelperSourcePath(_requiredArgs: Record<string, never>, _optional?: Record<string, never>): string;
16
+ /**
17
+ * Construct on-device recognition with host policy and optional injected ports.
18
+ * Keep realDependencies separate so a caller can override only the few ports it needs
19
+ * while every omitted dependency still follows the production path. Call only on darwin;
20
+ * resolveTranscriptionPort decides platform eligibility before reaching this factory.
21
+ * @complexity O(1) to construct; native compilation/recognition happens only when used.
22
+ */
23
+ export declare function createNativeMacTranscriptionPort(config: NativeMacTranscriberConfig, overrides?: Partial<MacTranscriberDeps>): TranscriptionPort;
24
+ //# sourceMappingURL=mac-on-device-transcriber.d.ts.map
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Node-native binding of `../../speech/macos`'s on-device recognizer: the real `fs`,
3
+ * `execFile`, temp-file naming and the published Swift helper source, with the host's helper binary
4
+ * path, error wording and temp-file prefix injected.
5
+ *
6
+ * **Zero downloaded model data.** The helper links `Speech`/`SFSpeechRecognizer` against the
7
+ * speech models macOS ships with the OS; nothing is fetched at install or first run. whisper.cpp
8
+ * was rejected for its ~75MB model download — this path adds none.
9
+ *
10
+ * **No silent network fallback.** Every request the helper builds sets
11
+ * `requiresOnDeviceRecognition = true` (`speech/macos/speech-helper.swift`). If on-device assets are
12
+ * not installed for the recognizer's locale, `SFSpeechRecognizer` does not silently use the network
13
+ * instead — it fails the request, and this module surfaces that failure as `available: false` / a
14
+ * rejected `transcribe()` rather than papering over it. Silently transcribing over the network would
15
+ * defeat the entire point (a local-first host; browser speech recognition uploads audio to a
16
+ * vendor's servers) and the caller would have no way to know it happened, so "on-device
17
+ * unavailable" is a reportable stop condition, never a fallback trigger.
18
+ *
19
+ * Helper spike history: synthesized speech first proved this subprocess approach. Its initial
20
+ * semaphore-based CLI starved the main queue's XPC callbacks and timed out on every run at the
21
+ * 30s ceiling; the Swift helper pumps the run loop instead. Keep its 15s authorization and
22
+ * 30s recognition budgets, and never replace the loop with a blocking main-thread semaphore.
23
+ *
24
+ * The compiled helper binary is never committed — the recognizer lazily runs `swiftc` against the
25
+ * source the first time it is needed and caches the binary at the host's `binaryPath`. A machine
26
+ * with no `swiftc` simply reports `unavailable` instead of failing to install.
27
+ *
28
+ * Wiring: the host injects `binaryPath` (computed in the host exactly where its cache has always
29
+ * lived; moving this module must not move that cache), `messages` and `tempFilePrefix`.
30
+ */
31
+ import path from "node:path";
32
+ import os from "node:os";
33
+ import crypto from "node:crypto";
34
+ import { createRequire } from "node:module";
35
+ import { fileURLToPath } from "node:url";
36
+ import { createMacOnDeviceTranscriptionPort as createMacPort, } from "../../speech/macos/index.js";
37
+ // ESM has no synchronous import; createRequire preserves lazy loading of the native Node adapters.
38
+ const require = createRequire(import.meta.url);
39
+ /**
40
+ * Resolve the published Swift asset only when macOS speech is constructed: the same file the
41
+ * `./speech/macos/speech-helper.swift` export names (the build copies it beside `speech/macos`).
42
+ * @complexity O(1).
43
+ */
44
+ export function speechHelperSourcePath(_requiredArgs, _optional = {}) {
45
+ return fileURLToPath(new URL("../../speech/macos/speech-helper.swift", import.meta.url));
46
+ }
47
+ /** Bind Node's native signatures without running recognition. @complexity O(1). */
48
+ function realDependencies({ binaryPath, sourcePath, messages, tempFilePrefix }) {
49
+ // Requiring inside the factory keeps non-macOS hosts from loading the process/promisify
50
+ // adapters at module import; resolveTranscriptionPort selects platform eligibility first.
51
+ const { execFile } = require("node:child_process");
52
+ const { promisify } = require("node:util");
53
+ const fs = require("node:fs");
54
+ const execFileAsync = promisify(execFile);
55
+ return {
56
+ fs: {
57
+ existsSync: ({ path }) => fs.existsSync(path),
58
+ mkdirSync: ({ path }, { recursive = false } = {}) => fs.mkdirSync(path, { recursive }),
59
+ writeFileSync: ({ path, data }) => fs.writeFileSync(path, data),
60
+ rmSync: ({ path }, { force = false } = {}) => fs.rmSync(path, { force }),
61
+ },
62
+ // No `spawnSync` adapter: the helper is compiled through `execFileAsync`, and the deps'
63
+ // `spawnSync` is deprecated and never called.
64
+ execFileAsync: ({ file, args }) => execFileAsync(file, args),
65
+ sourcePath, binaryPath, compilerPath: "swiftc", locale: "en-US", messages,
66
+ tempFilePath: () => path.join(os.tmpdir(), `${tempFilePrefix}${crypto.randomUUID()}.wav`),
67
+ };
68
+ }
69
+ /**
70
+ * Construct on-device recognition with host policy and optional injected ports.
71
+ * Keep realDependencies separate so a caller can override only the few ports it needs
72
+ * while every omitted dependency still follows the production path. Call only on darwin;
73
+ * resolveTranscriptionPort decides platform eligibility before reaching this factory.
74
+ * @complexity O(1) to construct; native compilation/recognition happens only when used.
75
+ */
76
+ export function createNativeMacTranscriptionPort(config, overrides = {}) {
77
+ const sourcePath = overrides.sourcePath ?? speechHelperSourcePath({});
78
+ const binaryPath = overrides.binaryPath ?? config.binaryPath;
79
+ return createMacPort({ ...realDependencies({ ...config, sourcePath, binaryPath }), ...overrides });
80
+ }
81
+ //# sourceMappingURL=mac-on-device-transcriber.js.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Electron-native binding of `../../speech`'s IPC handlers: adapts Electron's positional
3
+ * `ipcMain.handle(channel, (event, samples, sampleRate) => …)` to the package's object-argument
4
+ * port and lazily builds the default transcription port (macOS on-device, else unavailable).
5
+ * This is the one module that knows both "there is an Electron IPC channel" and "there is a
6
+ * transcription port"; it has no recognition logic of its own.
7
+ *
8
+ * **Every call is validated before it costs anything.** The channels are reachable from every page
9
+ * that runs a preload exposing the host's voice bridge — a site's admin AND its public pages, and
10
+ * the host's home window. So the sender's page is checked first, then the sample rate, then the
11
+ * samples' type and length, all before a single sample is copied. `samples` arrives by structured
12
+ * clone, so `{ length: 2_000_000_000 }` crosses IPC in a few bytes; a naive
13
+ * `Float32Array.from(samples)` then allocated 8 GB in the main process.
14
+ *
15
+ * Wiring: the host injects its IPC `channelNamespace` (shared with its preload bridge), all error
16
+ * wording, and the macOS recognizer config; register once before any window opens.
17
+ */
18
+ import { MAX_TRANSCRIBE_SAMPLES, type SpeechIpcEvent, type SpeechIpcMessages, type TranscriptionMessages, type TranscriptionPort } from "../../speech/index.js";
19
+ import type { MacTranscriberDeps } from "../../speech/macos/index.js";
20
+ import { type NativeMacTranscriberConfig } from "./mac-on-device-transcriber.js";
21
+ export { MAX_TRANSCRIBE_SAMPLES };
22
+ /** Everything product-specific about the speech feature, owned by the host. */
23
+ export interface NativeSpeechHost {
24
+ channelNamespace: string;
25
+ messages: SpeechIpcMessages;
26
+ transcriptionMessages: TranscriptionMessages;
27
+ mac: NativeMacTranscriberConfig;
28
+ }
29
+ /** The slice of Electron's `ipcMain` used here, positional as Electron declares it. */
30
+ export interface NativeSpeechIpcMain {
31
+ handle(channel: string, listener: (event: SpeechIpcEvent, ...args: unknown[]) => unknown): void;
32
+ removeHandler?(channel: string): void;
33
+ }
34
+ /** Resolve a lazy host transcription port. @complexity O(1). */
35
+ export declare function buildDefaultTranscriptionPort({ platform, host }: {
36
+ platform: string;
37
+ host: Pick<NativeSpeechHost, "transcriptionMessages" | "mac">;
38
+ }, overrides?: Partial<MacTranscriberDeps>): TranscriptionPort;
39
+ /** Adapt native IPC without changing the renderer's positional payloads. @complexity O(1) to register; O(n) per recording. */
40
+ export declare function registerNativeSpeechIpc({ ipcMain, isTrustedSender, host }: {
41
+ ipcMain: NativeSpeechIpcMain;
42
+ isTrustedSender: (required: {
43
+ senderUrl: string;
44
+ }) => boolean;
45
+ host: NativeSpeechHost;
46
+ }, { port, maxSamples, platform }?: {
47
+ port?: TranscriptionPort;
48
+ maxSamples?: number;
49
+ /** Which platform's default port to build when `port` is omitted; defaults to this process's. */
50
+ platform?: string;
51
+ }): () => void;
52
+ //# sourceMappingURL=speech-ipc.d.ts.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Electron-native binding of `../../speech`'s IPC handlers: adapts Electron's positional
3
+ * `ipcMain.handle(channel, (event, samples, sampleRate) => …)` to the package's object-argument
4
+ * port and lazily builds the default transcription port (macOS on-device, else unavailable).
5
+ * This is the one module that knows both "there is an Electron IPC channel" and "there is a
6
+ * transcription port"; it has no recognition logic of its own.
7
+ *
8
+ * **Every call is validated before it costs anything.** The channels are reachable from every page
9
+ * that runs a preload exposing the host's voice bridge — a site's admin AND its public pages, and
10
+ * the host's home window. So the sender's page is checked first, then the sample rate, then the
11
+ * samples' type and length, all before a single sample is copied. `samples` arrives by structured
12
+ * clone, so `{ length: 2_000_000_000 }` crosses IPC in a few bytes; a naive
13
+ * `Float32Array.from(samples)` then allocated 8 GB in the main process.
14
+ *
15
+ * Wiring: the host injects its IPC `channelNamespace` (shared with its preload bridge), all error
16
+ * wording, and the macOS recognizer config; register once before any window opens.
17
+ */
18
+ import { registerSpeechIpc as registerIpc, resolveTranscriptionPort, MAX_TRANSCRIBE_SAMPLES, } from "../../speech/index.js";
19
+ import { createNativeMacTranscriptionPort } from "./mac-on-device-transcriber.js";
20
+ export { MAX_TRANSCRIBE_SAMPLES };
21
+ /** Resolve a lazy host transcription port. @complexity O(1). */
22
+ export function buildDefaultTranscriptionPort({ platform, host }, overrides = {}) {
23
+ return resolveTranscriptionPort({ platform, messages: host.transcriptionMessages, createMacPort: () => createNativeMacTranscriptionPort(host.mac, overrides) });
24
+ }
25
+ /** Adapt native IPC without changing the renderer's positional payloads. @complexity O(1) to register; O(n) per recording. */
26
+ export function registerNativeSpeechIpc({ ipcMain, isTrustedSender, host }, { port, maxSamples = MAX_TRANSCRIBE_SAMPLES, platform = process.platform } = {}) {
27
+ // Fail before constructing native dependencies when the host forgot its sender policy.
28
+ if (typeof isTrustedSender !== "function")
29
+ throw new Error(host.messages.missingSenderGuard);
30
+ return registerIpc({
31
+ channelNamespace: host.channelNamespace, messages: host.messages,
32
+ port: port ?? buildDefaultTranscriptionPort({ platform, host }),
33
+ isTrustedSender,
34
+ ipcMain: {
35
+ handle: ({ channel, handler }) => ipcMain.handle(channel, (event, samples, sampleRate) => handler({ event, samples, sampleRate })),
36
+ removeHandler: ({ channel }) => ipcMain.removeHandler?.(channel),
37
+ },
38
+ }, { maxSamples });
39
+ }
40
+ //# sourceMappingURL=speech-ipc.js.map
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @file The right-click spelling-suggestions menu — Electron shows NO native context menu of its
3
+ * own on any `webContents` (unlike a real browser tab), so without this, right-clicking a
4
+ * misspelled word in an editing surface does nothing at all.
5
+ *
6
+ * Registered against two different `webContents`, both from `main.ts`'s `openSitesHomeWindow`: the
7
+ * sites home window's own top-level page (its few text fields — site names, search), and every
8
+ * project tab's `<webview>` guest (via `did-attach-webview`, which is where the real prose lives —
9
+ * the embedded site admin's `FormEditor` and page content). `spellcheck` itself needs no separate
10
+ * enable step: Electron's own `webPreferences` default (`spellcheck: true`) already covers both,
11
+ * and nothing in `webview-guest-policy.ts` overrides it. This file only builds the menu Chromium's
12
+ * `context-menu` event hands the ingredients for but never shows on its own.
13
+ *
14
+ * `buildSpellCheckMenuTemplate` is the whole decision, kept separate from
15
+ * {@link registerSpellCheckContextMenu} for the same reason `find-menu.ts`'s `sendFindToggle` is
16
+ * split from `findMenu`: a plain function is what `spellcheck-menu.test.ts` can call directly,
17
+ * without a real Electron `Menu` or `webContents` to drive it.
18
+ *
19
+ * ## Wiring
20
+ * The host supplies the menu wording as `labels` (`SpellCheckLabels`) and Electron's `Menu` as
21
+ * `menuBuilder` on each call's required object; this module authors no copy and imports no Electron.
22
+ *
23
+ * No runtime `electron` import at module scope — the real `Menu` is an explicit injected port,
24
+ * so this stays testable under plain `node --test` the same way
25
+ * `find-in-page-ipc.ts` keeps `BrowserWindow` at arm's length.
26
+ */
27
+ import { type SpellCheckContextMenuParams, type SpellCheckLabels, type MenuItemConstructorOptions as SpellCheckMenuItem } from "../electron/usability/index.js";
28
+ export type { SpellCheckContextMenuParams } from "../electron/usability/index.js";
29
+ export interface SpellCheckMenuHandlers {
30
+ replace(required: {
31
+ word: string;
32
+ }): void;
33
+ addToDictionary(required: {
34
+ word: string;
35
+ }): void;
36
+ cut(): void;
37
+ copy(): void;
38
+ paste(): void;
39
+ selectAll(): void;
40
+ }
41
+ /**
42
+ * Build spelling suggestions followed by enabled edit commands with the host-supplied `labels`. Five matches
43
+ * Chrome's cap: further alternatives add noise. An empty result means no popup, not an empty menu.
44
+ * @complexity O(k) in suggestions, capped at five.
45
+ */
46
+ export declare function buildSpellCheckMenuTemplate({ labels, params, handlers }: {
47
+ labels: SpellCheckLabels;
48
+ params: SpellCheckContextMenuParams;
49
+ handlers: SpellCheckMenuHandlers;
50
+ }): SpellCheckMenuItem[];
51
+ /** The slice of a `webContents` {@link registerSpellCheckContextMenu} drives — real or faked in
52
+ * tests. `replaceMisspelling`/`cut`/`copy`/`paste`/`selectAll` are Electron's own `WebContents`
53
+ * methods; `session.addWordToSpellCheckerDictionary` is scoped to THIS contents' own session, which
54
+ * is what makes a guest's dictionary additions follow that project's own partition. */
55
+ export interface SpellCheckWebContents {
56
+ on(event: "context-menu", listener: (event: unknown, params: SpellCheckContextMenuParams) => void): unknown;
57
+ removeListener?(event: "context-menu", listener: (event: unknown, params: SpellCheckContextMenuParams) => void): unknown;
58
+ replaceMisspelling(text: string): void;
59
+ cut(): void;
60
+ copy(): void;
61
+ paste(): void;
62
+ selectAll(): void;
63
+ session: {
64
+ addWordToSpellCheckerDictionary(word: string): void;
65
+ };
66
+ }
67
+ /** Native Menu builder supplied by the host composition or its test double. */
68
+ export interface MenuBuilder {
69
+ buildFromTemplate(template: SpellCheckMenuItem[]): {
70
+ popup(): void;
71
+ };
72
+ }
73
+ /**
74
+ * Register spelling for one native session; return a matching listener disposer. Menu is required
75
+ * because main already owns Electron's Menu: a module-level default adds no capability and would
76
+ * load a native runtime in plain Node tests. A click with no spelling/edit actions shows no popup.
77
+ * @complexity O(1) to register; each popup is capped at five suggestions.
78
+ */
79
+ export declare function registerSpellCheckContextMenu({ labels, webContents, menuBuilder }: {
80
+ labels: SpellCheckLabels;
81
+ webContents: SpellCheckWebContents;
82
+ menuBuilder: MenuBuilder;
83
+ }): () => void;
84
+ //# sourceMappingURL=spellcheck-menu.d.ts.map