feat(companion): add bootstrap manifest export for app packaging

This commit is contained in:
William Valentin
2026-02-26 18:40:55 -08:00
parent 62c427da4a
commit 6620afcf1f
11 changed files with 363 additions and 61 deletions
+59
View File
@@ -0,0 +1,59 @@
import type { RegisterNodeInput, SetNodeStatusInput } from './runtimeClient.js';
export type CompanionBootstrapPlatform = SetNodeStatusInput['platform'];
export interface CompanionBootstrapManifest {
schemaVersion: 1;
generatedAt: string;
gateway: {
url: string;
token?: string;
};
node: Pick<RegisterNodeInput, 'nodeId' | 'role' | 'capabilities'> & {
platform: CompanionBootstrapPlatform;
};
runtime: {
heartbeatSeconds: number;
handoffTimeoutMs: number;
autoReconnect: boolean;
};
}
export interface CreateCompanionBootstrapManifestInput {
gatewayUrl: string;
gatewayToken?: string;
nodeId: string;
role: string;
platform: CompanionBootstrapPlatform;
capabilities: string[];
heartbeatSeconds: number;
handoffTimeoutMs: number;
autoReconnect: boolean;
generatedAt?: Date;
}
export function createCompanionBootstrapManifest(
input: CreateCompanionBootstrapManifestInput,
): CompanionBootstrapManifest {
const generatedAt = (input.generatedAt ?? new Date()).toISOString();
return {
schemaVersion: 1,
generatedAt,
gateway: {
url: input.gatewayUrl,
...(input.gatewayToken && input.gatewayToken.length > 0 ? { token: input.gatewayToken } : {}),
},
node: {
nodeId: input.nodeId,
role: input.role,
platform: input.platform,
capabilities: input.capabilities,
},
runtime: {
heartbeatSeconds: input.heartbeatSeconds,
handoffTimeoutMs: input.handoffTimeoutMs,
autoReconnect: input.autoReconnect,
},
};
}