mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:00:42 +00:00
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
|
|
function formatBonjourInstanceName(displayName: string) {
|
|
const trimmed = displayName.trim();
|
|
if (!trimmed) {
|
|
return "OpenClaw";
|
|
}
|
|
if (/openclaw/i.test(trimmed)) {
|
|
return trimmed;
|
|
}
|
|
return `${trimmed} (OpenClaw)`;
|
|
}
|
|
|
|
export default definePluginEntry({
|
|
id: "bonjour",
|
|
name: "Bonjour Gateway Discovery",
|
|
description: "Advertise the local OpenClaw gateway over Bonjour/mDNS.",
|
|
register(api) {
|
|
api.registerGatewayDiscoveryService({
|
|
id: "bonjour",
|
|
advertise: async (ctx) => {
|
|
const [
|
|
{ startGatewayBonjourAdvertiser },
|
|
{ registerUncaughtExceptionHandler, registerUnhandledRejectionHandler },
|
|
] = await Promise.all([
|
|
import("./src/advertiser.js"),
|
|
import("openclaw/plugin-sdk/runtime"),
|
|
]);
|
|
const advertiser = await startGatewayBonjourAdvertiser(
|
|
{
|
|
instanceName: formatBonjourInstanceName(ctx.machineDisplayName),
|
|
gatewayPort: ctx.gatewayPort,
|
|
gatewayTlsEnabled: ctx.gatewayTlsEnabled,
|
|
gatewayTlsFingerprintSha256: ctx.gatewayTlsFingerprintSha256,
|
|
canvasPort: ctx.canvasPort,
|
|
sshPort: ctx.sshPort,
|
|
tailnetDns: ctx.tailnetDns,
|
|
cliPath: ctx.cliPath,
|
|
minimal: ctx.minimal,
|
|
},
|
|
{
|
|
logger: api.logger,
|
|
registerUncaughtExceptionHandler,
|
|
registerUnhandledRejectionHandler,
|
|
},
|
|
);
|
|
return { stop: advertiser.stop };
|
|
},
|
|
});
|
|
},
|
|
});
|