@foldkit/vite-plugin 0.27.1 → 0.28.0-canary.1f6776fa7ece
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/README.md +7 -7
- package/dist/brandDist.d.ts.map +1 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/buildToken.d.ts.map +1 -1
- package/dist/devToolsOverlay.d.ts.map +1 -1
- package/dist/foldkitPackages.d.ts.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +158 -123
- package/dist/relayRegistry.d.ts +8 -6
- package/dist/relayRegistry.d.ts.map +1 -1
- package/dist/relayRegistry.js +87 -65
- package/dist/relayRegistryTrust.d.ts +19 -0
- package/dist/relayRegistryTrust.d.ts.map +1 -0
- package/dist/relayRegistryTrust.js +456 -0
- package/dist/ssr.d.ts.map +1 -1
- package/dist/viewIdentity.d.ts.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -171,10 +171,10 @@ When one Vite app build produces the client and server artifacts, the plugin gen
|
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
173
|
// src/entry.server.ts
|
|
174
|
-
Server.renderToString(
|
|
174
|
+
Server.renderToString(ApplicationBlock, { Flags }, { flags })
|
|
175
175
|
|
|
176
176
|
// src/entry.ts
|
|
177
|
-
Runtime.hydrate(
|
|
177
|
+
Runtime.hydrate(program)
|
|
178
178
|
```
|
|
179
179
|
|
|
180
180
|
Use the `buildId` option or `FOLDKIT_BUILD_ID` as an explicit override when client and server build in separate jobs, or when the id should name a deployment in another system:
|
|
@@ -203,19 +203,19 @@ To include the overlay in production, list `@foldkit/devtools` in regular `depen
|
|
|
203
203
|
|
|
204
204
|
During development, the plugin starts a WebSocket relay for the [`@foldkit/devtools-mcp`](https://www.npmjs.com/package/@foldkit/devtools-mcp) server. Through the relay, an AI agent can inspect a running Foldkit app and dispatch Messages.
|
|
205
205
|
|
|
206
|
-
By default, the relay
|
|
206
|
+
By default, the relay listens at `/__foldkit/devtools-mcp` on its own loopback port. WebSocket handlers on the Vite dev server cannot close its connection. Each dev server publishes its relay's address to a private registry, so the MCP server can find it without a configured port.
|
|
207
207
|
|
|
208
|
-
The
|
|
208
|
+
The registry lives under `XDG_RUNTIME_DIR` when set, `~/.cache` on macOS and Linux, or the user's temporary directory on Windows. `FOLDKIT_DEVTOOLS_RELAY_DIRECTORY` selects another directory. On Windows, that directory must be a direct child of the user's temporary directory.
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
For automatic discovery, the relay publishes a random token with its address. The MCP client signs a connection challenge with the token and checks the relay's response before sending tool requests. The plugin refuses to publish the record if another user can read or replace the registry directory. It also rejects symlinks and junctions, checks directory ACLs on macOS, and uses PowerShell to check ownership, access rights, and reparse points on Windows. If the check fails, the plugin reports the problem in the console.
|
|
211
211
|
|
|
212
|
-
To
|
|
212
|
+
An agent on another host cannot reach the automatic loopback relay. To connect from another host, or when the registry check fails, set a fixed port in your Vite config:
|
|
213
213
|
|
|
214
214
|
```typescript
|
|
215
215
|
plugins: [foldkit({ devToolsMcpPort: 9988 })]
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
Set `FOLDKIT_DEVTOOLS_MCP_PORT` to the same value for the MCP server.
|
|
218
|
+
Set `FOLDKIT_DEVTOOLS_MCP_PORT` to the same value for the MCP server. If the agent runs elsewhere, also set `FOLDKIT_DEVTOOLS_MCP_HOST` to the dev server's host. A fixed port listens on every interface without a token. Do not use it on a shared or untrusted network.
|
|
219
219
|
|
|
220
220
|
`devToolsMcpPort: false` disables the relay. The relay does not start during Vitest runs or in production builds.
|
|
221
221
|
|
package/dist/brandDist.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brandDist.d.ts","
|
|
1
|
+
{"version":3,"file":"brandDist.d.ts","sources":["../src/brandDist.ts"],"names":[],"mappings":"AAQA,sEAAsE;AACtE,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAC,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,gBAChB,MAAM,eACN,MAAM,KAClB,eAyBF,CAAA"}
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","
|
|
1
|
+
{"version":3,"file":"build.d.ts","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAA;AAS1C,OAAO,QAA8B,MAAM,WAAW,CAAA;AAEtD,OAAO,KAAK,EAGV,MAAM,EAGP,MAAM,MAAM,CAAA;AAEb,mEAAmE;AACnE,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAC,CAAA;AAEF,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,2HAA2H;IAC3H,WAAW,EAAE,MAAM,CAAA;IACnB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,uBAAuB,CAAA;CAC9C,CAAC,CAAA;AAEF,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,0BAA0B,CAAA;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;OAIG;;IAEH;;;;OAIG;;IAEH,+EAA+E;;IAE/E,2DAA2D;;IAE3D,6EAA6E;;EAE7E,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAA;AAEnE,iFAAiF;AACjF,eAAO,MAAM,oBAAoB;IAC/B,+CAA+C;;IAE/C,kDAAkD;;IAElD,iDAAiD;;IAEjD,kDAAkD;;IAElD,0DAA0D;;QAtC1D;;;;WAIG;;QAEH;;;;WAIG;;QAEH,+EAA+E;;QAE/E,2DAA2D;;QAE3D,6EAA6E;;;EAwB7E,CAAA;AAEF,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAA;AAEnE,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAA;IACnB,uDAAuD;IACvD,aAAa,EAAE,OAAO,uBAAuB,CAAA;IAC7C;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;CAC7C,CAAC,CAAA;AAcF,eAAO,MAAM,YAAY,SACjB,MAAM,aACD,MAAM,YACR,OAAO,QAAQ,KACvB,MAQF,CAAA;AA6FD,eAAO,MAAM,eAAe,oBACT,MAAM,QACjB,MAAM,UACJ,MAAM,YACL,OAAO,QAAQ,KACvB,QAAQ,CAAC;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA0CrC,CAAA;AAqLD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,gBACV,MAAM,WACV,mBAAmB,KAC3B,MAAM,CAAC,eAAe,CAwSxB,CAAA"}
|
package/dist/buildToken.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildToken.d.ts","
|
|
1
|
+
{"version":3,"file":"buildToken.d.ts","sources":["../src/buildToken.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAA+B,MAAM,MAAM,CAAA;AAoC/D;;;;GAIG;AACH,eAAO,MAAM,cAAc,gBAAiB,MAAM,KAAG,MAAM,GAAG,SAQ7D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,YACnB,OAAO,GAAG,OAAO,eACb,MAAM,KAClB,MAAM,GAAG,SAMX,CAAA;AA0ID;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAClB,MAAM,wCAEf,KAAK,CAAC,MAAM,CA+Dd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devToolsOverlay.d.ts","
|
|
1
|
+
{"version":3,"file":"devToolsOverlay.d.ts","sources":["../src/devToolsOverlay.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAoIlC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAC7B,OAAO,GAAG,OAAO,QACpB,MAAM,KACX,OAQF,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,QAAO,MAmExC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foldkitPackages.d.ts","
|
|
1
|
+
{"version":3,"file":"foldkitPackages.d.ts","sources":["../src/foldkitPackages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,MAAM,CAAA;AAS9D;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,cAClC,MAAM,KAChB,OAKA,CAAA;AA8CH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,SACzB,MAAM,WACH,OAAO,kBACA,UAAU,KACzB,OAAO,CAAC,QAAQ,CAAC;IAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAoCxE,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,13 +8,14 @@ export { type ViewIdentityTransformResult, foldkitViewIdentity, transformViewIde
|
|
|
8
8
|
/** Options for the `foldkit` Vite plugin. */
|
|
9
9
|
export type FoldkitPluginOptions = Readonly<{
|
|
10
10
|
/**
|
|
11
|
-
* By default, the
|
|
12
|
-
* address for the MCP server to find.
|
|
13
|
-
*
|
|
11
|
+
* By default, the DevTools MCP relay listens on a loopback port of its own
|
|
12
|
+
* and publishes its address for the MCP server to find. Automatically
|
|
13
|
+
* discovered addresses carry an access token.
|
|
14
14
|
*
|
|
15
15
|
* A number starts an unauthenticated listener on that port on every
|
|
16
16
|
* interface; set `FOLDKIT_DEVTOOLS_MCP_PORT` in the MCP server to match.
|
|
17
|
-
*
|
|
17
|
+
* Do not use a fixed port on a shared or untrusted network. `false`
|
|
18
|
+
* disables the relay. Vitest never starts it.
|
|
18
19
|
*/
|
|
19
20
|
devToolsMcpPort?: number | false;
|
|
20
21
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EAEV,MAAM,EAIP,MAAM,MAAM,CAAA;AAQb,OAAO,EAAE,KAAK,mBAAmB,EAAgB,MAAM,YAAY,CAAA;AAMnE,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,UAAU,CAAA;AAG7D,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,YAAY,GACb,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EACL,KAAK,2BAA2B,EAChC,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAE1B,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IAChC;;;;;;;OAOG;IACH,GAAG,CAAC,EAAE,IAAI,CACR,iBAAiB,EACjB,SAAS,GAAG,gBAAgB,GAAG,aAAa,GAAG,aAAa,CAC7D,GACC,CACI,QAAQ,CAAC;QACP,kFAAkF;QAClF,WAAW,EAAE,MAAM,CAAA;QACnB,WAAW,CAAC,EAAE,KAAK,CAAA;QACnB;;;;;;;;WAQG;QACH,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAA;KAC3D,CAAC,GACF,QAAQ,CAAC;QACP,kEAAkE;QAClE,WAAW,CAAC,EAAE,KAAK,CAAA;QACnB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,KAAK,CAAC,EAAE,KAAK,CAAA;KACd,CAAC,CACL,CAAA;IACH;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAC,CAAA;AA0/BF,eAAO,MAAM,OAAO,aAAa,oBAAoB,KAAQ,KAAK,CAAC,MAAM,CA+IxE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Array, Clock, ConfigProvider, Console, Crypto, Data, Duration, Effect, Exit, Fiber, HashMap,
|
|
1
|
+
import { Array, Clock, ConfigProvider, Console, Crypto, Data, Duration, Effect, Exit, Fiber, HashMap, Layer, Match, Number, Option, Order, Predicate, Queue, Ref, Schedule, Schema, Stream, pipe, } from 'effect';
|
|
2
2
|
import { Event as DevToolsEvent, EventFrame, RELAY_RECORD_VERSION, RequestFrame, Response, ResponseFrame, } from 'foldkit/devtools-protocol';
|
|
3
3
|
import { PreserveModelMessage, RequestModelMessage, RestoreModelMessage, } from 'foldkit/model-preservation';
|
|
4
|
-
import { timingSafeEqual } from 'node:crypto';
|
|
4
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
5
5
|
import { createServer as createHttpServer, } from 'node:http';
|
|
6
6
|
import { WebSocketServer } from 'ws';
|
|
7
|
+
import * as NodeChildProcessSpawner from '@effect/platform-node/NodeChildProcessSpawner';
|
|
7
8
|
import * as NodeCrypto from '@effect/platform-node/NodeCrypto';
|
|
8
9
|
import * as NodeFileSystem from '@effect/platform-node/NodeFileSystem';
|
|
9
10
|
import * as NodePath from '@effect/platform-node/NodePath';
|
|
@@ -12,6 +13,7 @@ import { foldkitBuildToken } from './buildToken.js';
|
|
|
12
13
|
import { devToolsOverlayPlugin } from './devToolsOverlay.js';
|
|
13
14
|
import { crawlFoldkitPackages } from './foldkitPackages.js';
|
|
14
15
|
import { publishRelayRecord, retireRelayRecord } from './relayRegistry.js';
|
|
16
|
+
import { relayRegistryTrust } from './relayRegistryTrust.js';
|
|
15
17
|
import { foldkitSsr } from './ssr.js';
|
|
16
18
|
import { foldkitViewIdentity } from './viewIdentity.js';
|
|
17
19
|
export { brandDistDirectory } from './brandDist.js';
|
|
@@ -68,6 +70,7 @@ const FORCE_INCLUDED_EFFECT_ENTRIES = [
|
|
|
68
70
|
'effect/String',
|
|
69
71
|
'effect/Struct',
|
|
70
72
|
'effect/SubscriptionRef',
|
|
73
|
+
'effect/Tuple',
|
|
71
74
|
'effect/Types',
|
|
72
75
|
];
|
|
73
76
|
// NOTE: Adding includes to an environment whose optimizer is otherwise disabled
|
|
@@ -84,21 +87,20 @@ const Event = Data.taggedEnum();
|
|
|
84
87
|
const makeState = Effect.gen(function* () {
|
|
85
88
|
const preservedModels = yield* Ref.make(HashMap.empty());
|
|
86
89
|
const connectedRuntimes = yield* Ref.make(HashMap.empty());
|
|
87
|
-
const
|
|
88
|
-
const clientConnections = yield* Ref.make(HashMap.empty());
|
|
89
|
-
const trackedClients = yield* Ref.make(HashSet.empty());
|
|
90
|
+
const nextSequence = yield* Ref.make(0);
|
|
90
91
|
const state = {
|
|
91
92
|
preservedModels,
|
|
92
93
|
connectedRuntimes,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
trackedClients,
|
|
94
|
+
nextSequence,
|
|
95
|
+
mcpClients: new Set(),
|
|
96
|
+
trackedClients: new WeakSet(),
|
|
96
97
|
};
|
|
97
98
|
return state;
|
|
98
99
|
});
|
|
99
100
|
const encodeResponseFrameJson = Schema.encodeUnknownSync(Schema.fromJsonString(ResponseFrame));
|
|
100
101
|
class WebSocketSendFailed extends Data.TaggedError('WebSocketSendFailed') {
|
|
101
102
|
}
|
|
103
|
+
const byConnectionOrder = Order.mapInput(Order.Number, ({ sequence }) => sequence);
|
|
102
104
|
// HANDLERS
|
|
103
105
|
const handlePreserveModelReceived = (state, payload) => Exit.match(Schema.decodeUnknownExit(PreserveModelMessage)(payload), {
|
|
104
106
|
onFailure: error => Console.warn('[foldkit:preserve] failed to decode preserve-model payload', error),
|
|
@@ -144,40 +146,34 @@ const handleBrowserEventFrameReceived = (state, data, client) => Exit.match(Sche
|
|
|
144
146
|
}),
|
|
145
147
|
});
|
|
146
148
|
const handleConnectedEvent = (state, event, client) => Effect.gen(function* () {
|
|
147
|
-
yield* Ref.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
const sequence = yield* Ref.getAndUpdate(state.nextSequence, Number.increment);
|
|
150
|
+
const connectedRuntime = {
|
|
151
|
+
runtime: event.runtime,
|
|
152
|
+
sequence,
|
|
153
|
+
client,
|
|
154
|
+
};
|
|
155
|
+
yield* Ref.update(state.connectedRuntimes, HashMap.set(event.runtime.connectionId, connectedRuntime));
|
|
152
156
|
yield* Console.log(`[foldkit:devTools] runtime connected: ${event.runtime.connectionId} (${event.runtime.title})`);
|
|
153
157
|
});
|
|
154
158
|
const handleDisconnectedEvent = (state, event) => Effect.gen(function* () {
|
|
155
159
|
yield* Ref.update(state.connectedRuntimes, HashMap.remove(event.connectionId));
|
|
156
160
|
yield* Console.log(`[foldkit:devTools] runtime disconnected: ${event.connectionId}`);
|
|
157
161
|
});
|
|
158
|
-
const pruneRuntime = (state, connectionId) => Effect.gen(function* () {
|
|
159
|
-
yield* Ref.update(state.connectedRuntimes, HashMap.remove(connectionId));
|
|
160
|
-
yield* Console.log(`[foldkit:devTools] runtime pruned (socket close): ${connectionId}`);
|
|
161
|
-
});
|
|
162
|
-
const pruneRuntimesForClient = (state, connectionIds) => Effect.forEach(Array.fromIterable(connectionIds), connectionId => pruneRuntime(state, connectionId), { discard: true });
|
|
163
162
|
const handleViteClientClosed = (state, client) => Effect.gen(function* () {
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
yield* Ref.update(state.clientConnections, HashMap.remove(client));
|
|
170
|
-
yield* Ref.update(state.trackedClients, HashSet.remove(client));
|
|
163
|
+
const prunedConnectionIds = yield* Ref.modify(state.connectedRuntimes, current => [
|
|
164
|
+
pipe(current, HashMap.filter(connectedRuntime => connectedRuntime.client === client), HashMap.keys, Array.fromIterable),
|
|
165
|
+
HashMap.filter(current, connectedRuntime => connectedRuntime.client !== client),
|
|
166
|
+
]);
|
|
167
|
+
yield* Effect.forEach(prunedConnectionIds, connectionId => Console.log(`[foldkit:devTools] runtime pruned (socket close): ${connectionId}`), { discard: true });
|
|
171
168
|
});
|
|
172
169
|
const handleBrowserResponseFrameReceived = (state, data) => Exit.match(Schema.decodeUnknownExit(ResponseFrame)(data), {
|
|
173
170
|
onFailure: error => Console.warn('[foldkit:devTools] failed to decode browser response frame', error),
|
|
174
171
|
onSuccess: frame => broadcastResponseToMcpClients(state, frame),
|
|
175
172
|
});
|
|
176
173
|
const broadcastResponseToMcpClients = (state, frame) => Effect.gen(function* () {
|
|
177
|
-
const clients = yield* Ref.get(state.mcpClients);
|
|
178
174
|
const payload = encodeResponseFrameJson(frame);
|
|
179
175
|
yield* Effect.sync(() => {
|
|
180
|
-
for (const client of
|
|
176
|
+
for (const client of state.mcpClients) {
|
|
181
177
|
if (client.readyState === client.OPEN) {
|
|
182
178
|
client.send(payload);
|
|
183
179
|
}
|
|
@@ -185,31 +181,47 @@ const broadcastResponseToMcpClients = (state, frame) => Effect.gen(function* ()
|
|
|
185
181
|
});
|
|
186
182
|
});
|
|
187
183
|
const handleMcpClientConnected = (state, client) => Effect.gen(function* () {
|
|
188
|
-
yield*
|
|
189
|
-
const total = HashSet.size(yield* Ref.get(state.mcpClients));
|
|
184
|
+
const total = yield* Effect.sync(() => state.mcpClients.add(client).size);
|
|
190
185
|
yield* Console.log(`[foldkit:devTools] MCP client connected (${total} total)`);
|
|
191
186
|
});
|
|
192
187
|
const handleMcpClientDisconnected = (state, client) => Effect.gen(function* () {
|
|
193
|
-
yield*
|
|
194
|
-
|
|
188
|
+
const remaining = yield* Effect.sync(() => {
|
|
189
|
+
state.mcpClients.delete(client);
|
|
190
|
+
return state.mcpClients.size;
|
|
191
|
+
});
|
|
195
192
|
yield* Console.log(`[foldkit:devTools] MCP client disconnected (${remaining} remaining)`);
|
|
196
193
|
});
|
|
197
194
|
const handleMcpRequestReceived = (server, state, client, raw) => Exit.match(Schema.decodeExit(Schema.fromJsonString(RequestFrame))(raw), {
|
|
198
195
|
onFailure: error => Console.warn('[foldkit:devTools] failed to decode MCP request frame', error),
|
|
199
|
-
onSuccess: frame => Match.value(frame.request).pipe(Match.tag('RequestListRuntimes', () => replyListRuntimes(state, client, frame.id)), Match.orElse(() =>
|
|
196
|
+
onSuccess: frame => Match.value(frame.request).pipe(Match.tag('RequestListRuntimes', () => replyListRuntimes(state, client, frame.id)), Match.orElse(() => routeRequestToRuntime(server, state, client, frame))),
|
|
197
|
+
});
|
|
198
|
+
const sendToRequester = (client, responseFrame) => Effect.sync(() => {
|
|
199
|
+
if (client.readyState === client.OPEN) {
|
|
200
|
+
client.send(encodeResponseFrameJson(responseFrame));
|
|
201
|
+
}
|
|
200
202
|
});
|
|
201
203
|
const replyListRuntimes = (state, client, requestId) => Effect.gen(function* () {
|
|
202
|
-
const runtimes = pipe(yield* Ref.get(state.connectedRuntimes), HashMap.values, Array.fromIterable);
|
|
203
|
-
|
|
204
|
+
const runtimes = pipe(yield* Ref.get(state.connectedRuntimes), HashMap.values, Array.fromIterable, Array.sort(byConnectionOrder), Array.map(({ runtime }) => runtime));
|
|
205
|
+
yield* sendToRequester(client, {
|
|
204
206
|
id: requestId,
|
|
205
207
|
response: Response.ResponseRuntimes({ runtimes }),
|
|
206
|
-
};
|
|
207
|
-
yield* Effect.sync(() => {
|
|
208
|
-
if (client.readyState === client.OPEN) {
|
|
209
|
-
client.send(encodeResponseFrameJson(responseFrame));
|
|
210
|
-
}
|
|
211
208
|
});
|
|
212
209
|
});
|
|
210
|
+
const routeRequestToRuntime = (server, state, client, frame) => Effect.gen(function* () {
|
|
211
|
+
const connectedRuntimes = yield* Ref.get(state.connectedRuntimes);
|
|
212
|
+
const maybeUnknownConnectionId = Option.filter(frame.maybeConnectionId, connectionId => !HashMap.has(connectedRuntimes, connectionId));
|
|
213
|
+
if (Option.isSome(maybeUnknownConnectionId)) {
|
|
214
|
+
yield* sendToRequester(client, {
|
|
215
|
+
id: frame.id,
|
|
216
|
+
response: Response.ResponseError({
|
|
217
|
+
reason: `No connected Foldkit Runtime has the id ${maybeUnknownConnectionId.value}. Call foldkit_list_runtimes for the current ids.`,
|
|
218
|
+
}),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
yield* forwardRequestToBrowsers(server, frame);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
213
225
|
const forwardRequestToBrowsers = (server, frame) => Effect.gen(function* () {
|
|
214
226
|
const encoded = yield* Schema.encodeEffect(RequestFrame)(frame);
|
|
215
227
|
yield* Effect.try({
|
|
@@ -230,19 +242,18 @@ const dispatchEvent = (server, state, event) => Match.value(event).pipe(Match.ta
|
|
|
230
242
|
McpRequestReceived: ({ client, raw }) => handleMcpRequestReceived(server, state, client, raw),
|
|
231
243
|
}));
|
|
232
244
|
// VITE WS BRIDGE
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
if (HashSet.has(tracked, client)) {
|
|
245
|
+
const trackClientClose = (state, client, enqueue) => {
|
|
246
|
+
if (state.trackedClients.has(client)) {
|
|
236
247
|
return;
|
|
237
248
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
249
|
+
state.trackedClients.add(client);
|
|
250
|
+
client.socket.on('close', () => enqueue(Event.ViteClientClosed({ client })));
|
|
251
|
+
};
|
|
241
252
|
const registerViteWsHandlers = (server, state, enqueue) => Effect.sync(() => {
|
|
242
253
|
server.ws.on('foldkit:preserve-model', payload => enqueue(Event.PreserveModelReceived({ payload })));
|
|
243
254
|
server.ws.on('foldkit:request-model', payload => enqueue(Event.RequestModelReceived({ payload })));
|
|
244
255
|
server.ws.on('foldkit:devTools:event', (data, client) => {
|
|
245
|
-
|
|
256
|
+
trackClientClose(state, client, enqueue);
|
|
246
257
|
enqueue(Event.BrowserEventFrameReceived({ data, client }));
|
|
247
258
|
});
|
|
248
259
|
server.ws.on('foldkit:devTools:response', (data) => enqueue(Event.BrowserResponseFrameReceived({ data })));
|
|
@@ -258,6 +269,21 @@ const RELAY_LOOPBACK_HOST = '127.0.0.1';
|
|
|
258
269
|
const RELAY_CONFIGURED_PORT_HOST = 'localhost';
|
|
259
270
|
const RELAY_TOKEN_PARAMETER = 'token';
|
|
260
271
|
const RELAY_TOKEN_BYTES = 32;
|
|
272
|
+
const RELAY_CHALLENGE_HEADER = 'x-foldkit-relay-challenge';
|
|
273
|
+
const RELAY_CLIENT_PROOF_HEADER = 'x-foldkit-relay-client-proof';
|
|
274
|
+
const RELAY_SERVER_PROOF_HEADER = 'X-Foldkit-Relay-Server-Proof';
|
|
275
|
+
const RELAY_CHALLENGE_PATTERN = /^[0-9a-f]{64}$/;
|
|
276
|
+
const RELAY_PROOF_PATTERN = /^[0-9a-f]{64}$/;
|
|
277
|
+
const BAD_REQUEST = 400;
|
|
278
|
+
const UNAUTHORIZED = 401;
|
|
279
|
+
const NOT_FOUND = 404;
|
|
280
|
+
const UPGRADE_REQUIRED = 426;
|
|
281
|
+
const UPGRADE_REQUIRED_BODY = 'Upgrade Required';
|
|
282
|
+
const REFUSED_UPGRADE_REASONS = {
|
|
283
|
+
[BAD_REQUEST]: 'Bad Request',
|
|
284
|
+
[UNAUTHORIZED]: 'Unauthorized',
|
|
285
|
+
[NOT_FOUND]: 'Not Found',
|
|
286
|
+
};
|
|
261
287
|
class RelayBindFailed extends Data.TaggedError('RelayBindFailed') {
|
|
262
288
|
}
|
|
263
289
|
const isPortInUse = (error) => Predicate.hasProperty(error, 'code') && error.code === 'EADDRINUSE';
|
|
@@ -303,63 +329,81 @@ const requestPresentsToken = (url, token) => {
|
|
|
303
329
|
return (expected.length === actual.length && timingSafeEqual(expected, actual));
|
|
304
330
|
});
|
|
305
331
|
};
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
332
|
+
const computeRelayProof = (token, role, challenge) => createHmac('sha256', token).update(`${role}:${challenge}`).digest('hex');
|
|
333
|
+
const requestPresentsProof = (request, token) => {
|
|
334
|
+
const challenge = request.headers[RELAY_CHALLENGE_HEADER];
|
|
335
|
+
const presented = request.headers[RELAY_CLIENT_PROOF_HEADER];
|
|
336
|
+
if (!Predicate.isString(challenge) ||
|
|
337
|
+
!RELAY_CHALLENGE_PATTERN.test(challenge) ||
|
|
338
|
+
!Predicate.isString(presented) ||
|
|
339
|
+
!RELAY_PROOF_PATTERN.test(presented)) {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
const expected = Buffer.from(computeRelayProof(token, 'client', challenge), 'hex');
|
|
343
|
+
const actual = Buffer.from(presented, 'hex');
|
|
344
|
+
return timingSafeEqual(expected, actual);
|
|
309
345
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const url = new URL(pipe(maybeResolvedUrl, Option.orElse(() => Option.map(boundPort(httpServer.address()), port => `http://${RELAY_LOOPBACK_HOST}:${port}/`)), Option.getOrThrowWith(relayHasNoBoundPort)));
|
|
315
|
-
url.protocol = 'ws:';
|
|
316
|
-
url.pathname = RELAY_PATH;
|
|
317
|
-
return withRelayToken(url, token);
|
|
346
|
+
const refuseUpgrade = (socket, status) => {
|
|
347
|
+
socket.on('error', () => socket.destroy());
|
|
348
|
+
socket.once('finish', () => socket.destroy());
|
|
349
|
+
socket.end(`HTTP/1.1 ${status} ${REFUSED_UPGRADE_REASONS[status]}\r\nConnection: close\r\nContent-Length: 0\r\n\r\n`);
|
|
318
350
|
};
|
|
319
|
-
const loopbackRelayUrl = (token) =>
|
|
351
|
+
const loopbackRelayUrl = (httpServer, token) => {
|
|
320
352
|
const port = Option.getOrThrowWith(boundPort(httpServer.address()), relayHasNoBoundPort);
|
|
321
353
|
const url = new URL(`ws://${RELAY_LOOPBACK_HOST}:${port}${RELAY_PATH}`);
|
|
322
354
|
return withRelayToken(url, token);
|
|
323
355
|
};
|
|
324
|
-
const
|
|
356
|
+
const acceptRelayUpgrades = (httpServer, id, token, enqueue) => Effect.sync(() => {
|
|
325
357
|
const wss = new WebSocketServer({ noServer: true });
|
|
326
358
|
attachRelayHandlers(wss, enqueue);
|
|
327
|
-
|
|
359
|
+
wss.on('headers', (headers, request) => {
|
|
360
|
+
const challenge = request.headers[RELAY_CHALLENGE_HEADER];
|
|
361
|
+
if (Predicate.isString(challenge) &&
|
|
362
|
+
RELAY_CHALLENGE_PATTERN.test(challenge)) {
|
|
363
|
+
headers.push(`${RELAY_SERVER_PROOF_HEADER}: ${computeRelayProof(token, 'server', challenge)}`);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
httpServer.on('upgrade', (request, socket, head) => {
|
|
328
367
|
const maybeUrl = parseRequestUrl(request);
|
|
329
368
|
if (Option.isNone(maybeUrl)) {
|
|
330
|
-
socket
|
|
369
|
+
refuseUpgrade(socket, BAD_REQUEST);
|
|
331
370
|
return;
|
|
332
371
|
}
|
|
333
372
|
const url = maybeUrl.value;
|
|
334
373
|
if (url.pathname !== RELAY_PATH) {
|
|
374
|
+
refuseUpgrade(socket, NOT_FOUND);
|
|
335
375
|
return;
|
|
336
376
|
}
|
|
337
|
-
if (!requestPresentsToken(url, token)
|
|
338
|
-
|
|
377
|
+
if (!requestPresentsToken(url, token) &&
|
|
378
|
+
!requestPresentsProof(request, token)) {
|
|
379
|
+
refuseUpgrade(socket, UNAUTHORIZED);
|
|
339
380
|
return;
|
|
340
381
|
}
|
|
341
382
|
wss.handleUpgrade(request, socket, head, client => {
|
|
342
383
|
wss.emit('connection', client, request);
|
|
343
384
|
});
|
|
385
|
+
});
|
|
386
|
+
return {
|
|
387
|
+
id,
|
|
388
|
+
wss,
|
|
389
|
+
url: loopbackRelayUrl(httpServer, token),
|
|
390
|
+
closeListener: () => {
|
|
391
|
+
httpServer.close();
|
|
392
|
+
},
|
|
344
393
|
};
|
|
345
|
-
httpServer.on('upgrade', onUpgrade);
|
|
346
|
-
const detach = () => {
|
|
347
|
-
httpServer.off('upgrade', onUpgrade);
|
|
348
|
-
httpServer.off('listening', onListening);
|
|
349
|
-
};
|
|
350
|
-
const onListening = () => {
|
|
351
|
-
resume(Effect.sync(() => ({ id, wss, url: toUrl(httpServer), detach })));
|
|
352
|
-
};
|
|
353
|
-
if (httpServer.listening) {
|
|
354
|
-
onListening();
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
httpServer.once('listening', onListening);
|
|
358
|
-
}
|
|
359
|
-
return Effect.sync(detach);
|
|
360
394
|
});
|
|
395
|
+
const answerPlainRequest = (_request, response) => {
|
|
396
|
+
response
|
|
397
|
+
.writeHead(UPGRADE_REQUIRED, {
|
|
398
|
+
Connection: 'Upgrade',
|
|
399
|
+
Upgrade: 'websocket',
|
|
400
|
+
'Content-Type': 'text/plain',
|
|
401
|
+
'Content-Length': Buffer.byteLength(UPGRADE_REQUIRED_BODY),
|
|
402
|
+
})
|
|
403
|
+
.end(UPGRADE_REQUIRED_BODY);
|
|
404
|
+
};
|
|
361
405
|
const bindLoopbackHttpServer = Effect.callback(resume => {
|
|
362
|
-
const httpServer = createHttpServer();
|
|
406
|
+
const httpServer = createHttpServer(answerPlainRequest);
|
|
363
407
|
const onBindFailed = (cause) => {
|
|
364
408
|
httpServer.close();
|
|
365
409
|
resume(Effect.fail(new RelayBindFailed({ maybePort: Option.none(), cause })));
|
|
@@ -376,17 +420,7 @@ const bindLoopbackHttpServer = Effect.callback(resume => {
|
|
|
376
420
|
httpServer.close();
|
|
377
421
|
});
|
|
378
422
|
});
|
|
379
|
-
const bindLoopbackRelay = (id, token, enqueue) => Effect.
|
|
380
|
-
const httpServer = yield* bindLoopbackHttpServer;
|
|
381
|
-
const relay = yield* hostRelayOnServer(httpServer, id, token, loopbackRelayUrl(token), enqueue);
|
|
382
|
-
return {
|
|
383
|
-
...relay,
|
|
384
|
-
detach: () => {
|
|
385
|
-
relay.detach();
|
|
386
|
-
httpServer.close();
|
|
387
|
-
},
|
|
388
|
-
};
|
|
389
|
-
});
|
|
423
|
+
const bindLoopbackRelay = (id, token, enqueue) => Effect.flatMap(bindLoopbackHttpServer, httpServer => acceptRelayUpgrades(httpServer, id, token, enqueue));
|
|
390
424
|
const bindStandaloneRelay = (port, id, enqueue) => Effect.callback(resume => {
|
|
391
425
|
const wss = new WebSocketServer({ port });
|
|
392
426
|
attachRelayHandlers(wss, enqueue);
|
|
@@ -400,7 +434,7 @@ const bindStandaloneRelay = (port, id, enqueue) => Effect.callback(resume => {
|
|
|
400
434
|
id,
|
|
401
435
|
wss,
|
|
402
436
|
url: `ws://${RELAY_CONFIGURED_PORT_HOST}:${listeningPort}`,
|
|
403
|
-
|
|
437
|
+
closeListener: () => undefined,
|
|
404
438
|
}));
|
|
405
439
|
};
|
|
406
440
|
const onBindFailed = (cause) => {
|
|
@@ -426,49 +460,50 @@ const reportRelayBindFailed = (maybePort, cause) => {
|
|
|
426
460
|
return Console.error(`[foldkit:devTools] MCP relay failed to start on ${where}; continuing without the relay`, cause);
|
|
427
461
|
}
|
|
428
462
|
};
|
|
429
|
-
const unpublishedRelayMessage = (reason) => `[foldkit:devTools] Cannot publish the MCP relay address: ${reason}. Set matching devToolsMcpPort and FOLDKIT_DEVTOOLS_MCP_PORT values for MCP access, or set FOLDKIT_DEVTOOLS_RELAY_DIRECTORY to a
|
|
463
|
+
const unpublishedRelayMessage = (reason) => `[foldkit:devTools] Cannot publish the MCP relay address: ${reason}. Set matching devToolsMcpPort and FOLDKIT_DEVTOOLS_MCP_PORT values for MCP access on a trusted network, or set FOLDKIT_DEVTOOLS_RELAY_DIRECTORY to a directory private to your user.`;
|
|
430
464
|
const publishRelay = (root, relay) => Effect.gen(function* () {
|
|
431
465
|
const startedAt = yield* Clock.currentTimeMillis;
|
|
432
|
-
yield* publishRelayRecord({
|
|
466
|
+
const directory = yield* publishRelayRecord({
|
|
433
467
|
version: RELAY_RECORD_VERSION,
|
|
434
468
|
id: relay.id,
|
|
435
469
|
root,
|
|
436
470
|
url: relay.url,
|
|
437
471
|
pid: process.pid,
|
|
438
472
|
startedAt,
|
|
439
|
-
});
|
|
440
|
-
|
|
473
|
+
}, relayRegistryTrust);
|
|
474
|
+
return Option.some(directory);
|
|
475
|
+
}).pipe(Effect.catchTag('RelayRegistryDirectoryRefused', ({ directory, reason }) => Effect.as(Console.error(unpublishedRelayMessage(`the registry directory ${directory} ${reason}`)), Option.none())), Effect.catch(error => Effect.as(Console.error(unpublishedRelayMessage('the registry could not be written'), error), Option.none())));
|
|
441
476
|
const startMcpRelay = (server, devToolsMcpPort, enqueue) => {
|
|
442
477
|
const root = server.config.root;
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return yield* Option.match(maybeHttpServer, {
|
|
455
|
-
onNone: () => bindLoopbackRelay(id, token, enqueue),
|
|
456
|
-
onSome: httpServer => hostRelayOnServer(httpServer, id, token, hostedRelayUrl(server, token), enqueue),
|
|
478
|
+
return Effect.gen(function* () {
|
|
479
|
+
const publishedDirectory = yield* Ref.make(Option.none());
|
|
480
|
+
// NOTE: A configured port accepts unauthenticated connections on every
|
|
481
|
+
// interface. An assigned port binds to loopback and requires discovery.
|
|
482
|
+
const acquire = Effect.gen(function* () {
|
|
483
|
+
const id = yield* relayId;
|
|
484
|
+
if (devToolsMcpPort !== undefined) {
|
|
485
|
+
return yield* bindStandaloneRelay(devToolsMcpPort, id, enqueue);
|
|
486
|
+
}
|
|
487
|
+
const token = yield* relayToken;
|
|
488
|
+
return yield* bindLoopbackRelay(id, token, enqueue);
|
|
457
489
|
});
|
|
490
|
+
return yield* Effect.acquireRelease(acquire, relay => Effect.gen(function* () {
|
|
491
|
+
const maybeDirectory = yield* Ref.get(publishedDirectory);
|
|
492
|
+
if (Option.isSome(maybeDirectory)) {
|
|
493
|
+
yield* retireRelayRecord(relay.id, maybeDirectory.value).pipe(Effect.catch(error => Console.error('[foldkit:devTools] could not remove the MCP relay registry record', error)));
|
|
494
|
+
}
|
|
495
|
+
relay.closeListener();
|
|
496
|
+
for (const client of relay.wss.clients) {
|
|
497
|
+
client.terminate();
|
|
498
|
+
}
|
|
499
|
+
relay.wss.close();
|
|
500
|
+
yield* Console.log('[foldkit:devTools] MCP relay stopped');
|
|
501
|
+
})).pipe(Effect.retry({
|
|
502
|
+
while: ({ cause }) => isPortInUse(cause),
|
|
503
|
+
times: RELAY_BIND_RETRY_COUNT,
|
|
504
|
+
schedule: Schedule.spaced(RELAY_BIND_RETRY_DELAY),
|
|
505
|
+
}), Effect.tap(relay => Console.log(`[foldkit:devTools] MCP relay listening at ${relayUrlForLog(relay.url)}`)), Effect.tap(relay => Effect.uninterruptible(publishRelay(root, relay).pipe(Effect.flatMap(maybeDirectory => Ref.set(publishedDirectory, maybeDirectory))))), Effect.catchTag('RelayBindFailed', ({ maybePort, cause }) => reportRelayBindFailed(maybePort, cause)));
|
|
458
506
|
});
|
|
459
|
-
return Effect.acquireRelease(acquire.pipe(Effect.tap(relay => Console.log(`[foldkit:devTools] MCP relay listening at ${relayUrlForLog(relay.url)}`)), Effect.tap(relay => publishRelay(root, relay))), relay => Effect.gen(function* () {
|
|
460
|
-
relay.detach();
|
|
461
|
-
for (const client of relay.wss.clients) {
|
|
462
|
-
client.terminate();
|
|
463
|
-
}
|
|
464
|
-
relay.wss.close();
|
|
465
|
-
yield* retireRelayRecord(root, relay.id);
|
|
466
|
-
yield* Console.log('[foldkit:devTools] MCP relay stopped');
|
|
467
|
-
})).pipe(Effect.retry({
|
|
468
|
-
while: ({ cause }) => isPortInUse(cause),
|
|
469
|
-
times: RELAY_BIND_RETRY_COUNT,
|
|
470
|
-
schedule: Schedule.spaced(RELAY_BIND_RETRY_DELAY),
|
|
471
|
-
}), Effect.catchTag('RelayBindFailed', ({ maybePort, cause }) => reportRelayBindFailed(maybePort, cause)));
|
|
472
507
|
};
|
|
473
508
|
// NOTE: A Vitest run can override its mode, but still carries Vitest plugins.
|
|
474
509
|
// Starting a relay there can contend with the project's dev server.
|
|
@@ -499,7 +534,7 @@ const main = (server, events, options) => Effect.gen(function* () {
|
|
|
499
534
|
* an array; Vite flattens nested plugin arrays, so `plugins: [foldkit()]`
|
|
500
535
|
* keeps working.
|
|
501
536
|
*/
|
|
502
|
-
const relayRegistryLayer = Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeCrypto.layer);
|
|
537
|
+
const relayRegistryLayer = Layer.provideMerge(NodeChildProcessSpawner.layer, Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeCrypto.layer));
|
|
503
538
|
export const foldkit = (options = {}) => {
|
|
504
539
|
// NOTE: During a Vite restart, old and new servers overlap. Separate queues
|
|
505
540
|
// and fibers keep their events and shutdowns attached to the right server.
|
package/dist/relayRegistry.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect, FileSystem, Path, type PlatformError } from 'effect';
|
|
2
|
+
import type { ChildProcessSpawner } from 'effect/process';
|
|
2
3
|
import { RelayRecord } from 'foldkit/devtools-protocol';
|
|
3
|
-
|
|
4
|
+
import { type RelayRegistryTrust } from './relayRegistryTrust.js';
|
|
5
|
+
type RelayRegistryServices = FileSystem.FileSystem | Path.Path;
|
|
6
|
+
export type RelayPublisherServices = RelayRegistryServices | ChildProcessSpawner.ChildProcessSpawner;
|
|
4
7
|
declare const RelayRegistryDirectoryRefused_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
5
8
|
readonly _tag: "RelayRegistryDirectoryRefused";
|
|
6
9
|
} & Readonly<A>;
|
|
@@ -9,9 +12,8 @@ export declare class RelayRegistryDirectoryRefused extends RelayRegistryDirector
|
|
|
9
12
|
readonly reason: string;
|
|
10
13
|
}> {
|
|
11
14
|
}
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const retireRelayRecord: (root: string, id: string) => Effect.Effect<void, never, RelayPublisherServices>;
|
|
15
|
+
export declare const publishRelayRecord: (record: RelayRecord, trust: RelayRegistryTrust) => Effect.Effect<string, PlatformError.PlatformError | RelayRegistryDirectoryRefused, RelayPublisherServices>;
|
|
16
|
+
export declare const readRelayRecords: Effect.Effect<ReadonlyArray<RelayRecord>, never, RelayRegistryServices>;
|
|
17
|
+
export declare const retireRelayRecord: (id: string, directory: string) => Effect.Effect<void, PlatformError.PlatformError, RelayRegistryServices>;
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=relayRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayRegistry.d.ts","
|
|
1
|
+
{"version":3,"file":"relayRegistry.d.ts","sources":["../src/relayRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EACN,UAAU,EAEV,IAAI,EACJ,KAAK,aAAa,EAGnB,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAGL,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,yBAAyB,CAAA;AAUhC,KAAK,qBAAqB,GAAG,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAA;AAE9D,MAAM,MAAM,sBAAsB,GAC9B,qBAAqB,GACrB,mBAAmB,CAAC,mBAAmB,CAAA;;;;AAE3C,qBAAa,6BAA8B,SAAQ,mCAEjD;IACA,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB,CAAC;CAAG;AAkIL,eAAO,MAAM,kBAAkB,WACrB,WAAW,SACZ,kBAAkB,KACxB,MAAM,CAAC,MAAM,CACd,MAAM,EACN,aAAa,CAAC,aAAa,GAAG,6BAA6B,EAC3D,sBAAsB,CA+CpB,CAAA;AAEJ,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAC1C,aAAa,CAAC,WAAW,CAAC,EAC1B,KAAK,EACL,qBAAqB,CAOrB,CAAA;AAEF,eAAO,MAAM,iBAAiB,OACxB,MAAM,aACC,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,aAAa,EAAE,qBAAqB,CAKrE,CAAA"}
|