@gajae-gateway/cli 0.1.8 → 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,41 @@
1
+ /**
2
+ * Discord setup helpers: guided bot token acquisition and invite URL generation.
3
+ */
4
+ /**
5
+ * Discord OAuth2 scopes needed for the adapter.
6
+ * `bot` allows the bot to join servers.
7
+ * `applications.commands` allows slash commands (future feature).
8
+ */
9
+ export declare const DISCORD_BOT_SCOPES: string[];
10
+ /**
11
+ * Discord permissions needed for the bot to function.
12
+ * Calculated as the bitwise OR of individual permission bits.
13
+ *
14
+ * - SEND_MESSAGES (2048): Send messages in channels
15
+ * - EMBED_LINKS (16384): Embed links in messages
16
+ * - ATTACH_FILES (33554432): Attach files to messages
17
+ * - READ_MESSAGE_HISTORY (65536): Read past messages
18
+ * - MENTION_EVERYONE (131072): Mention @everyone, @here
19
+ * - MANAGE_MESSAGES (8192): Manage messages (delete, etc.)
20
+ * - ADD_REACTIONS (64): React to messages
21
+ */
22
+ export declare const DISCORD_BOT_PERMISSIONS: number;
23
+ /**
24
+ * Prints step-by-step guidance for getting a Discord bot token.
25
+ * Called before asking the user to paste the token.
26
+ */
27
+ export declare function printDiscordSetupGuide(log: (line: string) => void): void;
28
+ /**
29
+ * Generates an OAuth2 invite URL for the Discord bot.
30
+ * The URL allows server owners to authorize the bot with the required permissions.
31
+ *
32
+ * @param appId - The Discord application ID (obtained from the API)
33
+ * @returns A clickable invite URL
34
+ */
35
+ export declare function generateDiscordInviteUrl(appId: string): string;
36
+ /**
37
+ * Formats the Discord bot setup success message with the invite URL.
38
+ * Includes clear instructions for the user to authorize the bot in their server.
39
+ */
40
+ export declare function printDiscordBotReady(log: (line: string) => void, appId: string, botName?: string): void;
41
+ //# sourceMappingURL=discord-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-setup.d.ts","sourceRoot":"","sources":["../src/discord-setup.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,UAAmC,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,QAAuD,CAAC;AAE5F;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CA0BxE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CA0BvG"}
@@ -0,0 +1,13 @@
1
+ export interface GjcInstallRunResult {
2
+ readonly exitCode: number;
3
+ readonly stdout: string;
4
+ readonly stderr: string;
5
+ }
6
+ export type GjcInstallRunner = (command: readonly string[], cwd: string) => Promise<GjcInstallRunResult>;
7
+ /** Install the gateway-pinned gjc into its versioned private prefix. */
8
+ export declare function installPinnedGjc(options: {
9
+ readonly home: string;
10
+ readonly version: string;
11
+ readonly runner?: GjcInstallRunner;
12
+ }): Promise<string>;
13
+ //# sourceMappingURL=gjc-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gjc-install.d.ts","sourceRoot":"","sources":["../src/gjc-install.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAgEzG,wEAAwE;AACxE,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;CACnC,GAAG,OAAO,CAAC,MAAM,CAAC,CAuDlB"}
package/dist/main.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bun
2
- import type { OpsCycleResult } from "@gajae-gateway/protocol";
2
+ import type { OpsCycleResult, OpsDeliveriesResult, OpsSloResult } from "@gajae-gateway/protocol";
3
+ import { GajaewayClient } from "@gajae-gateway/sdk";
3
4
  import { type LaunchRestartOptions, type RunRestartOptions } from "./restart-stack";
4
5
  import { type InstallServicesOptions, type ServicePlatform } from "./services";
5
6
  import { type RunSetupOptions } from "./setup";
@@ -12,7 +13,7 @@ export declare function socketPath(home?: string | undefined): string;
12
13
  * never after, so the list is checked up front.
13
14
  */
14
15
  export declare const COMMANDS: readonly ["status", "shutdown", "chat", "daemon", "sessions", "ops", "memory", "monitors", "work", "services", "migrate", "update", "setup"];
15
- export declare const CLI_USAGE = "usage: gajaeway [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] [--notify originKey (start only)] <text>|work status <name>|work steer <name> <text>|work retire [--force] <name>|work retire --all-dead|work jobs|ops backup <path>|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restore <backupPath>|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux]|migrate [--source PATH] [--target PATH] [--dry-run]|update [--check] [--force] [--bin-dir DIR] [--no-restart]|setup [--from-env] [--adapters discord,slack,telegram] [--owner ID] [--discord-app-id ID]|setup --status (work run waits for a response; caller timeout does not end the attempt); cron timezone is an IANA zone and defaults to the gateway host's local timezone";
16
+ export declare const CLI_USAGE = "usage: gajaeway [--version] [--socket PATH] status|shutdown|chat|daemon run|sessions list [--json] [--fields a,b,c] [--limit N] [--offset N]|sessions inspect <originKey-or-index>|memory audit|memory search <query>|monitors ... (settle <eventId>|retry <eventId>|test <id> [--type T] [--payload J] [--wait[=SECONDS]])|work run|start <name> [--cwd DIR] [--resume] [--model ID|--preset NAME] [--notify originKey (start only)] <text>|work status <name>|work steer <name> <text>|work retire [--force] <name>|work retire --all-dead|work jobs [--limit N] [--offset N]|ops backup <path>|ops deliveries [--since ISO] [--state S] [--limit N] [--json]|ops redeliver <deliveryId>|ops redeliver --since <iso>|ops cycle [--json]|ops integrity|ops restart-stack [--status]|services install|repair --bin-dir DIR [--launch-agents-dir DIR] [--unit-dir DIR] [--platform darwin|linux]|migrate [--source PATH] [--target PATH] [--dry-run]|update [--check] [--force] [--bin-dir DIR] [--no-restart]|setup [--from-env] [--adapters discord,slack,telegram] [--owner ID] [--discord-app-id ID]|setup --status|setup --broker-agent [--from DIR] (work run waits for a response; caller timeout does not end the attempt); cron timezone is an IANA zone and defaults to the gateway host's local timezone";
16
17
  /** Usage errors exit 2, as `gajaeway-gateway` does; 1 stays a runtime failure. */
17
18
  export declare const USAGE_EXIT_CODE = 2;
18
19
  /** The usage text when `command` cannot be dispatched, undefined when it can. */
@@ -25,7 +26,7 @@ export declare function parseArgs(args: string[]): {
25
26
  export interface MainOptions {
26
27
  readonly services?: Pick<InstallServicesOptions, "loginPathRunner" | "writeFile">;
27
28
  /** Test seams for `setup`: the platform fetch and the prompter. */
28
- readonly setup?: Pick<RunSetupOptions, "fetch" | "prompter" | "env">;
29
+ readonly setup?: Pick<RunSetupOptions, "fetch" | "prompter" | "env" | "binDir" | "runBrokerAgent">;
29
30
  /** Test seams for `ops restart-stack`; the real path spawns the service manager. */
30
31
  readonly restartStack?: {
31
32
  readonly launch?: Omit<LaunchRestartOptions, "home">;
@@ -59,34 +60,20 @@ export declare function renderCycle(cycle: OpsCycleResult): string[];
59
60
  * healthy. Extracted so the automation-facing contract is pinned by tests.
60
61
  */
61
62
  export declare function cycleExitCode(cycle: OpsCycleResult): number;
63
+ export declare function renderSlo(result: OpsSloResult): string[];
64
+ export declare function sloExitCode(result: OpsSloResult): number;
65
+ export declare function renderDeliveries(result: OpsDeliveriesResult): string[];
62
66
  /**
63
- * The same acceptance the gateway applies at boot (`PRAGMA integrity_check`
64
- * must answer `ok`), run read-only against the backup before it replaces
65
- * anything. A 16-byte header match is not a database: a truncated or
66
- * bit-flipped file passes it, gets copied into place, and the next boot
67
- * fails while the restore already reported success.
68
- *
69
- * An empty file is also refused: SQLite treats a zero-length file as a valid
70
- * empty database and `integrity_check` answers `ok` for it, but restoring it
71
- * would boot a gateway with every table freshly created and nothing in them.
72
- *
73
- * Opening a WAL-mode backup read-only may leave empty `-wal`/`-shm` sidecars
74
- * next to the backup; `ops backup` writes delete-mode files, which gain none.
75
- */
76
- export declare function verifyBackupIntegrity(backupPath: string): void;
77
- /**
78
- * The database the gateway actually opens: `config.json` `dbPath` when set,
79
- * otherwise `<home>/gateway.db` — the same file-based resolution as the
80
- * gateway's `loadConfig`. An absent `config.json` means defaults, exactly as
81
- * at boot. A present-but-unreadable one (EACCES, EISDIR, or a dangling symlink,
82
- * which reports ENOENT while the entry exists) refuses the restore instead of
83
- * guessing, as boot refuses to start: copying a backup over the wrong file
84
- * reports success while the live database stays broken.
85
- *
86
- * `schemaVersion` is deliberately not checked: `dbPath` is a version-independent
87
- * string, and disaster recovery must not be blocked by an unrelated schema bump.
67
+ * Poll for memory operation completion. Memory operations (audit, autolink) are
68
+ * long-running and return an opRef immediately; this function polls for the result.
69
+ * If the CLI wait expires before completion, report 'still running' instead of failure.
88
70
  */
89
- export declare function restoreTargetPath(home?: string): Promise<string>;
90
- export declare function restoreDatabase(socket: string, backupPath: string): Promise<void>;
71
+ export declare function pollMemoryOp(client: Pick<GajaewayClient, "request">, opRef: string, maxWaitMs?: number, // 5 min default CLI timeout
72
+ pollIntervalMs?: number): Promise<{
73
+ status: "completed" | "failed" | "still_running";
74
+ elapsedMs: number;
75
+ result?: unknown;
76
+ error?: string;
77
+ }>;
91
78
  export declare function main(args?: string[], options?: MainOptions): Promise<void>;
92
79
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAKX,cAAc,EAQd,MAAM,yBAAyB,CAAC;AAcjC,OAAO,EAEN,KAAK,oBAAoB,EAEzB,KAAK,iBAAiB,EAItB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,sBAAsB,EAAmB,KAAK,eAAe,EAAgB,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,SAAS,CAAC;AACzD,OAAO,EAA4C,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAGrF,wBAAgB,UAAU,CAAC,IAAI,qBAA4B,GAAG,MAAM,CAEnE;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,8IAcX,CAAC;AAEX,eAAO,MAAM,SAAS,0mCACklC,CAAC;AAEzmC,kFAAkF;AAClF,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAExE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQ9F;AAMD,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,iBAAiB,GAAG,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