trellis 3.2.2 → 3.2.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.
Files changed (210) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +4 -0
  3. package/dist/better-sqlite-backend-CDYOAJDF.js +209 -0
  4. package/dist/boot-middleware-LBJX4N2S.js +9 -0
  5. package/dist/boot-middleware-PATBLD52.js +9 -0
  6. package/dist/bridge-G5DPW6TY.js +2361 -0
  7. package/dist/bridge-JSSPQPRH.js +2389 -0
  8. package/dist/bridge-LNXE4HAW.js +2389 -0
  9. package/dist/bridge-OAAXJWSA.js +2389 -0
  10. package/dist/bridge-SFS63RHC.js +2367 -0
  11. package/dist/bridge-U5TOUBVM.js +2389 -0
  12. package/dist/browser/index.js +9 -9
  13. package/dist/{chunk-KSU2GW22.js → chunk-276W52FK.js} +8 -0
  14. package/dist/{chunk-KFQGP6VL.js → chunk-2ESYSVXG.js} +15 -0
  15. package/dist/{chunk-L5N5PR2S.js → chunk-2WW2X2BR.js} +313 -77
  16. package/dist/chunk-3XCOAP6G.js +48 -0
  17. package/dist/chunk-53PDCTJ3.js +1856 -0
  18. package/dist/{chunk-N6MYZT4O.js → chunk-547FZFKO.js} +1 -1
  19. package/dist/{chunk-H6JB3PZ3.js → chunk-5KSGGKET.js} +1 -1
  20. package/dist/{chunk-J2TXUFCZ.js → chunk-6RWGFC3N.js} +134 -20
  21. package/dist/{chunk-QB5ISE47.js → chunk-7WVOPXJV.js} +3 -3
  22. package/dist/chunk-CMSFD6OV.js +11801 -0
  23. package/dist/{chunk-RSWUFTO2.js → chunk-CPUYCCLT.js} +2 -2
  24. package/dist/{chunk-4HYPLFJD.js → chunk-FA5TFVA5.js} +1 -1
  25. package/dist/{chunk-4XIVMVHC.js → chunk-G3XIHPSQ.js} +1 -1
  26. package/dist/{chunk-JHHEXEDM.js → chunk-GCQF75T4.js} +3 -3
  27. package/dist/{chunk-FKQO5A3H.js → chunk-GHG4H3AS.js} +2 -2
  28. package/dist/{chunk-GLM4HGN4.js → chunk-GRWQPKYK.js} +1 -1
  29. package/dist/{chunk-PZ4XYZ4J.js → chunk-GXA73CNC.js} +33 -8
  30. package/dist/{chunk-6GEZ6DN5.js → chunk-H6VTC5SS.js} +3 -3
  31. package/dist/{chunk-S3XLFZ27.js → chunk-IHHSOBJS.js} +1 -1
  32. package/dist/chunk-IJNC25UD.js +2243 -0
  33. package/dist/{chunk-VDAKEOML.js → chunk-J6OUIION.js} +1 -1
  34. package/dist/chunk-JAVAYMMS.js +6 -0
  35. package/dist/{chunk-S6GBJ2ZB.js → chunk-JCQQFLO5.js} +1 -1
  36. package/dist/{chunk-FWRS4CSC.js → chunk-KQG6ZYXP.js} +3 -3
  37. package/dist/chunk-KXAISKZT.js +119 -0
  38. package/dist/chunk-N3R74ZSR.js +7949 -0
  39. package/dist/{chunk-GU374KWZ.js → chunk-NLFRRGX6.js} +3 -3
  40. package/dist/{chunk-XMQ7G77X.js → chunk-OB4CMMX6.js} +1 -1
  41. package/dist/chunk-OKNASCZY.js +182 -0
  42. package/dist/chunk-ONOPPX5E.js +394 -0
  43. package/dist/chunk-QMSU2RAH.js +98 -0
  44. package/dist/{chunk-TCKXSOBP.js → chunk-RARKFVWU.js} +8 -1
  45. package/dist/{chunk-2W3MHTMG.js → chunk-SJWVDS5M.js} +835 -127
  46. package/dist/{chunk-SPSPV5BC.js → chunk-SZ3VAB5P.js} +159 -2
  47. package/dist/chunk-V2ASD6RQ.js +147 -0
  48. package/dist/{chunk-KQ4A2D2P.js → chunk-V4YCJDYL.js} +58 -38
  49. package/dist/{chunk-LNUIGRDZ.js → chunk-VWKLKLYB.js} +1 -1
  50. package/dist/chunk-W5PADCDF.js +1856 -0
  51. package/dist/{chunk-MLC5BUYO.js → chunk-WMERMSWI.js} +1 -1
  52. package/dist/{chunk-IZX2PLIB.js → chunk-WXAURJUD.js} +835 -127
  53. package/dist/chunk-YC5I32PS.js +147 -0
  54. package/dist/{chunk-VBYUTRXX.js → chunk-YKVB4LUQ.js} +3 -3
  55. package/dist/{chunk-7ZFRVCUE.js → chunk-YPT6XMS4.js} +48 -64
  56. package/dist/cli/deploy-cli.d.ts.map +1 -1
  57. package/dist/{deploy-cli-C35HTITO.js → cli/deploy-cli.js} +45 -6
  58. package/dist/cli/gateway-deploy-cli.d.ts +19 -0
  59. package/dist/cli/gateway-deploy-cli.d.ts.map +1 -0
  60. package/dist/cli/index.d.ts.map +1 -1
  61. package/dist/cli/index.js +1363 -884
  62. package/dist/cli/lane.d.ts.map +1 -1
  63. package/dist/cli/protocol.d.ts +6 -0
  64. package/dist/cli/protocol.d.ts.map +1 -0
  65. package/dist/client/index.browser.js +2 -2
  66. package/dist/client/index.js +11 -11
  67. package/dist/client/sdk.browser.d.ts +28 -1
  68. package/dist/client/sdk.browser.d.ts.map +1 -1
  69. package/dist/client/sdk.browser.js +2 -2
  70. package/dist/client/sdk.js +2 -2
  71. package/dist/cms/index.js +1 -1
  72. package/dist/config-KMY6RRK3.js +19 -0
  73. package/dist/core/index.js +17 -17
  74. package/dist/core/kernel/boot-middleware.d.ts +1 -1
  75. package/dist/core/kernel/boot-middleware.d.ts.map +1 -1
  76. package/dist/core/kernel/schema-middleware.d.ts +2 -1
  77. package/dist/core/kernel/schema-middleware.d.ts.map +1 -1
  78. package/dist/core/kernel/trellis-kernel.d.ts +10 -10
  79. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
  80. package/dist/core/persist/factory.js +2 -2
  81. package/dist/core/persist/sqljs-backend.js +2 -2
  82. package/dist/db/index.js +32 -27
  83. package/dist/decisions/index.js +4 -4
  84. package/dist/embeddings/index.js +2 -2
  85. package/dist/engine.d.ts +24 -6
  86. package/dist/engine.d.ts.map +1 -1
  87. package/dist/gateway-deploy-cli-4TU4V3QI.js +312 -0
  88. package/dist/gateway-deploy-cli-A4ISTDHJ.js +298 -0
  89. package/dist/gateway-deploy-cli-D3XTKJQJ.js +312 -0
  90. package/dist/gateway-deploy-cli-ECV3OQCN.js +305 -0
  91. package/dist/gateway-deploy-cli-JUHKVIJE.js +296 -0
  92. package/dist/gateway-deploy-cli-NSDW2JLT.js +310 -0
  93. package/dist/gateway-serve-CM5EAZ52.js +113 -0
  94. package/dist/import-AJLYHFIA.js +10 -0
  95. package/dist/index.js +11 -11
  96. package/dist/launch-explorer-FVX6ZABW.js +95 -0
  97. package/dist/links/index.js +2 -2
  98. package/dist/mcp/bridge.d.ts +45 -0
  99. package/dist/mcp/bridge.d.ts.map +1 -0
  100. package/dist/mcp/discovery.d.ts +15 -0
  101. package/dist/mcp/discovery.d.ts.map +1 -0
  102. package/dist/mcp/gateway-config.d.ts +20 -0
  103. package/dist/mcp/gateway-config.d.ts.map +1 -0
  104. package/dist/mcp/gateway-serve.d.ts +19 -0
  105. package/dist/mcp/gateway-serve.d.ts.map +1 -0
  106. package/dist/mcp/gateway-serve.js +119 -0
  107. package/dist/mcp/graph-summary.d.ts +47 -0
  108. package/dist/mcp/graph-summary.d.ts.map +1 -0
  109. package/dist/mcp/room-audit.d.ts +14 -0
  110. package/dist/mcp/room-audit.d.ts.map +1 -0
  111. package/dist/mcp/room-helpers.d.ts +43 -0
  112. package/dist/mcp/room-helpers.d.ts.map +1 -0
  113. package/dist/mcp/room-registry.d.ts +32 -0
  114. package/dist/mcp/room-registry.d.ts.map +1 -0
  115. package/dist/mcp/room.d.ts +28 -0
  116. package/dist/mcp/room.d.ts.map +1 -0
  117. package/dist/plugins/agent-memory/index.js +1 -1
  118. package/dist/plugins/idea-garden/index.js +1 -1
  119. package/dist/plugins/plan-approval/index.js +1 -1
  120. package/dist/plugins/proactive-watcher/index.js +1 -1
  121. package/dist/protocol/envelope.d.ts +30 -0
  122. package/dist/protocol/envelope.d.ts.map +1 -0
  123. package/dist/protocol/index.d.ts +3 -0
  124. package/dist/protocol/index.d.ts.map +1 -0
  125. package/dist/protocol/whereami.d.ts +33 -0
  126. package/dist/protocol/whereami.d.ts.map +1 -0
  127. package/dist/query-KHDDIR5G.js +31 -0
  128. package/dist/react/index.js +3 -3
  129. package/dist/react/realtime.js +1 -1
  130. package/dist/react/schema-hooks.js +6 -6
  131. package/dist/realtime/index.js +3 -3
  132. package/dist/realtime/relay-server.d.ts.map +1 -1
  133. package/dist/realtime/room.d.ts.map +1 -1
  134. package/dist/realtime.bundle.js +2 -0
  135. package/dist/relay-server-BT6DCJ7F.js +12 -0
  136. package/dist/relay-server-MPQVGNQU.js +12 -0
  137. package/dist/relay-server-PAPW2EWC.js +12 -0
  138. package/dist/remote-manager-6ERQUBSL.js +224 -0
  139. package/dist/remote-manager-G665WWYY.js +224 -0
  140. package/dist/remote-manager-HJTEZ4OF.js +224 -0
  141. package/dist/remote-manager-NYP2Y5UR.js +224 -0
  142. package/dist/remote-manager-WGLCAMMC.js +224 -0
  143. package/dist/scaffold/write.d.ts.map +1 -1
  144. package/dist/schema/index.js +1 -1
  145. package/dist/server/cors.d.ts +13 -0
  146. package/dist/server/cors.d.ts.map +1 -0
  147. package/dist/server/deploy-gateway.d.ts +27 -0
  148. package/dist/server/deploy-gateway.d.ts.map +1 -0
  149. package/dist/server/deploy.d.ts +1 -1
  150. package/dist/server/deploy.d.ts.map +1 -1
  151. package/dist/server/deploy.js +10 -0
  152. package/dist/server/discovery-mcp-gateway.d.ts +13 -0
  153. package/dist/server/discovery-mcp-gateway.d.ts.map +1 -0
  154. package/dist/server/index.js +44 -37
  155. package/dist/server/mcp-gateway.d.ts +27 -0
  156. package/dist/server/mcp-gateway.d.ts.map +1 -0
  157. package/dist/server/mcp-oauth-metadata.d.ts +31 -0
  158. package/dist/server/mcp-oauth-metadata.d.ts.map +1 -0
  159. package/dist/server/node-adapter.d.ts +7 -0
  160. package/dist/server/node-adapter.d.ts.map +1 -1
  161. package/dist/server/node-adapter.js +2 -2
  162. package/dist/server/realtime.d.ts.map +1 -1
  163. package/dist/server/server.d.ts +8 -0
  164. package/dist/server/server.d.ts.map +1 -1
  165. package/dist/server/streamable-mcp-gateway.d.ts +12 -0
  166. package/dist/server/streamable-mcp-gateway.d.ts.map +1 -0
  167. package/dist/server/usage-meter.d.ts +11 -0
  168. package/dist/server/usage-meter.d.ts.map +1 -1
  169. package/dist/server-4VEZHXXS.js +23 -0
  170. package/dist/{server-ZVWGLLRF.js → server-556BMK4C.js} +1 -1
  171. package/dist/server-FQT2VYRE.js +23 -0
  172. package/dist/server-HGZE4ECC.js +23 -0
  173. package/dist/server-J4JKEAMH.js +23 -0
  174. package/dist/server-LXPM5TFR.js +23 -0
  175. package/dist/{server-MB3OPSPI.js → server-POB4NEUX.js} +2 -2
  176. package/dist/server-VJKAPGPG.js +23 -0
  177. package/dist/server-YHS3XIIG.js +23 -0
  178. package/dist/server-ZHTPWPXS.js +23 -0
  179. package/dist/sprites-NC6D7YZS.js +27 -0
  180. package/dist/svelte/index.js +3 -3
  181. package/dist/svelte/schema-hooks.js +4 -4
  182. package/dist/sync/index.js +4 -4
  183. package/dist/tenancy-2SZTP4UD.js +16 -0
  184. package/dist/tenancy-7MTSESMJ.js +16 -0
  185. package/dist/tenancy-U4E7ZEAG.js +16 -0
  186. package/dist/vcs/decompose.d.ts.map +1 -1
  187. package/dist/vcs/index.js +5 -5
  188. package/dist/vcs/lane-disk-materialize.d.ts +11 -0
  189. package/dist/vcs/lane-disk-materialize.d.ts.map +1 -0
  190. package/dist/vcs/lane-worktree.d.ts +21 -0
  191. package/dist/vcs/lane-worktree.d.ts.map +1 -0
  192. package/dist/vcs/store.d.ts +28 -0
  193. package/dist/vcs/store.d.ts.map +1 -0
  194. package/dist/vcs/types.d.ts +5 -0
  195. package/dist/vcs/types.d.ts.map +1 -1
  196. package/dist/vm-config-YZRJ3KUB.js +21 -0
  197. package/dist/vue/index.js +3 -3
  198. package/dist/vue/schema-hooks.js +4 -4
  199. package/package.json +4 -3
  200. package/dist/chunk-FF36CQHZ.js +0 -61
  201. package/dist/chunk-GFZCJ4EH.js +0 -108
  202. package/dist/chunk-KIJITUZB.js +0 -419
  203. package/dist/chunk-SGMDTWJJ.js +0 -149
  204. package/dist/chunk-UQISRW6T.js +0 -203
  205. package/dist/db/trellis.css +0 -1
  206. package/dist/deploy-LQ7GUGJ5.js +0 -9
  207. package/dist/deploy-YNVG5E4E.js +0 -9
  208. package/dist/deploy-cli-24BCHAXY.js +0 -67
  209. package/dist/sprites-RU3E4XQN.js +0 -15
  210. package/dist/tenancy-NBLLGCNJ.js +0 -14
@@ -0,0 +1,147 @@
1
+ import {
2
+ loadVmConfig
3
+ } from "./chunk-UZRUP7QW.js";
4
+ import {
5
+ readConfig
6
+ } from "./chunk-JA7AIHRK.js";
7
+
8
+ // src/mcp/gateway-config.ts
9
+ import { existsSync, readFileSync, writeFileSync } from "fs";
10
+ import { join, resolve } from "path";
11
+ var GATEWAY_CONFIG_FILE = ".trellis-mcp-gateway.json";
12
+ function gatewayConfigPath(dir = ".") {
13
+ return resolve(join(dir, GATEWAY_CONFIG_FILE));
14
+ }
15
+ function readGatewayConfig(dir = ".") {
16
+ const path = gatewayConfigPath(dir);
17
+ if (!existsSync(path)) return null;
18
+ try {
19
+ return JSON.parse(readFileSync(path, "utf8"));
20
+ } catch {
21
+ throw new Error(`Failed to parse ${path}: invalid JSON`);
22
+ }
23
+ }
24
+ function writeGatewayConfig(config, dir = ".") {
25
+ writeFileSync(
26
+ gatewayConfigPath(dir),
27
+ JSON.stringify(config, null, 2) + "\n",
28
+ "utf8"
29
+ );
30
+ }
31
+
32
+ // src/mcp/room-registry.ts
33
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
34
+ import { resolve as resolve2 } from "path";
35
+ function normalizeBaseUrl(url) {
36
+ return url.replace(/\/$/, "");
37
+ }
38
+ function roomMcpPathForUrl(baseUrl) {
39
+ const env = process.env.TRELLIS_MCP_PATH?.trim();
40
+ if (env) return env.startsWith("/") ? env : `/${env}`;
41
+ try {
42
+ const host = new URL(baseUrl).hostname;
43
+ if (/\.sprites\.app$/i.test(host)) return "/trellis/mcp";
44
+ } catch {
45
+ }
46
+ return "/mcp";
47
+ }
48
+ function toMcpUrl(base) {
49
+ const trimmed = normalizeBaseUrl(base);
50
+ if (trimmed.endsWith("/mcp") || trimmed.endsWith("/trellis/mcp")) {
51
+ return trimmed;
52
+ }
53
+ return `${trimmed}${roomMcpPathForUrl(trimmed)}`;
54
+ }
55
+ function parseRegistryJson(raw, source) {
56
+ try {
57
+ const data = JSON.parse(raw);
58
+ const rooms = Array.isArray(data) ? data : data.rooms ?? [];
59
+ return rooms.filter((r) => r.name && r.url).map((r) => ({
60
+ name: r.name,
61
+ url: normalizeBaseUrl(r.url),
62
+ mcpUrl: toMcpUrl(normalizeBaseUrl(r.url)),
63
+ apiKey: r.apiKey,
64
+ source,
65
+ deployedAt: r.deployedAt,
66
+ active: r.active
67
+ }));
68
+ } catch {
69
+ return [];
70
+ }
71
+ }
72
+ function listRegisteredRooms(opts = {}) {
73
+ const configDir = opts.configDir ?? ".";
74
+ const byUrl = /* @__PURE__ */ new Map();
75
+ const envRooms = process.env.TRELLIS_MCP_GATEWAY_ROOMS?.trim();
76
+ if (envRooms) {
77
+ for (const room of parseRegistryJson(envRooms, "env")) {
78
+ byUrl.set(room.url, room);
79
+ }
80
+ }
81
+ const registryPath = process.env.TRELLIS_ROOM_REGISTRY?.trim() ?? resolve2(configDir, ".trellis-rooms.json");
82
+ if (existsSync2(registryPath)) {
83
+ try {
84
+ const raw = readFileSync2(registryPath, "utf8");
85
+ for (const room of parseRegistryJson(raw, "registry")) {
86
+ byUrl.set(room.url, room);
87
+ }
88
+ } catch {
89
+ }
90
+ }
91
+ const vm = loadVmConfig();
92
+ for (const [name, sprite] of Object.entries(vm.sprites)) {
93
+ if (!sprite.hasTrellis && !sprite.apiKey) continue;
94
+ const url = normalizeBaseUrl(sprite.url);
95
+ byUrl.set(url, {
96
+ name,
97
+ url,
98
+ mcpUrl: toMcpUrl(url),
99
+ apiKey: sprite.apiKey,
100
+ source: "vm",
101
+ active: vm.activeSprite === name
102
+ });
103
+ }
104
+ const dbConfig = readConfig(configDir);
105
+ if (dbConfig?.mode === "remote" && dbConfig.url) {
106
+ const url = normalizeBaseUrl(dbConfig.url);
107
+ const name = dbConfig.spriteName ?? url.replace(/^https?:\/\//, "").split(".")[0];
108
+ if (!byUrl.has(url)) {
109
+ byUrl.set(url, {
110
+ name,
111
+ url,
112
+ mcpUrl: toMcpUrl(url),
113
+ apiKey: dbConfig.apiKey,
114
+ source: "project",
115
+ deployedAt: dbConfig.deployedAt,
116
+ active: true
117
+ });
118
+ }
119
+ }
120
+ return [...byUrl.values()].sort((a, b) => a.name.localeCompare(b.name));
121
+ }
122
+ function getRegisteredRoom(nameOrUrl, opts) {
123
+ const needle = nameOrUrl.trim().toLowerCase();
124
+ const rooms = listRegisteredRooms(opts);
125
+ return rooms.find(
126
+ (r) => r.name.toLowerCase() === needle || r.url.toLowerCase() === needle || r.mcpUrl.toLowerCase() === needle || normalizeBaseUrl(needle).endsWith(r.name.toLowerCase())
127
+ ) ?? null;
128
+ }
129
+ function gatewayPublicUrl(opts) {
130
+ const fromConfig = readGatewayConfig(opts?.configDir ?? ".")?.publicUrl?.trim();
131
+ if (fromConfig) return fromConfig.replace(/\/$/, "");
132
+ if (opts?.gatewayPublicUrl?.trim()) {
133
+ return opts.gatewayPublicUrl.trim().replace(/\/$/, "");
134
+ }
135
+ const env = process.env.TRELLIS_MCP_GATEWAY_PUBLIC_URL?.trim();
136
+ if (env) return env.replace(/\/$/, "");
137
+ return "https://mcp.trellis.computer";
138
+ }
139
+
140
+ export {
141
+ gatewayConfigPath,
142
+ writeGatewayConfig,
143
+ roomMcpPathForUrl,
144
+ listRegisteredRooms,
145
+ getRegisteredRoom,
146
+ gatewayPublicUrl
147
+ };
@@ -6,15 +6,15 @@ import {
6
6
  init_types,
7
7
  issueEntityId,
8
8
  laneEntityId
9
- } from "./chunk-N6MYZT4O.js";
9
+ } from "./chunk-547FZFKO.js";
10
10
  import {
11
11
  createVcsOp,
12
12
  init_ops
13
- } from "./chunk-GLM4HGN4.js";
13
+ } from "./chunk-GRWQPKYK.js";
14
14
  import {
15
15
  __esm,
16
16
  __require
17
- } from "./chunk-KFQGP6VL.js";
17
+ } from "./chunk-2ESYSVXG.js";
18
18
 
19
19
  // src/vcs/decompose.ts
20
20
  import { dirname } from "path";
@@ -1,3 +1,8 @@
1
+ import {
2
+ SPRITE_PUBLIC_HTTP_PORT,
3
+ buildDeployUrl,
4
+ validateDeployName
5
+ } from "./chunk-3XCOAP6G.js";
1
6
  import {
2
7
  SPRITE_ENSURE_BUN_SH,
3
8
  assertSpriteCli,
@@ -10,56 +15,13 @@ import {
10
15
  import {
11
16
  updateConfig
12
17
  } from "./chunk-JA7AIHRK.js";
13
- import {
14
- __require
15
- } from "./chunk-KFQGP6VL.js";
16
18
 
17
19
  // src/server/deploy.ts
20
+ import { execFile } from "child_process";
18
21
  import { existsSync, writeFileSync, mkdirSync } from "fs";
19
- import { join, resolve } from "path";
20
-
21
- // src/server/deploy-meta.ts
22
- var DEPLOY_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
23
- var MIN_LEN = 3;
24
- var MAX_LEN = 32;
25
- var DeployNameError = class extends Error {
26
- constructor(message) {
27
- super(message);
28
- this.name = "DeployNameError";
29
- }
30
- };
31
- function normalizeDeployName(name) {
32
- return name.trim().toLowerCase();
33
- }
34
- function validateDeployName(name) {
35
- const normalized = normalizeDeployName(name);
36
- if (!normalized) {
37
- throw new DeployNameError("Deploy name is required.");
38
- }
39
- if (normalized.length < MIN_LEN || normalized.length > MAX_LEN) {
40
- throw new DeployNameError(
41
- `Deploy name must be ${MIN_LEN}\u2013${MAX_LEN} characters (got ${normalized.length}).`
42
- );
43
- }
44
- if (normalized.includes("--")) {
45
- throw new DeployNameError(
46
- "Deploy name cannot contain consecutive hyphens."
47
- );
48
- }
49
- if (!DEPLOY_NAME_RE.test(normalized)) {
50
- throw new DeployNameError(
51
- "Deploy name must start with a letter and use only lowercase letters, numbers, and single hyphens (e.g. my-app)."
52
- );
53
- }
54
- return normalized;
55
- }
56
- function buildDeployUrl(name) {
57
- const slug = validateDeployName(name);
58
- return `https://${slug}.sprites.app`;
59
- }
60
- var SPRITE_PUBLIC_HTTP_PORT = 8080;
61
-
62
- // src/server/deploy.ts
22
+ import { dirname, join, resolve } from "path";
23
+ import { fileURLToPath } from "url";
24
+ import { promisify } from "util";
63
25
  async function deploy(opts) {
64
26
  const { configDir = ".", onProgress = () => {
65
27
  } } = opts;
@@ -109,16 +71,22 @@ async function deploy(opts) {
109
71
  if (!bunPath.includes("bun")) {
110
72
  throw new Error(`Bun install failed on sprite ${name}: ${bunPath || "(no output)"}`);
111
73
  }
112
- onProgress("Starting server...");
113
- await runSpriteExec(
114
- name,
115
- 'pkill -f "/home/sprite/trellis-db/server.js" 2>/dev/null || true'
116
- ).catch(() => {
117
- });
74
+ onProgress("Starting server (sprite-env service)...");
118
75
  const bun = bunPath.trim().split("\n").pop().trim();
119
76
  await runSpriteExec(
120
77
  name,
121
- `cd /home/sprite/trellis-db && (nohup ${bun} run server.js >> server.log 2>&1 </dev/null &); exit 0`
78
+ `
79
+ export PATH="$HOME/.bun/bin:$PATH"
80
+ ENV="/.sprite/bin/sprite-env"
81
+ BUN="${bun}"
82
+ $ENV services delete trellis-db 2>/dev/null || true
83
+ $ENV services create trellis-db \\
84
+ --cmd "$BUN" \\
85
+ --args run,server.js \\
86
+ --dir /home/sprite/trellis-db \\
87
+ --http-port ${listenPort} \\
88
+ --no-stream
89
+ `.trim()
122
90
  );
123
91
  onProgress("Waiting for health check...");
124
92
  await waitForDeployHealth(url, 6e4);
@@ -162,8 +130,6 @@ function generateSecret(prefix) {
162
130
  return `${prefix}${b64}`;
163
131
  }
164
132
  async function runBun(args) {
165
- const { execFile } = __require("child_process");
166
- const { promisify } = __require("util");
167
133
  const execFileAsync = promisify(execFile);
168
134
  try {
169
135
  await execFileAsync("bun", args);
@@ -173,10 +139,33 @@ async function runBun(args) {
173
139
  );
174
140
  }
175
141
  }
142
+ function resolveTrellisImports() {
143
+ const root = process.env.TRELLIS_NODE_ROOT?.trim();
144
+ if (root) {
145
+ return {
146
+ server: join(root, "dist/server/index.js").replace(/\\/g, "/"),
147
+ client: join(root, "dist/client/index.js").replace(/\\/g, "/")
148
+ };
149
+ }
150
+ const here = dirname(fileURLToPath(import.meta.url));
151
+ const packageRoots = [resolve(here, ".."), resolve(here, "..", "..")];
152
+ for (const packageRoot of packageRoots) {
153
+ const server = join(packageRoot, "dist/server/index.js");
154
+ const client = join(packageRoot, "dist/client/index.js");
155
+ if (existsSync(server) && existsSync(client)) {
156
+ return {
157
+ server: server.replace(/\\/g, "/"),
158
+ client: client.replace(/\\/g, "/")
159
+ };
160
+ }
161
+ }
162
+ return { server: "trellis/server", client: "trellis/client" };
163
+ }
176
164
  function generateServerEntrypoint(opts) {
165
+ const { server, client } = resolveTrellisImports();
177
166
  return `
178
- import { TenantPool, startServer } from 'trellis/server';
179
- import { readConfig, defaultLocalConfig, writeConfig } from 'trellis/client';
167
+ import { TenantPool, startServer } from '${server}';
168
+ import { readConfig, defaultLocalConfig, writeConfig } from '${client}';
180
169
  import { join } from 'path';
181
170
  import { existsSync } from 'fs';
182
171
 
@@ -194,7 +183,7 @@ const config = readConfig(configDir)!;
194
183
  const pool = new TenantPool(dbPath, { backend: { backend: 'sqljs' } });
195
184
  await pool.preload();
196
185
 
197
- const server = startServer({ port: ${opts.port}, config, pool });
186
+ await startServer({ port: ${opts.port}, config, pool, presenceRelay: true });
198
187
 
199
188
  console.log('Trellis DB running on port ${opts.port}');
200
189
  console.log(\`Listening on port ${opts.port}\`);
@@ -202,10 +191,5 @@ console.log(\`Listening on port ${opts.port}\`);
202
191
  }
203
192
 
204
193
  export {
205
- DeployNameError,
206
- normalizeDeployName,
207
- validateDeployName,
208
- buildDeployUrl,
209
- SPRITE_PUBLIC_HTTP_PORT,
210
194
  deploy
211
195
  };
@@ -1 +1 @@
1
- {"version":3,"file":"deploy-cli.d.ts","sourceRoot":"","sources":["../../src/cli/deploy-cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACrD,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,GACZ,IAAI,CAqBN;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCxE"}
1
+ {"version":3,"file":"deploy-cli.d.ts","sourceRoot":"","sources":["../../src/cli/deploy-cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACrD,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,GACZ,IAAI,CA2CN;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmDxE"}
@@ -1,12 +1,18 @@
1
1
  import {
2
- DeployNameError,
3
2
  deploy
4
- } from "./chunk-7ZFRVCUE.js";
5
- import "./chunk-CAG4FULI.js";
3
+ } from "../chunk-YPT6XMS4.js";
4
+ import {
5
+ DeployNameError
6
+ } from "../chunk-3XCOAP6G.js";
7
+ import "../chunk-CAG4FULI.js";
8
+ import {
9
+ roomMcpPathForUrl
10
+ } from "../chunk-YC5I32PS.js";
11
+ import "../chunk-UZRUP7QW.js";
6
12
  import {
7
13
  configPath
8
- } from "./chunk-JA7AIHRK.js";
9
- import "./chunk-KFQGP6VL.js";
14
+ } from "../chunk-JA7AIHRK.js";
15
+ import "../chunk-2ESYSVXG.js";
10
16
 
11
17
  // src/cli/deploy-cli.ts
12
18
  import chalk from "chalk";
@@ -22,7 +28,29 @@ function printDeploySuccess(result, configDir, stub) {
22
28
  console.log(chalk.dim(` API key: ${result.apiKey}`));
23
29
  console.log(chalk.dim(` Config: ${configPath(configDir)}`));
24
30
  console.log("");
31
+ const base = result.url.replace(/\/$/, "");
32
+ const mcpPath = roomMcpPathForUrl(base);
33
+ const mcpUrl = `${base}${mcpPath}`;
25
34
  console.log(chalk.dim(` Health: curl ${result.url}/health`));
35
+ console.log(chalk.dim(` MCP: ${mcpUrl}`));
36
+ if (mcpPath !== "/mcp") {
37
+ console.log(chalk.dim(` (Sprites reserves /mcp \u2014 use ${mcpPath} on *.sprites.app)`));
38
+ }
39
+ console.log(chalk.dim(` Gateway: ${base}/gateway/mcp`));
40
+ console.log("");
41
+ console.log(chalk.bold("Cursor MCP (remote):"));
42
+ console.log(
43
+ chalk.cyan(
44
+ ` { "url": "${mcpUrl}", "headers": { "Authorization": "Bearer ${result.apiKey}" } }`
45
+ )
46
+ );
47
+ console.log("");
48
+ console.log(chalk.bold("Claude Desktop (stdio bridge):"));
49
+ console.log(
50
+ chalk.cyan(
51
+ ` npx trellis mcp bridge --room ${result.url} --api-key ${result.apiKey}`
52
+ )
53
+ );
26
54
  console.log("");
27
55
  console.log(chalk.bold("SDK:"));
28
56
  console.log(chalk.cyan(` import { TrellisDb } from 'trellis/client';`));
@@ -35,7 +63,7 @@ function printDeploySuccess(result, configDir, stub) {
35
63
  async function runDeployCli(opts) {
36
64
  const configDir = opts.configDir ?? ".";
37
65
  const port = opts.port === void 0 ? void 0 : typeof opts.port === "string" ? parseInt(opts.port, 10) : opts.port;
38
- const { readConfig } = await import("./config-PFTP67TR.js");
66
+ const { readConfig } = await import("../config-KMY6RRK3.js");
39
67
  const config = readConfig(configDir);
40
68
  const label = opts.stub ? "Stub deploy" : "Deploying to Sprites";
41
69
  console.log(chalk.bold(`${label}: ${opts.name}...`));
@@ -51,6 +79,17 @@ async function runDeployCli(opts) {
51
79
  onProgress: (msg) => console.log(chalk.dim(` ${msg}`))
52
80
  });
53
81
  printDeploySuccess(result, configDir, !!opts.stub);
82
+ if (!opts.stub) {
83
+ try {
84
+ const { trackSprite } = await import("../vm-config-YZRJ3KUB.js");
85
+ trackSprite(result.name, {
86
+ url: result.url,
87
+ hasTrellis: true,
88
+ apiKey: result.apiKey
89
+ });
90
+ } catch {
91
+ }
92
+ }
54
93
  } catch (err) {
55
94
  if (err instanceof DeployNameError) {
56
95
  console.error(chalk.red(`Invalid name: ${err.message}`));
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `trellis mcp gateway deploy` handler.
3
+ */
4
+ export interface GatewayDeployCliOptions {
5
+ name: string;
6
+ publicUrl?: string;
7
+ port?: string | number;
8
+ configDir?: string;
9
+ roomsFile?: string;
10
+ stub?: boolean;
11
+ }
12
+ export declare function printGatewayDeploySuccess(result: {
13
+ url: string;
14
+ publicUrl: string;
15
+ name: string;
16
+ roomCount: number;
17
+ }, configDir: string, stub: boolean): void;
18
+ export declare function runGatewayDeployCli(opts: GatewayDeployCliOptions): Promise<void>;
19
+ //# sourceMappingURL=gateway-deploy-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-deploy-cli.d.ts","sourceRoot":"","sources":["../../src/cli/gateway-deploy-cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE;IACN,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,EACD,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,GACZ,IAAI,CA8CN;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiCf"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AA4CH,MAAM,MAAM,OAAO,GACf,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,GACT,OAAO,GACP,QAAQ,GACR,MAAM,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;AACjE,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,MAAM,GACN,UAAU,GACV,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,SAAS,GACT,WAAW,GACX,OAAO,GACP,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AA6CH,MAAM,MAAM,OAAO,GACf,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,GACT,OAAO,GACP,QAAQ,GACR,MAAM,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;AACjE,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,MAAM,GACN,UAAU,GACV,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,SAAS,GACT,WAAW,GACX,OAAO,GACP,MAAM,CAAC"}