@kl-c/matrixos 0.1.49 → 0.2.1

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.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * matrixos adopt — re-run the full MaTrixOS adoption wizard, or adopt a
3
+ * specific channel (e.g. telegram).
4
+ *
5
+ * "adopt" is intentionally separate from the initial install: it lets an
6
+ * existing user reconfigure providers, channels, and profile without
7
+ * reinstalling from scratch.
8
+ */
9
+ export type AdoptChannel = "telegram";
10
+ export interface RunAdoptOptions {
11
+ /** If set, only adopt this channel instead of running the full wizard. */
12
+ channel?: AdoptChannel;
13
+ /** Pre-supplied token for non-interactive channel adoption. */
14
+ token?: string;
15
+ /** Restrict gateway to a single chat id. */
16
+ allowedChatId?: string;
17
+ /** Skip interactive prompts (requires token for channel adoption). */
18
+ nonInteractive?: boolean;
19
+ /** For tests: validate the token via Telegram getMe. */
20
+ validate?: () => Promise<boolean>;
21
+ }
22
+ export interface AdoptResult {
23
+ ok: boolean;
24
+ channel?: AdoptChannel;
25
+ message: string;
26
+ tokenWritten?: boolean;
27
+ tokenLength?: number;
28
+ validated?: boolean;
29
+ allowedChatId?: string;
30
+ }
31
+ export declare function runChannelAdopt(channel: AdoptChannel, options?: RunAdoptOptions): Promise<AdoptResult>;
32
+ export declare function runAdopt(options?: RunAdoptOptions): Promise<AdoptResult>;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * matrixos gateway start [telegram]
3
+ *
4
+ * Boots the MaTrixOS gateway: loads `.klc-gateway.env`, builds a
5
+ * GatewayConfig, instantiates the requested channel adapter, registers it
6
+ * with the MatrixGateway, sets a message handler that shells out to
7
+ * `matrixos run`, and starts long-polling.
8
+ *
9
+ * Token handling: the token is read from `.klc-gateway.env` (chmod 600)
10
+ * via `loadGatewayEnv()`. NEVER hardcoded. Set it with
11
+ * `matrixos gateway set-token telegram --token "<token>"` or
12
+ * `matrixos gateway set-token telegram -i` (masked interactive prompt).
13
+ *
14
+ * The file `.klc-gateway.env` is gitignored (created by `set-token`).
15
+ */
16
+ import { MatrixGateway, TelegramAdapter, type GatewayConfig, type TelegramChannelConfig } from "@matrixos/matrix-gateway-core";
17
+ export interface GatewayStartOptions {
18
+ readonly channel?: "telegram" | "discord";
19
+ readonly envPath?: string;
20
+ readonly command?: string;
21
+ readonly args?: string[];
22
+ readonly timeoutMs?: number;
23
+ /** Mock-friendly: inject a built gateway instead of constructing one. */
24
+ readonly gatewayFactory?: (config: GatewayConfig) => MatrixGateway;
25
+ readonly adapterFactory?: (config: TelegramChannelConfig) => TelegramAdapter;
26
+ }
27
+ export interface GatewayStartResult {
28
+ readonly ok: boolean;
29
+ readonly channel: string;
30
+ readonly pid: number;
31
+ readonly envLoaded: boolean;
32
+ readonly tokenPresent: boolean;
33
+ readonly message: string;
34
+ }
35
+ /** Parse a .klc-gateway.env file (KEY=value, no shell quoting) without dotenv dep. */
36
+ export declare function loadGatewayEnv(path?: string): Record<string, string>;
37
+ export declare function buildTelegramConfig(env: Record<string, string>): TelegramChannelConfig;
38
+ export declare function buildGatewayConfig(channel: TelegramChannelConfig): GatewayConfig;
39
+ export declare function runGatewayStart(opts?: GatewayStartOptions): Promise<GatewayStartResult>;