crewx 0.9.0-rc.97 → 0.9.0-rc.98

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.
@@ -59,6 +59,7 @@ const crewx_pool_service_js_1 = require("../../modules/crewx-pool.service.js");
59
59
  const install_id_validation_js_1 = require("./install-id.validation.js");
60
60
  const source_coordinate_js_1 = require("./source-coordinate.js");
61
61
  const todo_js_1 = require("../mcp/default-apps/todo.js");
62
+ const mcp_app_assets_js_1 = require("../mcp/mcp-app-assets.js");
62
63
  /**
63
64
  * PLAN→APPLY sealing window (design §5.7, WI-20260803-007 §2) — a layer
64
65
  * separate from `TemplateInstaller.cleanupStale()`'s 24h stale-leftover
@@ -89,7 +90,7 @@ function sealPath(workspaceRoot, installId) {
89
90
  return (0, path_1.join)(stagingDirFor(workspaceRoot, installId), '.install-meta.json');
90
91
  }
91
92
  function publicTodoAssetPath() {
92
- return (0, path_1.resolve)(process.env.MCP_APPS_ASSET_DIR ?? (0, path_1.resolve)(process.cwd(), 'examples/mcp-apps/dist'), 'todo/todo.html');
93
+ return (0, path_1.resolve)((0, mcp_app_assets_js_1.mcpAppAssetDir)(), 'todo/todo.html');
93
94
  }
94
95
  function sha256File(absPath) {
95
96
  return (0, crypto_1.createHash)('sha256').update(new Uint8Array((0, fs_1.readFileSync)(absPath))).digest('hex');
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mcpAppAssetDir = mcpAppAssetDir;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const MCP_APP_ASSET_SUBDIR = (0, node_path_1.join)('examples', 'mcp-apps', 'dist');
7
+ let crewxPackageRoot;
8
+ // Walk up from __dirname to find root package.json (works in both src/ and dist-server/ layouts)
9
+ function findCrewxPackageRoot() {
10
+ if (crewxPackageRoot !== undefined)
11
+ return crewxPackageRoot;
12
+ let dir = __dirname;
13
+ while (dir !== (0, node_path_1.dirname)(dir)) {
14
+ try {
15
+ const pkg = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(dir, 'package.json'), 'utf-8'));
16
+ if (pkg.name === 'crewx')
17
+ return (crewxPackageRoot = dir);
18
+ }
19
+ catch { }
20
+ dir = (0, node_path_1.dirname)(dir);
21
+ }
22
+ return (crewxPackageRoot = null);
23
+ }
24
+ /**
25
+ * Directory holding the generated MCP App HTML bundles. Anchored to the crewx
26
+ * package root, not process.cwd() — `npx crewx` runs with the user's directory
27
+ * as cwd, which never contains the bundles.
28
+ */
29
+ function mcpAppAssetDir() {
30
+ return (0, node_path_1.resolve)(process.env.MCP_APPS_ASSET_DIR ?? (0, node_path_1.resolve)(findCrewxPackageRoot() ?? process.cwd(), MCP_APP_ASSET_SUBDIR));
31
+ }
@@ -29,6 +29,7 @@ const weather_js_1 = require("./default-apps/weather.js");
29
29
  const terminal_js_1 = require("./default-apps/terminal.js");
30
30
  const terminal_session_service_js_1 = require("../terminal/terminal-session.service.js");
31
31
  const workspace_context_store_js_1 = require("../../common/workspace-context.store.js");
32
+ const mcp_app_assets_js_1 = require("./mcp-app-assets.js");
32
33
  exports.MCP_APPS_ENV = 'CREWX_MCP_APPS';
33
34
  const PUBLIC_TODO_CONTENT_ID = 'cmtybl8cc0fapgi1wdx61w003';
34
35
  const PUBLIC_TODO_ENTRY_HASH = '2c23ec000f7990e3b8ec836db21d80e0cbd9b28fd309066a9065c75c9f527732';
@@ -40,12 +41,9 @@ const MCP_APP_HELLO_ID = 'mcp-app-hello';
40
41
  exports.MCP_APP_WORKFLOW_ID = 'mcp-app-workflow-approval';
41
42
  exports.MCP_APP_TIC_TAC_TOE_ID = 'mcp-app-tic-tac-toe';
42
43
  exports.MCP_APP_TIC_TAC_TOE_CARD_KEY = exports.MCP_APP_TIC_TAC_TOE_ID;
43
- function mcpAppAssetDir() {
44
- return (0, node_path_1.resolve)(process.env.MCP_APPS_ASSET_DIR ?? (0, node_path_1.resolve)(process.cwd(), 'examples/mcp-apps/dist'));
45
- }
46
44
  /** Load the exact generated HTML that the MCP registry advertises and serves. */
47
45
  function readMcpAppAsset(relativePath) {
48
- const assetPath = (0, node_path_1.resolve)(mcpAppAssetDir(), relativePath);
46
+ const assetPath = (0, node_path_1.resolve)((0, mcp_app_assets_js_1.mcpAppAssetDir)(), relativePath);
49
47
  try {
50
48
  const html = (0, node_fs_1.readFileSync)(assetPath, 'utf8');
51
49
  if (!/<html(?:\s|>)/i.test(html) || !/<\/html\s*>/i.test(html)) {
@@ -64,7 +62,7 @@ function readMcpAppAsset(relativePath) {
64
62
  * present-and-invalid bundle through readMcpAppAsset().
65
63
  */
66
64
  function readOptionalMcpAppAsset(relativePath) {
67
- const assetPath = (0, node_path_1.resolve)(mcpAppAssetDir(), relativePath);
65
+ const assetPath = (0, node_path_1.resolve)((0, mcp_app_assets_js_1.mcpAppAssetDir)(), relativePath);
68
66
  return (0, node_fs_1.existsSync)(assetPath) ? readMcpAppAsset(relativePath) : undefined;
69
67
  }
70
68
  const HELLO_WORLD_HTML = readMcpAppAsset('hello/hello-world.html');