@automagik/omni 2.260405.2 → 2.260406.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/__tests__/mock-api.d.ts.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/connect.d.ts +1 -1
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/doctor.d.ts +119 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/done.d.ts.map +1 -1
- package/dist/commands/history.d.ts +14 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/install.d.ts +23 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/restart.d.ts +7 -0
- package/dist/commands/restart.d.ts.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/update.d.ts +57 -2
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/context.d.ts +8 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/index.js +1301 -469
- package/dist/runtime-env.d.ts +77 -0
- package/dist/runtime-env.d.ts.map +1 -0
- package/dist/server/index.js +43 -4
- package/dist/sidecar-cleanup.d.ts +86 -0
- package/dist/sidecar-cleanup.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-api.d.ts","sourceRoot":"","sources":["../../src/__tests__/mock-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,YAAY,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"mock-api.d.ts","sourceRoot":"","sources":["../../src/__tests__/mock-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,YAAY,4BAA4B,CAAC;AAgStD,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID;;;;GAIG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC,CA2B3D;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAIlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuRpC,wBAAgB,iBAAiB,IAAI,OAAO,CAiI3C"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 1. Discovers agent via `genie dir ls <agent-name> --json`
|
|
6
6
|
* 2. Creates/updates Omni provider with schema `nats-genie`
|
|
7
7
|
* 3. Creates Omni agent record linked to provider
|
|
8
|
-
* 4. Updates instance
|
|
8
|
+
* 4. Updates instance with agentId (FK), agentProviderId, agentReplyFilter, and triggerMode
|
|
9
9
|
*/
|
|
10
10
|
import { Command } from 'commander';
|
|
11
11
|
export declare function createConnectCommand(): Command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgFpC,wBAAgB,oBAAoB,IAAI,OAAO,CAyF9C"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor Command
|
|
3
|
+
*
|
|
4
|
+
* omni doctor [--fix] [--json] [--verbose]
|
|
5
|
+
*
|
|
6
|
+
* In-place diagnose + repair for the embedded-omni runtime. This is the
|
|
7
|
+
* command operators are pointed at when `omni update` reports a version
|
|
8
|
+
* mismatch or an auth failure after a restart.
|
|
9
|
+
*
|
|
10
|
+
* Checks performed, in order:
|
|
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
|
+
*
|
|
19
|
+
* Each check returns OK / WARN / FAIL with a one-line detail. `--fix`
|
|
20
|
+
* attempts repair for checks with a known repair path. The fix flow
|
|
21
|
+
* NEVER touches `~/.omni/data/pgserve/` — that safety constraint is
|
|
22
|
+
* load-bearing and has a dedicated mutation-safety test.
|
|
23
|
+
*
|
|
24
|
+
* Repair paths:
|
|
25
|
+
* - pm2-env-drift: `pm2 delete omni-api` + re-launch via the same code
|
|
26
|
+
* path used by `omni start`, with a sanitized env.
|
|
27
|
+
* - cli-key-valid: Delete `__primary__` from api_keys, restart with a
|
|
28
|
+
* freshly generated OMNI_API_KEY, re-validate, write
|
|
29
|
+
* the new key to `~/.omni/config.json`.
|
|
30
|
+
* - orphaned-data-dirs: Print `rm -rf` commands for the user to review
|
|
31
|
+
* (we never auto-delete data directories).
|
|
32
|
+
*/
|
|
33
|
+
import { Command } from 'commander';
|
|
34
|
+
import { type Config, type ServerConfig } from '../config.js';
|
|
35
|
+
/** Severity levels reported by each check. */
|
|
36
|
+
export type CheckLevel = 'OK' | 'WARN' | 'FAIL';
|
|
37
|
+
/** 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';
|
|
39
|
+
export interface CheckResult {
|
|
40
|
+
id: CheckId;
|
|
41
|
+
level: CheckLevel;
|
|
42
|
+
detail: string;
|
|
43
|
+
}
|
|
44
|
+
export interface DoctorReport {
|
|
45
|
+
checks: CheckResult[];
|
|
46
|
+
summary: {
|
|
47
|
+
ok: number;
|
|
48
|
+
warn: number;
|
|
49
|
+
fail: number;
|
|
50
|
+
};
|
|
51
|
+
fixesApplied: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface DoctorOptions {
|
|
54
|
+
fix?: boolean;
|
|
55
|
+
json?: boolean;
|
|
56
|
+
verbose?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Narrow shape of a pm2 process entry from `pm2 jlist`. We only care about
|
|
60
|
+
* fields relevant to env-drift and status checks.
|
|
61
|
+
*/
|
|
62
|
+
interface Pm2Entry {
|
|
63
|
+
name?: string;
|
|
64
|
+
pm_id?: number;
|
|
65
|
+
pm2_env?: {
|
|
66
|
+
status?: string;
|
|
67
|
+
env?: Record<string, string | undefined>;
|
|
68
|
+
pm_exec_path?: string;
|
|
69
|
+
args?: string[];
|
|
70
|
+
interpreter?: string;
|
|
71
|
+
OMNI_API_KEY?: string;
|
|
72
|
+
DATABASE_URL?: string;
|
|
73
|
+
PGSERVE_DATA?: string;
|
|
74
|
+
API_PORT?: string;
|
|
75
|
+
NODE_ENV?: string;
|
|
76
|
+
LOG_LEVEL?: string;
|
|
77
|
+
} & Record<string, unknown>;
|
|
78
|
+
}
|
|
79
|
+
/** Shape injected by the test harness to mock slow/external inputs. */
|
|
80
|
+
export interface DoctorDeps {
|
|
81
|
+
/** Return all pm2 processes (or null on error). */
|
|
82
|
+
getPm2Processes: () => Promise<Pm2Entry[] | null>;
|
|
83
|
+
/** Return true if a TCP connect to localhost:port succeeds. */
|
|
84
|
+
canConnect: (port: number) => Promise<boolean>;
|
|
85
|
+
/** Return true if the omni database exists on the embedded pgserve. */
|
|
86
|
+
omniDbExists: () => Promise<boolean>;
|
|
87
|
+
/** Walk the filesystem for orphaned `.pgserve-data` directories. */
|
|
88
|
+
findOrphanedDataDirs: () => string[];
|
|
89
|
+
/** Fetch the health body from the running server. */
|
|
90
|
+
fetchHealthVersion: (apiPort: number) => Promise<string | null>;
|
|
91
|
+
/** Validate the stored CLI key against the running server. */
|
|
92
|
+
validateStoredKey: (apiPort: number) => Promise<boolean>;
|
|
93
|
+
/** Return the current `~/.omni/` configs. */
|
|
94
|
+
loadState: () => {
|
|
95
|
+
serverConfig: ServerConfig;
|
|
96
|
+
cliConfig: Config;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Run a pm2 command. Returns the exit code. Tests stub this with a no-op
|
|
100
|
+
* to prevent fix handlers from actually mutating the host's pm2 state.
|
|
101
|
+
*/
|
|
102
|
+
runPm2: (args: string[], env?: Record<string, string>) => Promise<number>;
|
|
103
|
+
/** Persist a new CLI config. Tests stub this to in-memory state. */
|
|
104
|
+
saveCliConfig: (config: Config) => void;
|
|
105
|
+
/** Re-read the CLI config from disk (stubbed in tests). */
|
|
106
|
+
reloadCliConfig: () => Config;
|
|
107
|
+
/** Generate a new API key. Tests stub for determinism. */
|
|
108
|
+
generateApiKey: () => string;
|
|
109
|
+
/** Sleep briefly after a pm2 restart. Tests stub to zero-delay. */
|
|
110
|
+
sleepMs: (ms: number) => Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Run all checks and optionally apply fixes. Returns a structured
|
|
114
|
+
* DoctorReport — the caller decides how to render it (human vs. JSON).
|
|
115
|
+
*/
|
|
116
|
+
export declare function runDoctor(options: DoctorOptions, depsOverride?: DoctorDeps): Promise<DoctorReport>;
|
|
117
|
+
export declare function createDoctorCommand(): Command;
|
|
118
|
+
export {};
|
|
119
|
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,oEAAoE;IACpE,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,2DAA2D;IAC3D,eAAe,EAAE,MAAM,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,mEAAmE;IACnE,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AA6VD;;;GAGG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAkBxG;AA2BD,wBAAgB,mBAAmB,IAAI,OAAO,CA6C7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"done.d.ts","sourceRoot":"","sources":["../../src/commands/done.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2HpC,wBAAgB,iBAAiB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"done.d.ts","sourceRoot":"","sources":["../../src/commands/done.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2HpC,wBAAgB,iBAAiB,IAAI,OAAO,CA0C3C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History Command — Read conversation messages verb
|
|
3
|
+
*
|
|
4
|
+
* omni history — show last 10 messages in open chat
|
|
5
|
+
* omni history --limit 20 — show last 20 messages
|
|
6
|
+
* omni history --before <msg-id> — paginate backward
|
|
7
|
+
* omni history --full — show full content (no truncation)
|
|
8
|
+
* omni history --json — machine-readable output (global flag)
|
|
9
|
+
*
|
|
10
|
+
* Uses context resolution (env vars > PG context > config) for instance/chat.
|
|
11
|
+
*/
|
|
12
|
+
import { Command } from 'commander';
|
|
13
|
+
export declare function createHistoryCommand(): Command;
|
|
14
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsFpC,wBAAgB,oBAAoB,IAAI,OAAO,CAkE9C"}
|
|
@@ -16,5 +16,28 @@
|
|
|
16
16
|
* 10. Done banner + next steps
|
|
17
17
|
*/
|
|
18
18
|
import { Command } from 'commander';
|
|
19
|
+
/**
|
|
20
|
+
* Compute the default database URL for the install wizard.
|
|
21
|
+
*
|
|
22
|
+
* Embedded mode is the default and derives the URL from the configured
|
|
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.
|
|
30
|
+
*/
|
|
31
|
+
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
|
+
*/
|
|
39
|
+
export declare function resolveInstallDatabaseUrl(options: {
|
|
40
|
+
databaseUrlFlag?: string;
|
|
41
|
+
}): string;
|
|
19
42
|
export declare function createInstallCommand(): Command;
|
|
20
43
|
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBpC;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAMvF;AA0kBD,wBAAgB,oBAAoB,IAAI,OAAO,CAQ9C"}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* Restart Command
|
|
3
3
|
*
|
|
4
4
|
* omni restart — Restart omni PM2 processes and wait for health check
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: This command does NOT ask pm2 to re-read the shell environment
|
|
7
|
+
* on restart. Doing so would re-introduce env-pollution bugs (e.g. stray
|
|
8
|
+
* `DATABASE_URL` from a parent tmux session leaking into omni-api). Instead,
|
|
9
|
+
* we rely on the env that was captured at original `pm2 start` time (built
|
|
10
|
+
* by `buildRuntimeEnv` from config). If the stored env is stale, use
|
|
11
|
+
* `omni doctor --fix` to rebuild it deterministically.
|
|
5
12
|
*/
|
|
6
13
|
import { Command } from 'commander';
|
|
7
14
|
export declare function createRestartCommand(): Command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restart.d.ts","sourceRoot":"","sources":["../../src/commands/restart.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"restart.d.ts","sourceRoot":"","sources":["../../src/commands/restart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoDpC,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
|
|
@@ -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;AA0EpC,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C"}
|
|
@@ -6,9 +6,64 @@
|
|
|
6
6
|
* Self-update from npm: checks latest @automagik/omni version, prompts the
|
|
7
7
|
* user (unless --yes), installs with `bun add -g`, and restarts PM2 services
|
|
8
8
|
* only if they were already running. When that restart path runs, update
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* performs a 3-step visible verification:
|
|
10
|
+
*
|
|
11
|
+
* 1. CLI version matches `package.json` (trivial — known at compile time).
|
|
12
|
+
* 2. Server version matches the newly-installed CLI version (fetched from
|
|
13
|
+
* `/api/v2/health`). If not, update exits non-zero and tells the
|
|
14
|
+
* operator to run `omni doctor`.
|
|
15
|
+
* 3. The stored API key still validates against the (restarted) server. If
|
|
16
|
+
* not, update exits non-zero and tells the operator to run
|
|
17
|
+
* `omni doctor --fix`.
|
|
18
|
+
*
|
|
19
|
+
* This replaces the previous silent-success path where the CLI would report
|
|
20
|
+
* "updated to vX" even when the server was still running the old version or
|
|
21
|
+
* when the stored key no longer validated.
|
|
11
22
|
*/
|
|
12
23
|
import { Command } from 'commander';
|
|
24
|
+
/** Shape of the `/api/v2/health` response we care about. */
|
|
25
|
+
export interface HealthBody {
|
|
26
|
+
status?: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Normalize a version string for comparison. Strips a git-hash suffix
|
|
31
|
+
* (e.g. `2.20260218.18+abc1234` → `2.20260218.18`) so build metadata doesn't
|
|
32
|
+
* trigger a spurious mismatch.
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeVersion(version: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Result of the pure 3-step update verification. Exported so tests can
|
|
37
|
+
* exercise the logic without mocking pm2 / fetch / process.exit.
|
|
38
|
+
*/
|
|
39
|
+
export type UpdateVerifyResult = {
|
|
40
|
+
kind: 'ok';
|
|
41
|
+
cliVersion: string;
|
|
42
|
+
serverVersion: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'health-unreachable';
|
|
45
|
+
apiPort: number;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'version-mismatch';
|
|
48
|
+
cliVersion: string;
|
|
49
|
+
serverVersion: string | null;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'auth-invalid';
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Pure decision function for update verification. Given the raw inputs
|
|
55
|
+
* (health body + key-valid flag + CLI version + port), return a tagged
|
|
56
|
+
* union describing the outcome. The caller decides how to render and
|
|
57
|
+
* whether to exit non-zero.
|
|
58
|
+
*/
|
|
59
|
+
export declare function decideUpdateVerify(args: {
|
|
60
|
+
latest: string;
|
|
61
|
+
apiPort: number;
|
|
62
|
+
healthBody: HealthBody | null;
|
|
63
|
+
keyValid: boolean;
|
|
64
|
+
}): UpdateVerifyResult;
|
|
65
|
+
/** Error message strings — exported for tests and documentation. */
|
|
66
|
+
export declare function updateErrorVersionMismatch(cli: string, server: string | null): string;
|
|
67
|
+
export declare const UPDATE_ERROR_AUTH_INVALID = "Auth key invalid after restart. Run: omni doctor --fix";
|
|
13
68
|
export declare function createUpdateCommand(): Command;
|
|
14
69
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6HpC,4DAA4D;AAC5D,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7B;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;CACnB,GAAG,kBAAkB,CAarB;AAED,oEAAoE;AACpE,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAErF;AAED,eAAO,MAAM,yBAAyB,2DAA2D,CAAC;AAuOlG,wBAAgB,mBAAmB,IAAI,OAAO,CAmC7C"}
|
package/dist/context.d.ts
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* 3. PG-backed context (stored per API key via /context endpoint)
|
|
8
8
|
* 4. Config defaults (defaultInstance from ~/.omni/config.json)
|
|
9
9
|
* 5. Error — no context available
|
|
10
|
+
*
|
|
11
|
+
* Each field is resolved independently so that a single flag (e.g. --message)
|
|
12
|
+
* does not nullify other fields available from lower-priority sources.
|
|
10
13
|
*/
|
|
11
14
|
export interface ResolvedContext {
|
|
12
15
|
instanceId: string | null;
|
|
@@ -17,6 +20,11 @@ export interface ResolvedContext {
|
|
|
17
20
|
/**
|
|
18
21
|
* Resolve the current conversation context.
|
|
19
22
|
*
|
|
23
|
+
* Each field (instanceId, chatId, messageId) is resolved independently through
|
|
24
|
+
* the priority chain: CLI flags > env vars > PG context > config defaults.
|
|
25
|
+
* This prevents a single flag (e.g. --message) from nullifying other fields
|
|
26
|
+
* that are available from lower-priority sources (e.g. OMNI_INSTANCE env var).
|
|
27
|
+
*
|
|
20
28
|
* @param flags - Explicit CLI flags passed by the user
|
|
21
29
|
* @returns Resolved context with source indicator
|
|
22
30
|
*/
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACrD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,KAAK,CAAC,EAAE;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,eAAe,CAAC,CAiD3B;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS3F;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAevF"}
|