@workflow/web 5.0.0-beta.8 → 5.0.0

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 (49) hide show
  1. package/README.md +1 -0
  2. package/build/client/assets/app-BIKwaF7E.css +1 -0
  3. package/build/client/assets/arrow-up-right-jHPcOZmb.js +15 -0
  4. package/build/client/assets/{entry.client-DtOpLtMQ.js → entry.client-DmlDFlyx.js} +25 -185
  5. package/build/client/assets/{highlighted-body-B3W2YXNL-WHMd9MPa.js → highlighted-body-B3W2YXNL-CBBI0JQ-.js} +2 -2
  6. package/build/client/assets/{home-Cai0GqMt.js → home-BcIEUw9E.js} +1791 -291
  7. package/build/client/assets/index-HqNj_XIX.js +200 -0
  8. package/build/client/assets/{index-BsV8i_Jn.js → index-thGVuYbY.js} +19 -19
  9. package/build/client/assets/loader-circle-HeezuKOU.js +12 -0
  10. package/build/client/assets/manifest-a541ae9e.js +1 -0
  11. package/build/client/assets/{mermaid-3ZIDBTTL-TNUP6Q3m.js → mermaid-3ZIDBTTL-ClcCzUqi.js} +17543 -12877
  12. package/build/client/assets/mermaid-3ZIDBTTL-D8CjRQta.css +1 -0
  13. package/build/client/assets/{root-ORTTXEp6.js → root-DLS5V7HU.js} +17 -42
  14. package/build/client/assets/root-grl25rxS.css +1 -0
  15. package/build/client/assets/run-detail-CWoGxu_0.css +1 -0
  16. package/build/client/assets/{run-detail-DNZJxxPM.js → run-detail-DWoMKBqC.js} +3052 -2437
  17. package/build/client/assets/{workflow-graph-viewer-DKqOOMnz.js → workflow-graph-viewer-syfKq6DB.js} +5143 -5261
  18. package/build/client/assets/zstd-B5R2yJjB.wasm +0 -0
  19. package/build/client/assets/zstd-browser-decoder-D2p6f8lN.js +27 -0
  20. package/build/server/assets/{server-build-fc5Vuxba.js → app-CLF3fhv7.js} +102500 -73253
  21. package/build/server/assets/{highlighted-body-B3W2YXNL-BuIiME1D.js → highlighted-body-B3W2YXNL-D21NaJQ0.js} +22 -9
  22. package/build/server/assets/index-BfLBLRRi.js +204 -0
  23. package/build/server/assets/index-CETb4fkq.js +1164 -0
  24. package/build/server/assets/index-DnTW8Yiv.js +1262 -0
  25. package/build/server/assets/index-y9xp70jn.js +184 -0
  26. package/build/server/assets/{mermaid-3ZIDBTTL-TSh7T1Pv.js → mermaid-3ZIDBTTL-DlUUmZjL.js} +22 -9
  27. package/build/server/assets/{token--89oCxEK.js → token-DXiZgST4.js} +5 -2
  28. package/build/server/assets/{token-util-N0DDbkKZ.js → token-util-BvEnPXwK.js} +5 -2
  29. package/build/server/assets/wrapper-BsMfBV09.js +67 -0
  30. package/build/server/assets/zstd-browser-decoder-d2YJZBik.js +77 -0
  31. package/build/server/index.js +55 -3
  32. package/handler.d.ts +22 -0
  33. package/handler.js +103 -0
  34. package/package.json +28 -15
  35. package/registry.d.ts +29 -0
  36. package/registry.js +89 -0
  37. package/server.d.ts +5 -1
  38. package/server.js +32 -39
  39. package/static.js +86 -0
  40. package/build/client/assets/encryption-C69WMRfh.js +0 -34
  41. package/build/client/assets/index-Byi8AWfe.js +0 -280
  42. package/build/client/assets/manifest-127f70fe.js +0 -1
  43. package/build/client/assets/mermaid-3ZIDBTTL-DKxHcEOp.css +0 -1
  44. package/build/client/assets/root-COvK3yNk.css +0 -1
  45. package/build/client/assets/server-build-DzzvWTSG.css +0 -1
  46. package/build/client/assets/worker-CqHKTA7D.js +0 -115
  47. package/build/server/assets/app-BxqFvIap.js +0 -9213
  48. package/build/server/assets/index-CdMzuwNr.js +0 -89
  49. package/build/server/assets/index-meg9qk8y.js +0 -1282
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "@workflow/web",
3
3
  "description": "Workflow Observability UI",
4
- "version": "5.0.0-beta.8",
4
+ "version": "5.0.0",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [
8
8
  "build",
9
9
  "server.js",
10
10
  "server.d.ts",
11
+ "handler.js",
12
+ "handler.d.ts",
13
+ "registry.js",
14
+ "registry.d.ts",
15
+ "static.js",
11
16
  "package.json"
12
17
  ],
13
18
  "exports": {
@@ -15,6 +20,14 @@
15
20
  "types": "./server.d.ts",
16
21
  "default": "./server.js"
17
22
  },
23
+ "./handler": {
24
+ "types": "./handler.d.ts",
25
+ "default": "./handler.js"
26
+ },
27
+ "./registry": {
28
+ "types": "./registry.d.ts",
29
+ "default": "./registry.js"
30
+ },
18
31
  "./package.json": "./package.json"
19
32
  },
20
33
  "publishConfig": {
@@ -27,10 +40,11 @@
27
40
  "directory": "packages/web"
28
41
  },
29
42
  "dependencies": {
30
- "express": "^4.21.0"
43
+ "@workflow/world-local": "5.0.0",
44
+ "srvx": "^0.12.4",
45
+ "swr": "^2.3.6"
31
46
  },
32
47
  "devDependencies": {
33
- "@testing-library/react": "^16.3.0",
34
48
  "@biomejs/biome": "^2.4.4",
35
49
  "@radix-ui/react-alert-dialog": "1.1.5",
36
50
  "@radix-ui/react-checkbox": "1.1.4",
@@ -43,14 +57,19 @@
43
57
  "@radix-ui/react-tabs": "^1.1.13",
44
58
  "@radix-ui/react-tooltip": "1.2.8",
45
59
  "@react-router/dev": "7.13.1",
46
- "@react-router/express": "7.13.1",
47
60
  "@react-router/node": "7.13.1",
48
- "@vercel/react-router": "1.2.6",
49
61
  "@tailwindcss/vite": "4",
50
- "@types/express": "^5",
62
+ "@testing-library/react": "^16.3.0",
51
63
  "@types/node": "22.19.0",
52
64
  "@types/react": "19",
53
65
  "@types/react-dom": "19",
66
+ "@vercel/react-router": "1.2.6",
67
+ "@workflow/core": "5.0.0",
68
+ "@workflow/errors": "5.0.0",
69
+ "@workflow/utils": "5.0.0",
70
+ "@workflow/web-shared": "5.0.0",
71
+ "@workflow/world": "5.0.0",
72
+ "@workflow/world-vercel": "5.0.0",
54
73
  "@xyflow/react": "12.10.1",
55
74
  "cbor-x": "^1",
56
75
  "class-variance-authority": "0.7.1",
@@ -59,6 +78,7 @@
59
78
  "date-fns": "4.1.0",
60
79
  "geist": "^1.7.0",
61
80
  "isbot": "^5",
81
+ "jsdom": "^26",
62
82
  "lucide-react": "0.575.0",
63
83
  "next-themes": "0.4.6",
64
84
  "react": "19.1.0",
@@ -68,16 +88,9 @@
68
88
  "sonner": "2.0.7",
69
89
  "tailwind-merge": "3.5.0",
70
90
  "tailwindcss": "4",
71
- "typescript": "^5.9.3",
91
+ "typescript": "^6.0.3",
72
92
  "vite": "^6",
73
- "vitest": "^3",
74
- "jsdom": "^26",
75
- "@workflow/core": "5.0.0-beta.8",
76
- "@workflow/errors": "5.0.0-beta.5",
77
- "@workflow/utils": "5.0.0-beta.3",
78
- "@workflow/web-shared": "5.0.0-beta.8",
79
- "@workflow/world": "5.0.0-beta.5",
80
- "@workflow/world-vercel": "5.0.0-beta.7"
93
+ "vitest": "^3.2.7"
81
94
  },
82
95
  "scripts": {
83
96
  "dev": "react-router dev",
package/registry.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ /** A recorded embedded-dashboard instance. */
2
+ export interface DashboardRegistryEntry {
3
+ /** Public base URL the dashboard is reachable at (e.g. `http://localhost:3000/_workflow`). */
4
+ url: string;
5
+ /** Mount path the dashboard is served under (e.g. `/_workflow`; `""` at root). */
6
+ basename: string;
7
+ /** World backend identifier, for display (e.g. `local`, `@workflow/world-postgres`). */
8
+ world: string;
9
+ /** PID of the process hosting the dashboard. */
10
+ pid: number;
11
+ /** ISO timestamp the entry was recorded. */
12
+ startedAt: string;
13
+ }
14
+
15
+ /** Absolute path of the registry file for the current working directory. */
16
+ export function dashboardRegistryPath(): string;
17
+
18
+ /** Read the registry entries (always returns an array; never throws). */
19
+ export function readDashboardRegistry(): DashboardRegistryEntry[];
20
+
21
+ /**
22
+ * Record this process's embedded dashboard (idempotent per process). Entirely
23
+ * best-effort — never throws.
24
+ */
25
+ export function recordDashboard(entry: {
26
+ url: string;
27
+ basename?: string;
28
+ world?: string;
29
+ }): void;
package/registry.js ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Best-effort registry of live, embedded observability dashboards.
3
+ *
4
+ * When the dashboard is embedded in another server (e.g. `@workflow/nitro` at
5
+ * `/_workflow`), the running process records its public URL here. The CLI
6
+ * (`workflow web` / `inspect … --web`) reads this so it can point the user at
7
+ * an already-running dashboard instead of spawning a redundant standalone
8
+ * server on a fixed port.
9
+ *
10
+ * This is a coordination hint, never a source of truth: entries may be stale
11
+ * (a SIGKILL'd dev server can't clean up), so consumers MUST health-check a URL
12
+ * before trusting it. A missing or corrupt registry is treated as "none".
13
+ *
14
+ * The file is keyed by the current working directory so multiple projects don't
15
+ * collide, while multiple dev servers for the same project share one file
16
+ * (keyed by pid within it).
17
+ */
18
+
19
+ import { createHash } from 'node:crypto';
20
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
21
+ import os from 'node:os';
22
+ import path from 'node:path';
23
+
24
+ /** Absolute path of the registry file for the current working directory. */
25
+ export function dashboardRegistryPath() {
26
+ const key = createHash('sha256')
27
+ .update(process.cwd())
28
+ .digest('hex')
29
+ .slice(0, 16);
30
+ return path.join(os.tmpdir(), 'workflow-observability', `${key}.json`);
31
+ }
32
+
33
+ /** Read the registry entries (always returns an array; never throws). */
34
+ export function readDashboardRegistry() {
35
+ try {
36
+ const parsed = JSON.parse(readFileSync(dashboardRegistryPath(), 'utf8'));
37
+ return Array.isArray(parsed) ? parsed : [];
38
+ } catch {
39
+ return [];
40
+ }
41
+ }
42
+
43
+ function writeEntries(entries) {
44
+ const file = dashboardRegistryPath();
45
+ mkdirSync(path.dirname(file), { recursive: true });
46
+ writeFileSync(file, JSON.stringify(entries));
47
+ }
48
+
49
+ let recorded = false;
50
+
51
+ /**
52
+ * Record this process's embedded dashboard in the registry (idempotent per
53
+ * process). Call once the public origin is known (e.g. from the first request).
54
+ * Entirely best-effort — never throws.
55
+ *
56
+ * @param {{ url: string, basename?: string, world?: string }} entry
57
+ */
58
+ export function recordDashboard(entry) {
59
+ if (recorded) return;
60
+ recorded = true;
61
+ try {
62
+ const others = readDashboardRegistry().filter(
63
+ (e) => e && e.pid !== process.pid
64
+ );
65
+ others.push({
66
+ url: entry.url,
67
+ basename: entry.basename ?? '',
68
+ world: entry.world ?? '',
69
+ pid: process.pid,
70
+ startedAt: new Date().toISOString(),
71
+ });
72
+ writeEntries(others);
73
+ // Best-effort cleanup on normal exit. Signal-terminated processes (Ctrl+C,
74
+ // SIGKILL) won't run this — consumers prune via health checks instead. We
75
+ // intentionally don't hook SIGINT/SIGTERM so we don't interfere with the
76
+ // host framework's own shutdown handling.
77
+ process.once('exit', () => {
78
+ try {
79
+ writeEntries(
80
+ readDashboardRegistry().filter((e) => e && e.pid !== process.pid)
81
+ );
82
+ } catch {
83
+ // ignore
84
+ }
85
+ });
86
+ } catch {
87
+ // best-effort: a failed write must never break request handling
88
+ }
89
+ }
package/server.d.ts CHANGED
@@ -1,3 +1,7 @@
1
- import type { Server } from 'node:http';
1
+ import type { Server } from 'srvx';
2
2
 
3
+ /**
4
+ * Start the standalone observability UI server on `port` (defaults to `PORT`, then 3000),
5
+ * and resolve once it is listening.
6
+ */
3
7
  export function startServer(port?: number): Promise<Server>;
package/server.js CHANGED
@@ -10,57 +10,50 @@
10
10
 
11
11
  import path from 'node:path';
12
12
  import { fileURLToPath, pathToFileURL } from 'node:url';
13
- import express from 'express';
13
+ import { serve } from 'srvx';
14
+ import { createStaticHandler } from './static.js';
14
15
 
15
16
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
17
  const buildDir = path.resolve(__dirname, 'build');
17
-
18
- async function createApp() {
19
- // Import the compiled server build, which exports { app } (an Express app
20
- // with the React Router request handler already mounted by server/app.ts)
21
- const { app } = await import(
22
- pathToFileURL(path.join(buildDir, 'server/index.js')).href
23
- );
24
-
25
- // Add static file serving in front of the React Router handler.
26
- // We create a wrapper app so static middleware runs first.
27
- const server = express();
28
-
29
- // Serve immutable assets with long-lived cache
30
- server.use(
31
- '/assets',
32
- express.static(path.join(buildDir, 'client/assets'), {
33
- immutable: true,
34
- maxAge: '1y',
35
- })
36
- );
37
-
38
- // Serve static client files with short cache
39
- server.use(express.static(path.join(buildDir, 'client'), { maxAge: '1h' }));
40
-
41
- // Mount the React Router app
42
- server.use(app);
43
-
44
- return server;
45
- }
18
+ const clientDir = path.join(buildDir, 'client');
19
+ const serverEntry = path.join(buildDir, 'server', 'index.js');
46
20
 
47
21
  /**
48
22
  * Start the production HTTP server.
49
23
  *
50
24
  * @param {number} [port] - Port to listen on. Defaults to PORT env or 3000.
51
- * @returns {Promise<import("http").Server>} The HTTP server instance.
25
+ * @returns {Promise<import("srvx").Server>} The listening server. The
26
+ * underlying Node `http.Server` remains reachable via `server.node.server`.
52
27
  */
53
28
  export async function startServer(port) {
54
- const resolvedPort = port ?? parseInt(process.env.PORT || '3000', 10);
55
- const app = await createApp();
29
+ // Import the compiled server build, which exports `createFetchHandler` (the
30
+ // React Router request handler, as a Web `Request` -> `Response` function).
31
+ const { createFetchHandler } = await import(pathToFileURL(serverEntry).href);
32
+
33
+ // Static assets are resolved before the SSR handler ever runs. Compression is
34
+ // left on here (unlike the embedded handler): this server can be self-hosted
35
+ // over a real network, where trading CPU for bytes is worth it.
36
+ const serveStatic = createStaticHandler({ dir: clientDir });
37
+ const ssr = createFetchHandler('/');
56
38
 
57
- return new Promise((resolve, reject) => {
58
- const server = app.listen(resolvedPort, () => {
59
- console.log(`@workflow/web server listening on port ${resolvedPort}`);
60
- resolve(server);
61
- });
62
- server.on('error', reject);
39
+ const server = serve({
40
+ port: port ?? parseInt(process.env.PORT || '3000', 10),
41
+ async fetch(request) {
42
+ return (await serveStatic(request)) ?? ssr(request);
43
+ },
44
+ // Safety net — prevents an unhandled error from taking down the server when
45
+ // the React Router error boundary cannot render (e.g. during SSR).
46
+ error(error) {
47
+ console.error('Unhandled request error:', error);
48
+ return new Response('Internal Server Error', { status: 500 });
49
+ },
50
+ // We print our own listening line below.
51
+ silent: true,
63
52
  });
53
+
54
+ await server.ready();
55
+ console.log(`@workflow/web server listening on ${server.url}`);
56
+ return server;
64
57
  }
65
58
 
66
59
  // When run directly, start the server
package/static.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Static file serving for the prebuilt client bundle (`build/client`), shared
3
+ * by both ways @workflow/web is served:
4
+ *
5
+ * - `server.js` — the standalone server, mounted at the root.
6
+ * - `handler.js` — the embedded handler, mounted under a base path inside
7
+ * another server.
8
+ *
9
+ * Internal: this file ships in the package (both consumers import it
10
+ * relatively) but is deliberately absent from the `exports` map, so it is not
11
+ * part of the public API.
12
+ */
13
+
14
+ import { staticMiddleware } from 'srvx/static';
15
+
16
+ const ONE_YEAR_SECONDS = 31_536_000;
17
+ const ONE_HOUR_SECONDS = 3600;
18
+
19
+ /**
20
+ * Sentinel handed to `staticMiddleware` as its `next()`. Returned by identity
21
+ * when no file matched, so a miss is distinguishable from a real 404 the
22
+ * middleware itself produced. Never sent to a client.
23
+ */
24
+ const MISS = new Response(null, { status: 404 });
25
+
26
+ /**
27
+ * Build a static file handler for `dir`.
28
+ *
29
+ * Two middlewares over the same directory, differing only in freshness policy:
30
+ * everything under `/assets/` is content-hashed by Vite (its URL changes when
31
+ * its bytes do) and can be cached indefinitely without revalidation, while the
32
+ * rest — `favicon.ico` and anything else copied from `public/` — keeps a stable
33
+ * URL and so gets a short lifetime. Both emit ETag/Last-Modified validators
34
+ * regardless, so a stale client revalidates into a 304 rather than a full body.
35
+ *
36
+ * @param {object} options
37
+ * @param {string} options.dir - Directory to serve from (the client build).
38
+ * @param {string} [options.basename] - Mount prefix to strip before resolving,
39
+ * already normalized (no trailing slash; `""` for the root).
40
+ * @param {boolean} [options.compress] - Compress compressible bodies on the
41
+ * fly. Defaults to true.
42
+ * @returns {(request: Request) => Promise<Response | null>} The response, or
43
+ * `null` when the request maps to no file and should fall through to SSR.
44
+ */
45
+ export function createStaticHandler({ dir, basename = '', compress = true }) {
46
+ const hashedAssets = staticMiddleware({
47
+ dir,
48
+ maxAge: ONE_YEAR_SECONDS,
49
+ immutable: true,
50
+ compress,
51
+ });
52
+ const publicFiles = staticMiddleware({
53
+ dir,
54
+ maxAge: ONE_HOUR_SECONDS,
55
+ compress,
56
+ });
57
+
58
+ return async (request) => {
59
+ // Everything else (including the index) is the SSR handler's.
60
+ if (request.method !== 'GET' && request.method !== 'HEAD') return null;
61
+
62
+ let url;
63
+ try {
64
+ url = new URL(request.url);
65
+ } catch {
66
+ return null;
67
+ }
68
+
69
+ let target = request;
70
+ if (basename) {
71
+ // A request at exactly `basename` is the dashboard index, not a file.
72
+ if (!url.pathname.startsWith(`${basename}/`)) return null;
73
+ url.pathname = url.pathname.slice(basename.length);
74
+ // `staticMiddleware` resolves against the request's own pathname, so the
75
+ // mount prefix has to come off the URL rather than be passed alongside.
76
+ // Safe to rebuild for GET/HEAD, which carry no body.
77
+ target = new Request(url, request);
78
+ }
79
+
80
+ const middleware = url.pathname.startsWith('/assets/')
81
+ ? hashedAssets
82
+ : publicFiles;
83
+ const response = await middleware(target, () => MISS);
84
+ return response === MISS ? null : response;
85
+ };
86
+ }
@@ -1,34 +0,0 @@
1
- import { W as WorkflowRuntimeError } from "./index-Byi8AWfe.js";
2
- import "./index-BsV8i_Jn.js";
3
- const NONCE_LENGTH = 12;
4
- const TAG_LENGTH = 128;
5
- const KEY_LENGTH = 32;
6
- async function importKey(raw, usages = ["encrypt", "decrypt"]) {
7
- if (raw.byteLength !== KEY_LENGTH) {
8
- throw new WorkflowRuntimeError(`Encryption key must be exactly ${KEY_LENGTH} bytes, got ${raw.byteLength}`);
9
- }
10
- return globalThis.crypto.subtle.importKey(
11
- "raw",
12
- raw,
13
- "AES-GCM",
14
- false,
15
- // `KeyUsage` is a DOM-lib type that's not in scope under `es2022`.
16
- // The `ReadonlyArray<'encrypt' | 'decrypt'>` parameter type matches
17
- // a strict subset of `KeyUsage[]`, so this cast is sound.
18
- usages
19
- );
20
- }
21
- async function decrypt(key, data) {
22
- const minLength = NONCE_LENGTH + TAG_LENGTH / 8;
23
- if (data.byteLength < minLength) {
24
- throw new WorkflowRuntimeError(`Encrypted data too short: expected at least ${minLength} bytes, got ${data.byteLength}`);
25
- }
26
- const nonce = data.subarray(0, NONCE_LENGTH);
27
- const ciphertext = data.subarray(NONCE_LENGTH);
28
- const plaintext = await globalThis.crypto.subtle.decrypt({ name: "AES-GCM", iv: nonce, tagLength: TAG_LENGTH }, key, ciphertext);
29
- return new Uint8Array(plaintext);
30
- }
31
- export {
32
- decrypt,
33
- importKey
34
- };