@xfey/tutti 0.1.1 → 0.1.2
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/dist/server-shell/cli/host-server-runtime.js +14 -0
- package/dist/server-shell/http/create-server.d.ts +6 -0
- package/dist/server-shell/http/create-server.js +3 -0
- package/dist/server-shell/http/routes/health.d.ts +4 -0
- package/dist/server-shell/http/routes/health.js +2 -2
- package/package.json +1 -1
|
@@ -246,6 +246,7 @@ export async function startForegroundHostServer(options) {
|
|
|
246
246
|
});
|
|
247
247
|
let close = async () => { };
|
|
248
248
|
let relayTunnel;
|
|
249
|
+
let relayTunnelConnected = false;
|
|
249
250
|
const localControl = {
|
|
250
251
|
token,
|
|
251
252
|
requestShutdown: () => {
|
|
@@ -306,6 +307,12 @@ export async function startForegroundHostServer(options) {
|
|
|
306
307
|
});
|
|
307
308
|
app = options.createServer({
|
|
308
309
|
agentContext: { tokenRegistry: agentContextTokenRegistry },
|
|
310
|
+
health: {
|
|
311
|
+
readiness: {
|
|
312
|
+
relay: () => (relayTunnelConnected ? "connected" : "not_connected"),
|
|
313
|
+
store: () => "ready",
|
|
314
|
+
},
|
|
315
|
+
},
|
|
309
316
|
localControl,
|
|
310
317
|
now,
|
|
311
318
|
projectApi: {
|
|
@@ -397,6 +404,7 @@ export async function startForegroundHostServer(options) {
|
|
|
397
404
|
close = () => {
|
|
398
405
|
closePromise ??= (async () => {
|
|
399
406
|
try {
|
|
407
|
+
relayTunnelConnected = false;
|
|
400
408
|
relayTunnel?.close(1000, "host closing");
|
|
401
409
|
await app.close();
|
|
402
410
|
}
|
|
@@ -424,6 +432,12 @@ export async function startForegroundHostServer(options) {
|
|
|
424
432
|
trusted_relay_metadata_store: trustedMetadataStore,
|
|
425
433
|
attachRelayTunnel: (tunnel) => {
|
|
426
434
|
relayTunnel = tunnel;
|
|
435
|
+
relayTunnelConnected = true;
|
|
436
|
+
void tunnel.closed.finally(() => {
|
|
437
|
+
if (relayTunnel === tunnel) {
|
|
438
|
+
relayTunnelConnected = false;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
427
441
|
},
|
|
428
442
|
closed,
|
|
429
443
|
close,
|
|
@@ -7,6 +7,12 @@ export type HostServerOptions = {
|
|
|
7
7
|
agentContext?: false | {
|
|
8
8
|
tokenRegistry?: AgentContextTokenRegistry;
|
|
9
9
|
};
|
|
10
|
+
health?: {
|
|
11
|
+
readiness?: {
|
|
12
|
+
relay?: () => "not_connected" | "connected";
|
|
13
|
+
store?: () => "not_configured" | "ready";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
10
16
|
logger?: false;
|
|
11
17
|
localControl?: HostLocalControlOptions;
|
|
12
18
|
now?: () => Date;
|
|
@@ -12,6 +12,9 @@ export function createHostServer(options = {}) {
|
|
|
12
12
|
: fastify({ logger: createRedactedLoggerOptions("tutti-host") });
|
|
13
13
|
registerApiErrorHandler(app);
|
|
14
14
|
registerHostHealthRoute(app, {
|
|
15
|
+
...(options.health?.readiness === undefined
|
|
16
|
+
? {}
|
|
17
|
+
: { readiness: options.health.readiness }),
|
|
15
18
|
now: options.now ?? (() => new Date()),
|
|
16
19
|
serviceVersion: options.serviceVersion ?? "0.0.0",
|
|
17
20
|
});
|
|
@@ -33,8 +33,8 @@ export function registerHostHealthRoute(app, options) {
|
|
|
33
33
|
time: options.now().toISOString(),
|
|
34
34
|
readiness: {
|
|
35
35
|
api: "ready",
|
|
36
|
-
store: "not_configured",
|
|
37
|
-
relay: "not_connected",
|
|
36
|
+
store: options.readiness?.store?.() ?? "not_configured",
|
|
37
|
+
relay: options.readiness?.relay?.() ?? "not_connected",
|
|
38
38
|
},
|
|
39
39
|
}));
|
|
40
40
|
}
|