@kl-c/matrixos 0.2.0 → 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.
@@ -1,42 +1,32 @@
1
1
  /**
2
- * matrixos adopt [telegram]
2
+ * matrixos adopt — re-run the full MaTrixOS adoption wizard, or adopt a
3
+ * specific channel (e.g. telegram).
3
4
  *
4
- * Interactive adoption flow: asks the user for credentials, ingests them
5
- * via the same .klc-gateway.env file used by `gateway set-token`, and
6
- * validates the token against the platform API.
7
- *
8
- * Why a dedicated command and not just `gateway set-token`:
9
- * - `set-token` is the low-level "write one token" primitive
10
- * - `adopt` is the high-level "configure a channel end-to-end" UX
11
- * (token + chat id + optional validation)
12
- * - `adopt` is what a user re-runs when they want to fix or migrate
13
- * their setup
14
- *
15
- * The slash command `/adopt` in Telegram dispatches to this same flow
16
- * (see gateway-handler.ts).
17
- *
18
- * Token is NEVER hardcoded. Always prompted (masked) or read from --token.
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.
19
8
  */
20
- export interface AdoptOptions {
21
- readonly channel?: "telegram";
22
- readonly envPath?: string;
23
- readonly token?: string;
24
- readonly allowedChatId?: string;
25
- readonly nonInteractive?: boolean;
26
- /** Mock the validator (for tests). Returns true if the token is valid. */
27
- readonly validate?: (token: string) => Promise<boolean>;
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>;
28
21
  }
29
22
  export interface AdoptResult {
30
- readonly ok: boolean;
31
- readonly channel: string;
32
- readonly tokenWritten: boolean;
33
- readonly allowedChatId?: string;
34
- readonly validated: boolean;
35
- readonly message: string;
36
- /** Never the actual token — only a boolean and a length. */
37
- readonly tokenLength?: number;
23
+ ok: boolean;
24
+ channel?: AdoptChannel;
25
+ message: string;
26
+ tokenWritten?: boolean;
27
+ tokenLength?: number;
28
+ validated?: boolean;
29
+ allowedChatId?: string;
38
30
  }
39
- export declare function upsertEnvFile(path: string, updates: Record<string, string>): void;
40
- /** Default Telegram validator: hits getMe. Returns true on 200. */
41
- export declare function defaultTelegramValidate(token: string): Promise<boolean>;
42
- export declare function runAdopt(opts?: AdoptOptions): Promise<AdoptResult>;
31
+ export declare function runChannelAdopt(channel: AdoptChannel, options?: RunAdoptOptions): Promise<AdoptResult>;
32
+ export declare function runAdopt(options?: RunAdoptOptions): Promise<AdoptResult>;