@automagik/omni 2.260409.6 → 2.260410.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.
- package/dist/commands/doctor.d.ts +24 -15
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/install.d.ts +28 -29
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/index.js +2151 -1947
- package/dist/install-helpers.d.ts +32 -0
- package/dist/install-helpers.d.ts.map +1 -0
- package/dist/nats-install.d.ts +11 -0
- package/dist/nats-install.d.ts.map +1 -0
- package/dist/pm2.d.ts +46 -0
- package/dist/pm2.d.ts.map +1 -1
- package/dist/server/index.js +299 -46
- package/package.json +1 -1
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
* mismatch or an auth failure after a restart.
|
|
9
9
|
*
|
|
10
10
|
* Checks performed, in order:
|
|
11
|
-
* 1. pm2-env-drift
|
|
12
|
-
* 2. cli-key-valid
|
|
13
|
-
* 3. pgserve-reachable
|
|
14
|
-
* 4. omni-db-exists
|
|
15
|
-
* 5. orphaned-data-dirs
|
|
16
|
-
* 6. version-match
|
|
17
|
-
* 7. pm2-status
|
|
11
|
+
* 1. pm2-env-drift — pm2-stored env for omni-api vs. buildRuntimeEnv()
|
|
12
|
+
* 2. cli-key-valid — stored CLI key still validates against the server
|
|
13
|
+
* 3. pgserve-reachable — TCP connect to localhost:PGSERVE_PORT
|
|
14
|
+
* 4. omni-db-exists — `omni` database exists on the embedded pgserve
|
|
15
|
+
* 5. orphaned-data-dirs — `.pgserve-data/` directories under cwd
|
|
16
|
+
* 6. version-match — CLI version vs. /api/v2/health `version` field
|
|
17
|
+
* 7. pm2-status — omni-api and omni-nats both `online` in pm2
|
|
18
|
+
* 8. pm2-max-restarts — omni-api has bounded restarts (not 0 or >= 1000)
|
|
19
|
+
* 9. pm2-logrotate-installed — pm2-logrotate module configured correctly
|
|
18
20
|
*
|
|
19
21
|
* Each check returns OK / WARN / FAIL with a one-line detail. `--fix`
|
|
20
22
|
* attempts repair for checks with a known repair path. The fix flow
|
|
@@ -22,20 +24,24 @@
|
|
|
22
24
|
* load-bearing and has a dedicated mutation-safety test.
|
|
23
25
|
*
|
|
24
26
|
* Repair paths:
|
|
25
|
-
* - pm2-env-drift:
|
|
26
|
-
*
|
|
27
|
-
* - cli-key-valid:
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* - orphaned-data-dirs:
|
|
31
|
-
*
|
|
27
|
+
* - pm2-env-drift: `pm2 delete omni-api` + re-launch with a
|
|
28
|
+
* sanitized env via `buildPm2StartArgs()`.
|
|
29
|
+
* - cli-key-valid: Delete `__primary__` from api_keys, restart
|
|
30
|
+
* with a freshly generated OMNI_API_KEY, re-
|
|
31
|
+
* validate, write new key to ~/.omni/config.json.
|
|
32
|
+
* - orphaned-data-dirs: Print `rm -rf` commands for the user to review
|
|
33
|
+
* (we never auto-delete data directories).
|
|
34
|
+
* - pm2-max-restarts: `pm2 delete` + re-launch via `buildPm2StartArgs()`
|
|
35
|
+
* so the hardened `--max-restarts` flag takes effect.
|
|
36
|
+
* - pm2-logrotate-installed: Re-run `pm2 install pm2-logrotate` + the four
|
|
37
|
+
* `pm2 set pm2-logrotate:*` commands.
|
|
32
38
|
*/
|
|
33
39
|
import { Command } from 'commander';
|
|
34
40
|
import { type Config, type ServerConfig } from '../config.js';
|
|
35
41
|
/** Severity levels reported by each check. */
|
|
36
42
|
export type CheckLevel = 'OK' | 'WARN' | 'FAIL';
|
|
37
43
|
/** Identifier used in tests and --json output. */
|
|
38
|
-
export type CheckId = 'pm2-env-drift' | 'cli-key-valid' | 'pgserve-reachable' | 'omni-db-exists' | 'orphaned-data-dirs' | 'version-match' | 'pm2-status';
|
|
44
|
+
export type CheckId = 'pm2-env-drift' | 'cli-key-valid' | 'pgserve-reachable' | 'omni-db-exists' | 'orphaned-data-dirs' | 'version-match' | 'pm2-status' | 'pm2-max-restarts' | 'pm2-logrotate-installed';
|
|
39
45
|
export interface CheckResult {
|
|
40
46
|
id: CheckId;
|
|
41
47
|
level: CheckLevel;
|
|
@@ -68,6 +74,7 @@ interface Pm2Entry {
|
|
|
68
74
|
pm_exec_path?: string;
|
|
69
75
|
args?: string[];
|
|
70
76
|
interpreter?: string;
|
|
77
|
+
max_restarts?: number;
|
|
71
78
|
OMNI_API_KEY?: string;
|
|
72
79
|
DATABASE_URL?: string;
|
|
73
80
|
PGSERVE_DATA?: string;
|
|
@@ -108,6 +115,8 @@ export interface DoctorDeps {
|
|
|
108
115
|
generateApiKey: () => string;
|
|
109
116
|
/** Sleep briefly after a pm2 restart. Tests stub to zero-delay. */
|
|
110
117
|
sleepMs: (ms: number) => Promise<void>;
|
|
118
|
+
/** Capture `pm2 conf` stdout (or null on error). Used by pm2-logrotate check. */
|
|
119
|
+
capturePm2Conf: () => Promise<string | null>;
|
|
111
120
|
}
|
|
112
121
|
/**
|
|
113
122
|
* Run all checks and optionally apply fixes. Returns a structured
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAA4C,MAAM,cAAc,CAAC;AAcxG,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhD,kDAAkD;AAClD,MAAM,MAAM,OAAO,GACf,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,eAAe,GACf,YAAY,GACZ,kBAAkB,GAClB,yBAAyB,CAAC;AAE9B,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AAgB,mBAAmB,IAAI,OAAO,CA+C7C"}
|
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Install Command
|
|
3
3
|
*
|
|
4
|
-
* omni install [--
|
|
4
|
+
* omni install [--port <port>] [--database-url <url>] [--api-key <key>]
|
|
5
|
+
* [--systemd] [--force-cleanup] [--non-interactive]
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* 9. Write ~/.omni/config.json
|
|
16
|
-
* 10. Done banner + next steps
|
|
7
|
+
* Non-interactive, reinstall-safe bootstrapper. Rewritten from an interactive
|
|
8
|
+
* wizard in 2026-04 (WISH: omni-install-resilience). Flow:
|
|
9
|
+
*
|
|
10
|
+
* 1. Detect reinstall (config, pm2 process, or non-empty data dir).
|
|
11
|
+
* 2. Preserve ALL user data on reinstall — never regenerate keys or config.
|
|
12
|
+
* 3. Install pm2-logrotate (best-effort, idempotent).
|
|
13
|
+
* 4. Start services via pm2 with hardened flags (max-restarts, log rotation).
|
|
14
|
+
* 5. Health check.
|
|
15
|
+
* 6. Print an agent handoff block addressed TO the AI agent running this.
|
|
17
16
|
*/
|
|
18
17
|
import { Command } from 'commander';
|
|
19
18
|
/**
|
|
20
|
-
* Compute the default database URL
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* pgserve port (never from the calling shell, which has historically
|
|
24
|
-
* leaked foreign databases into omni-api via pm2's stored env). If an
|
|
25
|
-
* operator wants to point omni at an external PostgreSQL they must pass
|
|
26
|
-
* `--database-url <url>` explicitly — an opt-in signal that the external
|
|
27
|
-
* URL is intentional and not an accidental shell export.
|
|
28
|
-
*
|
|
29
|
-
* Exported so `install-env-leak.test.ts` can assert hermeticity.
|
|
19
|
+
* Compute the default database URL. Embedded-mode derives from the pgserve
|
|
20
|
+
* port — NEVER from the calling shell. Exported so install-env-leak tests
|
|
21
|
+
* can assert hermeticity.
|
|
30
22
|
*/
|
|
31
23
|
export declare function computeDefaultDatabaseUrl(): string;
|
|
32
|
-
/**
|
|
33
|
-
* Resolve the `databaseUrl` that will be written to `~/.omni/config.json`.
|
|
34
|
-
* Exported for hermeticity tests. Never reads the calling shell's env.
|
|
35
|
-
*
|
|
36
|
-
* @param options.databaseUrlFlag — the explicit `--database-url` value, if
|
|
37
|
-
* the operator passed one. Opt-in external-DB mode.
|
|
38
|
-
*/
|
|
24
|
+
/** Resolve the effective databaseUrl, honoring an explicit flag over the embedded default. */
|
|
39
25
|
export declare function resolveInstallDatabaseUrl(options: {
|
|
40
26
|
databaseUrlFlag?: string;
|
|
41
27
|
}): string;
|
|
28
|
+
interface ResolvedConfig {
|
|
29
|
+
port: number;
|
|
30
|
+
dataDir: string;
|
|
31
|
+
databaseUrl: string;
|
|
32
|
+
apiKey: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Agent handoff banner. Plain text, no ANSI, no ASCII art, no interactive
|
|
36
|
+
* prompts. An agent reading stdout can act on this block directly.
|
|
37
|
+
* Exported for tests that assert the block's structure.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildAgentHandoffBlock(cfg: ResolvedConfig, apiKeyDisplay: string): string;
|
|
42
40
|
export declare function createInstallCommand(): Command;
|
|
41
|
+
export {};
|
|
43
42
|
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBpC;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED,8FAA8F;AAC9F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAIvF;AAYD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAyLD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAmCzF;AA2DD,wBAAgB,oBAAoB,IAAI,OAAO,CAU9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyFpC,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C"}
|