trellis 3.2.3 → 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.
- package/CHANGELOG.md +10 -0
- package/README.md +4 -0
- package/dist/better-sqlite-backend-CDYOAJDF.js +209 -0
- package/dist/boot-middleware-LBJX4N2S.js +9 -0
- package/dist/boot-middleware-PATBLD52.js +9 -0
- package/dist/bridge-G5DPW6TY.js +2361 -0
- package/dist/bridge-JSSPQPRH.js +2389 -0
- package/dist/bridge-LNXE4HAW.js +2389 -0
- package/dist/bridge-OAAXJWSA.js +2389 -0
- package/dist/bridge-SFS63RHC.js +2367 -0
- package/dist/bridge-U5TOUBVM.js +2389 -0
- package/dist/browser/index.js +12 -12
- package/dist/{chunk-KSU2GW22.js → chunk-276W52FK.js} +8 -0
- package/dist/{chunk-KFQGP6VL.js → chunk-2ESYSVXG.js} +15 -0
- package/dist/{chunk-L5N5PR2S.js → chunk-2WW2X2BR.js} +313 -77
- package/dist/chunk-3XCOAP6G.js +48 -0
- package/dist/chunk-53PDCTJ3.js +1856 -0
- package/dist/{chunk-N6MYZT4O.js → chunk-547FZFKO.js} +1 -1
- package/dist/{chunk-7DUMWO5L.js → chunk-7WVOPXJV.js} +3 -3
- package/dist/chunk-CMSFD6OV.js +11801 -0
- package/dist/{chunk-RSWUFTO2.js → chunk-CPUYCCLT.js} +2 -2
- package/dist/{chunk-4HYPLFJD.js → chunk-FA5TFVA5.js} +1 -1
- package/dist/{chunk-4XIVMVHC.js → chunk-G3XIHPSQ.js} +1 -1
- package/dist/{chunk-JHHEXEDM.js → chunk-GCQF75T4.js} +3 -3
- package/dist/{chunk-FKQO5A3H.js → chunk-GHG4H3AS.js} +2 -2
- package/dist/{chunk-GLM4HGN4.js → chunk-GRWQPKYK.js} +1 -1
- package/dist/{chunk-PZ4XYZ4J.js → chunk-GXA73CNC.js} +33 -8
- package/dist/{chunk-6GEZ6DN5.js → chunk-H6VTC5SS.js} +3 -3
- package/dist/{chunk-S3XLFZ27.js → chunk-IHHSOBJS.js} +1 -1
- package/dist/chunk-IJNC25UD.js +2243 -0
- package/dist/{chunk-VDAKEOML.js → chunk-J6OUIION.js} +1 -1
- package/dist/chunk-JAVAYMMS.js +6 -0
- package/dist/{chunk-S6GBJ2ZB.js → chunk-JCQQFLO5.js} +1 -1
- package/dist/{chunk-FWRS4CSC.js → chunk-KQG6ZYXP.js} +3 -3
- package/dist/chunk-KXAISKZT.js +119 -0
- package/dist/chunk-N3R74ZSR.js +7949 -0
- package/dist/{chunk-GU374KWZ.js → chunk-NLFRRGX6.js} +3 -3
- package/dist/{chunk-XMQ7G77X.js → chunk-OB4CMMX6.js} +1 -1
- package/dist/chunk-OKNASCZY.js +182 -0
- package/dist/chunk-ONOPPX5E.js +394 -0
- package/dist/chunk-QMSU2RAH.js +98 -0
- package/dist/{chunk-TCKXSOBP.js → chunk-RARKFVWU.js} +8 -1
- package/dist/{chunk-2AACZRII.js → chunk-SJWVDS5M.js} +751 -162
- package/dist/{chunk-SPSPV5BC.js → chunk-SZ3VAB5P.js} +159 -2
- package/dist/chunk-V2ASD6RQ.js +147 -0
- package/dist/{chunk-KQ4A2D2P.js → chunk-V4YCJDYL.js} +58 -38
- package/dist/{chunk-LNUIGRDZ.js → chunk-VWKLKLYB.js} +1 -1
- package/dist/chunk-W5PADCDF.js +1856 -0
- package/dist/{chunk-MLC5BUYO.js → chunk-WMERMSWI.js} +1 -1
- package/dist/chunk-WXAURJUD.js +1948 -0
- package/dist/chunk-YC5I32PS.js +147 -0
- package/dist/{chunk-VBYUTRXX.js → chunk-YKVB4LUQ.js} +3 -3
- package/dist/{chunk-NWSW5YNS.js → chunk-YPT6XMS4.js} +20 -50
- package/dist/cli/deploy-cli.d.ts.map +1 -1
- package/dist/cli/deploy-cli.js +43 -4
- package/dist/cli/gateway-deploy-cli.d.ts +19 -0
- package/dist/cli/gateway-deploy-cli.d.ts.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1360 -881
- package/dist/cli/lane.d.ts.map +1 -1
- package/dist/cli/protocol.d.ts +6 -0
- package/dist/cli/protocol.d.ts.map +1 -0
- package/dist/client/index.browser.js +2 -2
- package/dist/client/index.js +11 -11
- package/dist/client/sdk.browser.js +1 -1
- package/dist/client/sdk.js +2 -2
- package/dist/cms/index.js +1 -1
- package/dist/config-KMY6RRK3.js +19 -0
- package/dist/core/index.js +13 -13
- package/dist/core/kernel/boot-middleware.d.ts +1 -1
- package/dist/core/kernel/boot-middleware.d.ts.map +1 -1
- package/dist/core/kernel/schema-middleware.d.ts +2 -1
- package/dist/core/kernel/schema-middleware.d.ts.map +1 -1
- package/dist/core/kernel/trellis-kernel.d.ts +10 -10
- package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
- package/dist/core/persist/factory.js +2 -2
- package/dist/core/persist/sqljs-backend.js +2 -2
- package/dist/db/index.js +30 -25
- package/dist/decisions/index.js +4 -4
- package/dist/embeddings/index.js +2 -2
- package/dist/engine.d.ts +24 -6
- package/dist/engine.d.ts.map +1 -1
- package/dist/gateway-deploy-cli-4TU4V3QI.js +312 -0
- package/dist/gateway-deploy-cli-A4ISTDHJ.js +298 -0
- package/dist/gateway-deploy-cli-D3XTKJQJ.js +312 -0
- package/dist/gateway-deploy-cli-ECV3OQCN.js +305 -0
- package/dist/gateway-deploy-cli-JUHKVIJE.js +296 -0
- package/dist/gateway-deploy-cli-NSDW2JLT.js +310 -0
- package/dist/gateway-serve-CM5EAZ52.js +113 -0
- package/dist/import-AJLYHFIA.js +10 -0
- package/dist/index.js +11 -11
- package/dist/launch-explorer-FVX6ZABW.js +95 -0
- package/dist/links/index.js +2 -2
- package/dist/mcp/bridge.d.ts +45 -0
- package/dist/mcp/bridge.d.ts.map +1 -0
- package/dist/mcp/discovery.d.ts +15 -0
- package/dist/mcp/discovery.d.ts.map +1 -0
- package/dist/mcp/gateway-config.d.ts +20 -0
- package/dist/mcp/gateway-config.d.ts.map +1 -0
- package/dist/mcp/gateway-serve.d.ts +19 -0
- package/dist/mcp/gateway-serve.d.ts.map +1 -0
- package/dist/mcp/gateway-serve.js +119 -0
- package/dist/mcp/graph-summary.d.ts +47 -0
- package/dist/mcp/graph-summary.d.ts.map +1 -0
- package/dist/mcp/room-audit.d.ts +14 -0
- package/dist/mcp/room-audit.d.ts.map +1 -0
- package/dist/mcp/room-helpers.d.ts +43 -0
- package/dist/mcp/room-helpers.d.ts.map +1 -0
- package/dist/mcp/room-registry.d.ts +32 -0
- package/dist/mcp/room-registry.d.ts.map +1 -0
- package/dist/mcp/room.d.ts +28 -0
- package/dist/mcp/room.d.ts.map +1 -0
- package/dist/plugins/agent-memory/index.js +1 -1
- package/dist/plugins/idea-garden/index.js +1 -1
- package/dist/plugins/plan-approval/index.js +1 -1
- package/dist/plugins/proactive-watcher/index.js +1 -1
- package/dist/protocol/envelope.d.ts +30 -0
- package/dist/protocol/envelope.d.ts.map +1 -0
- package/dist/protocol/index.d.ts +3 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/whereami.d.ts +33 -0
- package/dist/protocol/whereami.d.ts.map +1 -0
- package/dist/query-KHDDIR5G.js +31 -0
- package/dist/react/index.js +1 -1
- package/dist/react/realtime.js +1 -1
- package/dist/react/schema-hooks.js +5 -5
- package/dist/realtime/index.js +3 -3
- package/dist/realtime/relay-server.d.ts.map +1 -1
- package/dist/realtime/room.d.ts.map +1 -1
- package/dist/realtime.bundle.js +2 -0
- package/dist/relay-server-BT6DCJ7F.js +12 -0
- package/dist/relay-server-MPQVGNQU.js +12 -0
- package/dist/relay-server-PAPW2EWC.js +12 -0
- package/dist/remote-manager-6ERQUBSL.js +224 -0
- package/dist/remote-manager-G665WWYY.js +224 -0
- package/dist/remote-manager-HJTEZ4OF.js +224 -0
- package/dist/remote-manager-NYP2Y5UR.js +224 -0
- package/dist/remote-manager-WGLCAMMC.js +224 -0
- package/dist/scaffold/write.d.ts.map +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/server/cors.d.ts.map +1 -1
- package/dist/server/deploy-gateway.d.ts +27 -0
- package/dist/server/deploy-gateway.d.ts.map +1 -0
- package/dist/server/deploy.d.ts.map +1 -1
- package/dist/server/deploy.js +3 -2
- package/dist/server/discovery-mcp-gateway.d.ts +13 -0
- package/dist/server/discovery-mcp-gateway.d.ts.map +1 -0
- package/dist/server/index.js +38 -31
- package/dist/server/mcp-gateway.d.ts +27 -0
- package/dist/server/mcp-gateway.d.ts.map +1 -0
- package/dist/server/mcp-oauth-metadata.d.ts +31 -0
- package/dist/server/mcp-oauth-metadata.d.ts.map +1 -0
- package/dist/server/node-adapter.d.ts +7 -0
- package/dist/server/node-adapter.d.ts.map +1 -1
- package/dist/server/node-adapter.js +2 -2
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/server.d.ts +8 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/streamable-mcp-gateway.d.ts +12 -0
- package/dist/server/streamable-mcp-gateway.d.ts.map +1 -0
- package/dist/server/usage-meter.d.ts +11 -0
- package/dist/server/usage-meter.d.ts.map +1 -1
- package/dist/server-4VEZHXXS.js +23 -0
- package/dist/{server-OGVWNDNK.js → server-556BMK4C.js} +1 -1
- package/dist/server-FQT2VYRE.js +23 -0
- package/dist/server-HGZE4ECC.js +23 -0
- package/dist/server-J4JKEAMH.js +23 -0
- package/dist/server-LXPM5TFR.js +23 -0
- package/dist/server-POB4NEUX.js +18 -0
- package/dist/server-VJKAPGPG.js +23 -0
- package/dist/server-YHS3XIIG.js +23 -0
- package/dist/server-ZHTPWPXS.js +23 -0
- package/dist/sprites-NC6D7YZS.js +27 -0
- package/dist/svelte/index.js +3 -3
- package/dist/svelte/schema-hooks.js +4 -4
- package/dist/sync/index.js +4 -4
- package/dist/tenancy-2SZTP4UD.js +16 -0
- package/dist/tenancy-7MTSESMJ.js +16 -0
- package/dist/tenancy-U4E7ZEAG.js +16 -0
- package/dist/vcs/decompose.d.ts.map +1 -1
- package/dist/vcs/index.js +5 -5
- package/dist/vcs/lane-disk-materialize.d.ts +11 -0
- package/dist/vcs/lane-disk-materialize.d.ts.map +1 -0
- package/dist/vcs/lane-worktree.d.ts +21 -0
- package/dist/vcs/lane-worktree.d.ts.map +1 -0
- package/dist/vcs/store.d.ts +28 -0
- package/dist/vcs/store.d.ts.map +1 -0
- package/dist/vcs/types.d.ts +5 -0
- package/dist/vcs/types.d.ts.map +1 -1
- package/dist/vm-config-YZRJ3KUB.js +21 -0
- package/dist/vue/index.js +3 -3
- package/dist/vue/schema-hooks.js +4 -4
- package/package.json +4 -3
- package/dist/chunk-GFZCJ4EH.js +0 -108
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
corsPreflightResponse,
|
|
3
|
+
discoveryMcpGateway,
|
|
4
|
+
mcpServiceDocument,
|
|
5
|
+
oauthAuthorizationServerMetadata,
|
|
6
|
+
oauthProtectedResourceMetadata,
|
|
7
|
+
withCors
|
|
8
|
+
} from "./chunk-B2EJSYNW.js";
|
|
9
|
+
import "./chunk-OA7HD3UA.js";
|
|
10
|
+
import "./chunk-SXYFXZKZ.js";
|
|
11
|
+
import "./chunk-UZRUP7QW.js";
|
|
12
|
+
import "./chunk-JA7AIHRK.js";
|
|
13
|
+
import "./chunk-2ESYSVXG.js";
|
|
14
|
+
|
|
15
|
+
// src/mcp/gateway-serve.ts
|
|
16
|
+
async function createGatewayFetchHandler(opts = {}) {
|
|
17
|
+
const configDir = opts.configDir ?? ".";
|
|
18
|
+
const discoveryCtx = { configDir };
|
|
19
|
+
return async (req) => {
|
|
20
|
+
if (req.method === "OPTIONS") {
|
|
21
|
+
return corsPreflightResponse(req);
|
|
22
|
+
}
|
|
23
|
+
const url = new URL(req.url);
|
|
24
|
+
const path = url.pathname.replace(/\/$/, "") || "/";
|
|
25
|
+
const origin = opts.publicUrl?.replace(/\/$/, "") || `${url.protocol}//${url.host}`;
|
|
26
|
+
const respond = (res) => withCors(req, res);
|
|
27
|
+
if (path === "/health") {
|
|
28
|
+
return respond(
|
|
29
|
+
new Response(
|
|
30
|
+
JSON.stringify({
|
|
31
|
+
status: "ok",
|
|
32
|
+
service: "trellis-mcp-gateway",
|
|
33
|
+
mcp: "/mcp",
|
|
34
|
+
gateway: "/gateway/mcp"
|
|
35
|
+
}),
|
|
36
|
+
{ headers: { "Content-Type": "application/json" } }
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (path === "/.well-known/oauth-protected-resource") {
|
|
41
|
+
return respond(
|
|
42
|
+
new Response(JSON.stringify(oauthProtectedResourceMetadata(origin)), {
|
|
43
|
+
headers: { "Content-Type": "application/json" }
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (path === "/.well-known/oauth-authorization-server") {
|
|
48
|
+
return respond(
|
|
49
|
+
new Response(JSON.stringify(oauthAuthorizationServerMetadata(origin)), {
|
|
50
|
+
headers: { "Content-Type": "application/json" }
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (path === "/mcp" || path === "/gateway/mcp") {
|
|
55
|
+
const res = await discoveryMcpGateway.handle(req, {
|
|
56
|
+
...discoveryCtx,
|
|
57
|
+
origin,
|
|
58
|
+
gatewayPublicUrl: origin
|
|
59
|
+
});
|
|
60
|
+
return respond(res);
|
|
61
|
+
}
|
|
62
|
+
if (path === "/") {
|
|
63
|
+
return respond(
|
|
64
|
+
new Response(JSON.stringify(mcpServiceDocument(origin, {})), {
|
|
65
|
+
headers: { "Content-Type": "application/json" }
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return respond(
|
|
70
|
+
new Response(JSON.stringify({ error: "Not Found" }), {
|
|
71
|
+
status: 404,
|
|
72
|
+
headers: { "Content-Type": "application/json" }
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function startGatewayServer(opts = {}) {
|
|
78
|
+
const port = opts.port ?? 3940;
|
|
79
|
+
const fetch = await createGatewayFetchHandler(opts);
|
|
80
|
+
if (typeof globalThis.Bun !== "undefined") {
|
|
81
|
+
const server2 = globalThis.Bun.serve({
|
|
82
|
+
port,
|
|
83
|
+
hostname: opts.hostname ?? "0.0.0.0",
|
|
84
|
+
fetch
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
port: server2.port ?? port,
|
|
88
|
+
stop: () => server2.stop(true)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const { startNodeServer } = await import("./server/node-adapter.js");
|
|
92
|
+
const server = await startNodeServer({
|
|
93
|
+
port,
|
|
94
|
+
hostname: opts.hostname,
|
|
95
|
+
fetch,
|
|
96
|
+
websocket: {
|
|
97
|
+
open() {
|
|
98
|
+
},
|
|
99
|
+
message() {
|
|
100
|
+
},
|
|
101
|
+
close() {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
port: server.port,
|
|
107
|
+
stop: () => server.stop(true)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
createGatewayFetchHandler,
|
|
112
|
+
startGatewayServer
|
|
113
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-OKNASCZY.js";
|
|
2
2
|
import {
|
|
3
3
|
FileWatcher,
|
|
4
4
|
Ingestion,
|
|
@@ -11,19 +11,19 @@ import {
|
|
|
11
11
|
loadProfile,
|
|
12
12
|
saveProfile,
|
|
13
13
|
writeAgentScaffold
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-N3R74ZSR.js";
|
|
15
|
+
import "./chunk-NLFRRGX6.js";
|
|
16
16
|
import {
|
|
17
17
|
SqliteKernelBackend
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-OB4CMMX6.js";
|
|
19
19
|
import {
|
|
20
20
|
TrellisKernel
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-V4YCJDYL.js";
|
|
22
22
|
import "./chunk-6CTA6MCE.js";
|
|
23
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-G3XIHPSQ.js";
|
|
24
24
|
import {
|
|
25
25
|
VcsMiddleware
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KQG6ZYXP.js";
|
|
27
27
|
import {
|
|
28
28
|
IdbOpLog
|
|
29
29
|
} from "./chunk-MPXUVGT3.js";
|
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
unblockIssue,
|
|
81
81
|
updateIssue,
|
|
82
82
|
updateLaneHead
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-IJNC25UD.js";
|
|
84
84
|
import {
|
|
85
85
|
DEFAULT_CONFIG,
|
|
86
86
|
branchEntityId,
|
|
@@ -92,15 +92,15 @@ import {
|
|
|
92
92
|
issueEntityId,
|
|
93
93
|
laneEntityId,
|
|
94
94
|
milestoneEntityId
|
|
95
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-547FZFKO.js";
|
|
96
96
|
import {
|
|
97
97
|
createVcsOp,
|
|
98
98
|
hashVcsOp,
|
|
99
99
|
isVcsOp,
|
|
100
100
|
isVcsOpKind,
|
|
101
101
|
verifyVcsOpHash
|
|
102
|
-
} from "./chunk-
|
|
103
|
-
import "./chunk-
|
|
102
|
+
} from "./chunk-GRWQPKYK.js";
|
|
103
|
+
import "./chunk-2ESYSVXG.js";
|
|
104
104
|
|
|
105
105
|
// src/index.ts
|
|
106
106
|
init_engine();
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import "./chunk-2ESYSVXG.js";
|
|
2
|
+
|
|
3
|
+
// src/ui/launch-explorer.ts
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
var MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
function resolveExplorerAppDir() {
|
|
10
|
+
const candidates = [
|
|
11
|
+
path.resolve(MODULE_DIR, "../../demo/realtime-app"),
|
|
12
|
+
path.resolve(process.cwd(), "demo/realtime-app")
|
|
13
|
+
];
|
|
14
|
+
for (const dir of candidates) {
|
|
15
|
+
if (existsSync(path.join(dir, "package.json"))) return dir;
|
|
16
|
+
}
|
|
17
|
+
throw new Error(
|
|
18
|
+
"Realtime explorer app not found at demo/realtime-app.\nRun: node scripts/sync-realtime-app.mjs"
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function which(cmd) {
|
|
22
|
+
return process.platform === "win32" ? `${cmd}.cmd` : cmd;
|
|
23
|
+
}
|
|
24
|
+
async function launchRealtimeExplorer(opts) {
|
|
25
|
+
const appDir = resolveExplorerAppDir();
|
|
26
|
+
const appPort = opts.appPort ?? 4e3;
|
|
27
|
+
const trellisPort = opts.trellisPort ?? 3920;
|
|
28
|
+
if (!existsSync(path.join(appDir, "node_modules"))) {
|
|
29
|
+
console.log("Installing explorer dependencies (pnpm)\u2026");
|
|
30
|
+
await runCmd(which("pnpm"), ["install"], { cwd: appDir });
|
|
31
|
+
} else {
|
|
32
|
+
await runCmd(which("node"), ["scripts/ensure-trellis-build.mjs"], {
|
|
33
|
+
cwd: appDir
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const env = {
|
|
37
|
+
...process.env,
|
|
38
|
+
TRELLIS_PORT: String(trellisPort),
|
|
39
|
+
TRELLIS_REPO_ROOT: opts.rootPath
|
|
40
|
+
};
|
|
41
|
+
const child = spawn(which("pnpm"), ["run", "dev:all"], {
|
|
42
|
+
cwd: appDir,
|
|
43
|
+
env,
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
shell: process.platform === "win32"
|
|
46
|
+
});
|
|
47
|
+
const stop = () => {
|
|
48
|
+
if (!child.killed) child.kill("SIGTERM");
|
|
49
|
+
};
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
let settled = false;
|
|
52
|
+
child.on("error", (err) => {
|
|
53
|
+
if (!settled) {
|
|
54
|
+
settled = true;
|
|
55
|
+
reject(err);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
child.on("exit", (code) => {
|
|
59
|
+
if (settled) return;
|
|
60
|
+
if (code != null && code !== 0) {
|
|
61
|
+
settled = true;
|
|
62
|
+
reject(new Error(`Explorer exited with code ${code}`));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
if (settled) return;
|
|
67
|
+
settled = true;
|
|
68
|
+
resolve({
|
|
69
|
+
appPort,
|
|
70
|
+
trellisPort,
|
|
71
|
+
appUrl: `http://localhost:${appPort}`,
|
|
72
|
+
trellisUrl: `http://localhost:${trellisPort}`,
|
|
73
|
+
stop
|
|
74
|
+
});
|
|
75
|
+
}, 2e3);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function runCmd(cmd, args, opts) {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
const child = spawn(cmd, args, {
|
|
81
|
+
cwd: opts.cwd,
|
|
82
|
+
stdio: "inherit",
|
|
83
|
+
shell: process.platform === "win32"
|
|
84
|
+
});
|
|
85
|
+
child.on("error", reject);
|
|
86
|
+
child.on("exit", (code) => {
|
|
87
|
+
if (code === 0) resolve();
|
|
88
|
+
else reject(new Error(`${cmd} exited with ${code}`));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
launchRealtimeExplorer,
|
|
94
|
+
resolveExplorerAppDir
|
|
95
|
+
};
|
package/dist/links/index.js
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trellis Room MCP bridge — stdio proxy to a remote Streamable HTTP room.
|
|
3
|
+
*
|
|
4
|
+
* For MCP clients that only support stdio (Claude Desktop, older configs):
|
|
5
|
+
*
|
|
6
|
+
* npx trellis mcp bridge --room https://my-room.sprites.app
|
|
7
|
+
*
|
|
8
|
+
* @module trellis/mcp
|
|
9
|
+
*/
|
|
10
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
12
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
13
|
+
export interface RoomMcpBridgeOptions {
|
|
14
|
+
/** Room base URL or full `/mcp` URL. Falls back to `.trellis-db.json`. */
|
|
15
|
+
room?: string;
|
|
16
|
+
/** API key. Falls back to `.trellis-db.json`. */
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
/** Directory containing `.trellis-db.json`. */
|
|
19
|
+
configDir?: string;
|
|
20
|
+
/** Default tenant for all tool calls (e.g. embed-design-review). */
|
|
21
|
+
tenant?: string;
|
|
22
|
+
/** Playground `?room=` slug → tenant `embed-{slug}`. */
|
|
23
|
+
playgroundRoom?: string;
|
|
24
|
+
/** Suppress stderr startup line (for harness / IDE configs). */
|
|
25
|
+
quiet?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface ResolvedRoomMcpBridgeConfig {
|
|
28
|
+
url: string;
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
tenantId?: string | null;
|
|
31
|
+
}
|
|
32
|
+
/** Normalize a room base URL to the Streamable HTTP MCP endpoint. */
|
|
33
|
+
export declare function resolveRoomMcpUrl(baseUrl: string): string;
|
|
34
|
+
/** Resolve room URL + API key from CLI flags or `.trellis-db.json`. */
|
|
35
|
+
export declare function resolveBridgeConfig(opts: RoomMcpBridgeOptions): ResolvedRoomMcpBridgeConfig;
|
|
36
|
+
/** Connect an MCP client to a remote Trellis room. */
|
|
37
|
+
export declare function connectRemoteRoomClient(config: ResolvedRoomMcpBridgeConfig): Promise<{
|
|
38
|
+
client: Client;
|
|
39
|
+
transport: StreamableHTTPClientTransport;
|
|
40
|
+
}>;
|
|
41
|
+
/** Local MCP server that forwards tool calls to a remote room client. */
|
|
42
|
+
export declare function createRoomMcpProxyServer(remote: Client): Server;
|
|
43
|
+
/** Run stdio MCP bridge until stdin closes or the process is interrupted. */
|
|
44
|
+
export declare function runRoomMcpBridge(opts: RoomMcpBridgeOptions): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/mcp/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAYnE,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,2BAA2B;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,qEAAqE;AACrE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMzD;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,oBAAoB,GACzB,2BAA2B,CA2C7B;AAED,sDAAsD;AACtD,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,6BAA6B,CAAA;CAAE,CAAC,CAoBvE;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAa/D;AAED,6EAA6E;AAC7E,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BhF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP discovery tools — list/get/connect registered Trellis rooms.
|
|
3
|
+
*
|
|
4
|
+
* Mounted at `/gateway/mcp` on room servers and on `trellis mcp gateway serve`.
|
|
5
|
+
*
|
|
6
|
+
* @module trellis/mcp
|
|
7
|
+
*/
|
|
8
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
+
import { type RoomRegistryOptions } from './room-registry.js';
|
|
10
|
+
export interface DiscoveryMcpContext extends RoomRegistryOptions {
|
|
11
|
+
/** Request origin for OAuth metadata hints (e.g. https://room.sprites.app). */
|
|
12
|
+
origin?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createDiscoveryMcpServer(ctx?: DiscoveryMcpContext): McpServer;
|
|
15
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/mcp/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAUD,wBAAgB,wBAAwB,CAAC,GAAG,GAAE,mBAAwB,GAAG,SAAS,CAmLjF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `.trellis-mcp-gateway.json` — local config for a deployed discovery gateway.
|
|
3
|
+
*
|
|
4
|
+
* @module trellis/mcp
|
|
5
|
+
*/
|
|
6
|
+
export declare const GATEWAY_CONFIG_FILE = ".trellis-mcp-gateway.json";
|
|
7
|
+
export interface McpGatewayConfig {
|
|
8
|
+
/** Sprites URL (API origin). */
|
|
9
|
+
url: string;
|
|
10
|
+
/** Public URL agents use (e.g. https://mcp.trellis.computer). */
|
|
11
|
+
publicUrl: string;
|
|
12
|
+
spriteName: string;
|
|
13
|
+
deployedAt: string;
|
|
14
|
+
port?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function gatewayConfigPath(dir?: string): string;
|
|
17
|
+
export declare function hasGatewayConfig(dir?: string): boolean;
|
|
18
|
+
export declare function readGatewayConfig(dir?: string): McpGatewayConfig | null;
|
|
19
|
+
export declare function writeGatewayConfig(config: McpGatewayConfig, dir?: string): void;
|
|
20
|
+
//# sourceMappingURL=gateway-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-config.d.ts","sourceRoot":"","sources":["../../src/mcp/gateway-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,iBAAiB,CAAC,GAAG,SAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,SAAM,GAAG,OAAO,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,SAAM,GAAG,gBAAgB,GAAG,IAAI,CAQpE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,SAAM,GAAG,IAAI,CAM5E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone MCP discovery gateway HTTP server.
|
|
3
|
+
*
|
|
4
|
+
* `trellis mcp gateway serve` — discovery tools without a full room kernel.
|
|
5
|
+
*
|
|
6
|
+
* @module trellis/mcp
|
|
7
|
+
*/
|
|
8
|
+
export interface GatewayServeOptions {
|
|
9
|
+
port?: number;
|
|
10
|
+
hostname?: string;
|
|
11
|
+
configDir?: string;
|
|
12
|
+
publicUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createGatewayFetchHandler(opts?: GatewayServeOptions): Promise<(req: Request) => Promise<Response>>;
|
|
15
|
+
export declare function startGatewayServer(opts?: GatewayServeOptions): Promise<{
|
|
16
|
+
port: number;
|
|
17
|
+
stop: () => void;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=gateway-serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-serve.d.ts","sourceRoot":"","sources":["../../src/mcp/gateway-serve.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,yBAAyB,CAC7C,IAAI,GAAE,mBAAwB,GAC7B,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAuE9C;AAED,wBAAsB,kBAAkB,CACtC,IAAI,GAAE,mBAAwB,GAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,CA+B7C"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
corsPreflightResponse,
|
|
3
|
+
discoveryMcpGateway,
|
|
4
|
+
mcpServiceDocument,
|
|
5
|
+
oauthAuthorizationServerMetadata,
|
|
6
|
+
oauthProtectedResourceMetadata,
|
|
7
|
+
withCors
|
|
8
|
+
} from "../chunk-53PDCTJ3.js";
|
|
9
|
+
import "../chunk-CMSFD6OV.js";
|
|
10
|
+
import "../chunk-GCQF75T4.js";
|
|
11
|
+
import "../chunk-YC5I32PS.js";
|
|
12
|
+
import "../chunk-UZRUP7QW.js";
|
|
13
|
+
import "../chunk-JA7AIHRK.js";
|
|
14
|
+
import "../chunk-SZ3VAB5P.js";
|
|
15
|
+
import "../chunk-OB4CMMX6.js";
|
|
16
|
+
import "../chunk-V4YCJDYL.js";
|
|
17
|
+
import "../chunk-6CTA6MCE.js";
|
|
18
|
+
import "../chunk-G3XIHPSQ.js";
|
|
19
|
+
import "../chunk-2ESYSVXG.js";
|
|
20
|
+
|
|
21
|
+
// src/mcp/gateway-serve.ts
|
|
22
|
+
async function createGatewayFetchHandler(opts = {}) {
|
|
23
|
+
const configDir = opts.configDir ?? ".";
|
|
24
|
+
const discoveryCtx = { configDir };
|
|
25
|
+
return async (req) => {
|
|
26
|
+
if (req.method === "OPTIONS") {
|
|
27
|
+
return corsPreflightResponse(req);
|
|
28
|
+
}
|
|
29
|
+
const url = new URL(req.url);
|
|
30
|
+
const path = url.pathname.replace(/\/$/, "") || "/";
|
|
31
|
+
const origin = opts.publicUrl?.replace(/\/$/, "") || `${url.protocol}//${url.host}`;
|
|
32
|
+
const respond = (res) => withCors(req, res);
|
|
33
|
+
if (path === "/health") {
|
|
34
|
+
return respond(
|
|
35
|
+
new Response(
|
|
36
|
+
JSON.stringify({
|
|
37
|
+
status: "ok",
|
|
38
|
+
service: "trellis-mcp-gateway",
|
|
39
|
+
mcp: "/mcp",
|
|
40
|
+
gateway: "/gateway/mcp"
|
|
41
|
+
}),
|
|
42
|
+
{ headers: { "Content-Type": "application/json" } }
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (path === "/.well-known/oauth-protected-resource") {
|
|
47
|
+
return respond(
|
|
48
|
+
new Response(JSON.stringify(oauthProtectedResourceMetadata(origin)), {
|
|
49
|
+
headers: { "Content-Type": "application/json" }
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (path === "/.well-known/oauth-authorization-server") {
|
|
54
|
+
return respond(
|
|
55
|
+
new Response(JSON.stringify(oauthAuthorizationServerMetadata(origin)), {
|
|
56
|
+
headers: { "Content-Type": "application/json" }
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (path === "/mcp" || path === "/gateway/mcp") {
|
|
61
|
+
const res = await discoveryMcpGateway.handle(req, {
|
|
62
|
+
...discoveryCtx,
|
|
63
|
+
origin,
|
|
64
|
+
gatewayPublicUrl: origin
|
|
65
|
+
});
|
|
66
|
+
return respond(res);
|
|
67
|
+
}
|
|
68
|
+
if (path === "/") {
|
|
69
|
+
return respond(
|
|
70
|
+
new Response(JSON.stringify(mcpServiceDocument(origin, {})), {
|
|
71
|
+
headers: { "Content-Type": "application/json" }
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return respond(
|
|
76
|
+
new Response(JSON.stringify({ error: "Not Found" }), {
|
|
77
|
+
status: 404,
|
|
78
|
+
headers: { "Content-Type": "application/json" }
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async function startGatewayServer(opts = {}) {
|
|
84
|
+
const port = opts.port ?? 3940;
|
|
85
|
+
const fetch = await createGatewayFetchHandler(opts);
|
|
86
|
+
if (typeof globalThis.Bun !== "undefined") {
|
|
87
|
+
const server2 = globalThis.Bun.serve({
|
|
88
|
+
port,
|
|
89
|
+
hostname: opts.hostname ?? "0.0.0.0",
|
|
90
|
+
fetch
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
port: server2.port ?? port,
|
|
94
|
+
stop: () => server2.stop(true)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const { startNodeServer } = await import("../server/node-adapter.js");
|
|
98
|
+
const server = await startNodeServer({
|
|
99
|
+
port,
|
|
100
|
+
hostname: opts.hostname,
|
|
101
|
+
fetch,
|
|
102
|
+
websocket: {
|
|
103
|
+
open() {
|
|
104
|
+
},
|
|
105
|
+
message() {
|
|
106
|
+
},
|
|
107
|
+
close() {
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
port: server.port,
|
|
113
|
+
stop: () => server.stop(true)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
createGatewayFetchHandler,
|
|
118
|
+
startGatewayServer
|
|
119
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact graph summary for room MCP — token-efficient agent orientation.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors trellis-client GET /api/graph/summary shape for skill portability.
|
|
5
|
+
*
|
|
6
|
+
* @module trellis/mcp
|
|
7
|
+
*/
|
|
8
|
+
import type { TrellisKernel } from '../core/kernel/trellis-kernel.js';
|
|
9
|
+
export interface RoomGraphSummaryOptions {
|
|
10
|
+
limit?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface RoomGraphSummary {
|
|
13
|
+
health: {
|
|
14
|
+
status: 'ok';
|
|
15
|
+
factCount: number;
|
|
16
|
+
linkCount: number;
|
|
17
|
+
entityCount: number;
|
|
18
|
+
ops: number;
|
|
19
|
+
tenantId: string | null;
|
|
20
|
+
};
|
|
21
|
+
entityTypes: Array<{
|
|
22
|
+
type: string;
|
|
23
|
+
count: number;
|
|
24
|
+
}>;
|
|
25
|
+
ontologies: {
|
|
26
|
+
total: number;
|
|
27
|
+
system: string[];
|
|
28
|
+
user: string[];
|
|
29
|
+
};
|
|
30
|
+
topAttributes: Array<{
|
|
31
|
+
attribute: string;
|
|
32
|
+
distinctCount: number;
|
|
33
|
+
cardinality: 'one' | 'many';
|
|
34
|
+
}>;
|
|
35
|
+
links: {
|
|
36
|
+
total: number;
|
|
37
|
+
relations: string[];
|
|
38
|
+
};
|
|
39
|
+
recentMutations: Array<{
|
|
40
|
+
kind: string;
|
|
41
|
+
agentId: string;
|
|
42
|
+
timestamp: string;
|
|
43
|
+
entityId?: string;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export declare function buildRoomGraphSummary(kernel: TrellisKernel, tenantId: string | null, opts?: RoomGraphSummaryOptions): RoomGraphSummary;
|
|
47
|
+
//# sourceMappingURL=graph-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-summary.d.ts","sourceRoot":"","sources":["../../src/mcp/graph-summary.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE;QACN,MAAM,EAAE,IAAI,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;KACzB,CAAC;IACF,WAAW,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,CAAC;IACF,aAAa,EAAE,KAAK,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,KAAK,GAAG,MAAM,CAAC;KAC7B,CAAC,CAAC;IACH,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC9C,eAAe,EAAE,KAAK,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ;AAID,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,IAAI,GAAE,uBAA4B,GACjC,gBAAgB,CAgFlB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Room MCP audit — Decision entities for agent write attribution.
|
|
3
|
+
*
|
|
4
|
+
* @module trellis/mcp
|
|
5
|
+
*/
|
|
6
|
+
import type { MiddlewareContext } from '../core/kernel/middleware.js';
|
|
7
|
+
import type { TrellisKernel } from '../core/kernel/trellis-kernel.js';
|
|
8
|
+
/**
|
|
9
|
+
* Persist a Decision entity for an MCP write (fire-and-forget safe).
|
|
10
|
+
*/
|
|
11
|
+
export declare function recordRoomMcpAudit(kernel: TrellisKernel, agentId: string, toolName: string, params: Record<string, unknown>, resultText: string, wctx: Partial<MiddlewareContext>, relatedEntities?: string[]): Promise<string | null>;
|
|
12
|
+
/** Schedule audit without blocking the tool response. */
|
|
13
|
+
export declare function scheduleRoomMcpAudit(kernelPromise: Promise<TrellisKernel>, agentId: string, toolName: string, params: Record<string, unknown>, resultText: string, wctx: Partial<MiddlewareContext>, relatedEntities?: string[]): void;
|
|
14
|
+
//# sourceMappingURL=room-audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-audit.d.ts","sourceRoot":"","sources":["../../src/mcp/room-audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAkBtE;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,EAChC,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0BxB;AAED,yDAAyD;AACzD,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,EACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,EAChC,eAAe,CAAC,EAAE,MAAM,EAAE,GACzB,IAAI,CAYN"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for room MCP tools — lanes, rate limits, write context.
|
|
3
|
+
*
|
|
4
|
+
* @module trellis/mcp
|
|
5
|
+
*/
|
|
6
|
+
import type { MiddlewareContext } from '../core/kernel/middleware.js';
|
|
7
|
+
import type { AuthContext } from '../server/auth.js';
|
|
8
|
+
import { type UsageMeter } from '../server/usage-meter.js';
|
|
9
|
+
/** Normalize lane / agent attribution for draft writes. */
|
|
10
|
+
export declare function resolveWriteAgentId(lane: string | undefined, auth: AuthContext, headerLane?: string | null): string;
|
|
11
|
+
export declare function writeContext(lane: string | undefined, auth: AuthContext, headerLane?: string | null): Partial<MiddlewareContext>;
|
|
12
|
+
export declare function assertMcpBudget(meter: UsageMeter | null, tenantId: string | null): void;
|
|
13
|
+
export declare function playgroundRoomToTenant(slug: string): string;
|
|
14
|
+
export interface ResolveMcpTenantOptions {
|
|
15
|
+
/** Session default from `?tenantId=` on the MCP HTTP URL or auth JWT. */
|
|
16
|
+
defaultTenantId?: string | null;
|
|
17
|
+
/** `X-Trellis-Tenant` header on the MCP request. */
|
|
18
|
+
headerTenant?: string | null;
|
|
19
|
+
/** Per-tool explicit tenant id. */
|
|
20
|
+
toolTenantId?: string;
|
|
21
|
+
/** Playground `?room=` slug → `embed-{slug}`. */
|
|
22
|
+
roomSlug?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve effective tenant for a room MCP tool call.
|
|
26
|
+
* Priority: tool `tenantId` → tool `room` → header → URL/auth default → null (showcase).
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveMcpTenantId(opts: ResolveMcpTenantOptions): string | null;
|
|
29
|
+
export declare function handleMcpError(err: unknown): {
|
|
30
|
+
content: {
|
|
31
|
+
type: "text";
|
|
32
|
+
text: string;
|
|
33
|
+
}[];
|
|
34
|
+
} | null;
|
|
35
|
+
/** Stable CollectionMeta id used by Playground (`collectionMeta:<slug>`). */
|
|
36
|
+
export declare const COLLECTION_META_PREFIX: "collectionMeta:";
|
|
37
|
+
export declare function collectionMetaIdFromSlug(slug: string): string;
|
|
38
|
+
export declare function resolveCollectionId(opts: {
|
|
39
|
+
collectionSlug?: string;
|
|
40
|
+
collectionId?: string;
|
|
41
|
+
}): string;
|
|
42
|
+
export declare function collectionSlugFromMetaId(collectionId: string): string | null;
|
|
43
|
+
//# sourceMappingURL=room-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-helpers.d.ts","sourceRoot":"","sources":["../../src/mcp/room-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,0BAA0B,CAAC;AAElC,2DAA2D;AAC3D,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACzB,MAAM,CAYR;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,IAAI,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAI5B;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,UAAU,GAAG,IAAI,EACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,IAAI,CAGN;AAKD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,uBAAuB,GAC5B,MAAM,GAAG,IAAI,CAWf;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO;;;;;SAK1C;AAED,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,EAAG,iBAA0B,CAAC;AAEjE,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO7D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,CAQT;AAED,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI5E"}
|