@cmdless/ui-runtime 0.0.0 → 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cmdless
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,22 @@
1
1
  # @cmdless/ui-runtime
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ The actual Electron app behind cmdless UI. It's an Electron app without a renderer of its own — the caller provides one (a URL or a file) if they need it.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ Normally you don't run this directly; [`@cmdless/ui`](../ui) caches and forwards to it. It's a separate package because the two have very different dependencies: `@cmdless/ui` is a plain Node CLI, while this one needs Electron itself.
6
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ ## Commands
8
8
 
9
- ## Purpose
9
+ - `show <url|file> <source>` — open a `BrowserWindow` loading a URL or a local file.
10
+ - `message-box <type> <message>` — show a native message box.
10
11
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@cmdless/ui-runtime`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
12
+ Both accept `--app <name>` to group windows/dialogs under one Electron app identity — matching names share a `userData` profile and are single-instanced; omitting it creates a throwaway, self-cleaning ephemeral session for that one invocation.
15
13
 
16
- ## What is OIDC Trusted Publishing?
14
+ ## MCP mediation
17
15
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
16
+ A hosted window's renderer can ask main for any package's MCP server address (`cmdlessIPC`'s `mcpAddress` request, from a `createClient` facade in [`@cmdless/ui-sdk/browser`](../../packages/ui-sdk)) — main resolves and spawns it via `runAsMcp`. This app never runs any package's own `createApp` in-process (that lives in the package's own bin process, the one that invoked `createShowCommand`), so every request, including a package asking for its own tools, resolves the same way.
19
17
 
20
- ## Setup Instructions
18
+ Instances are cached per window tree, not globally: a request walks up from the requesting window through its ancestors (Electron's own `--parent` chain) looking for an existing instance of that package; if none exists anywhere up the chain, the requesting window opens one itself and owns it. Sibling windows sharing a parent therefore reuse one instance by default, but two unrelated top-level windows never do - and closing the window that owns an instance disposes it immediately, rather than it lingering until the whole app quits.
21
19
 
22
- To properly configure OIDC trusted publishing for this package:
20
+ ## How it resolves
23
21
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
22
+ Each invocation resolves to a single value (whatever the window or dialog produced) and exits. The wrapper CLI (`bin.ts`) talks to the actual Electron process over a `BinChannel` (a small local-socket protocol from [`@cmdless/ui-sdk/node`](../../packages/ui-sdk)) — not stdout, and deliberately not Node's `child_process` `'ipc'` stdio channel either. `'ipc'` is a documented source of `app.whenReady()` hangs when combined with Electron ([electron/electron#17044](https://github.com/electron/electron/issues/17044)); a plain socket avoids that while still keeping anything Electron itself logs out of the value being returned.
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { spawn } from "node:child_process";
6
+ import { ensureElectron } from "@cmdless/ensure-electron";
7
+ import { binOutput, BinChannel } from "@cmdless/ui-sdk/node";
8
+ import __cjs_mod__ from "node:module";
9
+ const __filename = import.meta.filename;
10
+ const __dirname = import.meta.dirname;
11
+ const require2 = __cjs_mod__.createRequire(import.meta.url);
12
+ function wireChild(write, rm) {
13
+ let cleanup;
14
+ return {
15
+ onMessage: (message) => {
16
+ if (message.type === "cleanup") {
17
+ cleanup = message;
18
+ return;
19
+ }
20
+ if (message.value !== null)
21
+ write(binOutput(message.value));
22
+ },
23
+ onExit: (code) => {
24
+ if (cleanup)
25
+ rm(cleanup.userData);
26
+ process.exitCode = code ?? 1;
27
+ }
28
+ };
29
+ }
30
+ const devDependencies = { "electron": "43.3.0" };
31
+ const pkg = {
32
+ devDependencies
33
+ };
34
+ const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
35
+ const mainEntry = path.join(__dirname$1, "index.js");
36
+ const electronVersion = pkg.devDependencies.electron;
37
+ const execPath = await ensureElectron({ meta: import.meta, electronVersion, rebuild: true });
38
+ const { onMessage, onExit } = wireChild(
39
+ (text) => process.stdout.write(text),
40
+ (userData) => fs.rmSync(userData, { recursive: true, force: true })
41
+ );
42
+ const channel = await BinChannel.start(onMessage);
43
+ const child = spawn(execPath, [mainEntry, ...process.argv.slice(2)], {
44
+ stdio: ["inherit", "pipe", "inherit"],
45
+ env: channel.env
46
+ });
47
+ child.stdout?.pipe(process.stderr);
48
+ child.once("exit", onExit);
49
+ const forwardSignal = (signal) => child.kill(signal);
50
+ process.on("SIGINT", forwardSignal);
51
+ process.on("SIGTERM", forwardSignal);
52
+ child.once("exit", () => {
53
+ process.off("SIGINT", forwardSignal);
54
+ process.off("SIGTERM", forwardSignal);
55
+ channel.close().catch(() => {
56
+ });
57
+ });