@the-librarian/cli 1.0.0-rc.21
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/LICENSE +201 -0
- package/README.md +94 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +15 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/install.d.ts +28 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +204 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/shared.d.ts +16 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +30 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/uninstall.d.ts +18 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +67 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +21 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +75 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +65 -0
- package/dist/config.js.map +1 -0
- package/dist/doctor.d.ts +23 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +81 -0
- package/dist/doctor.js.map +1 -0
- package/dist/env.d.ts +39 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +208 -0
- package/dist/env.js.map +1 -0
- package/dist/exec.d.ts +37 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +81 -0
- package/dist/exec.js.map +1 -0
- package/dist/harnesses/claude.d.ts +3 -0
- package/dist/harnesses/claude.d.ts.map +1 -0
- package/dist/harnesses/claude.js +88 -0
- package/dist/harnesses/claude.js.map +1 -0
- package/dist/harnesses/cli.d.ts +4 -0
- package/dist/harnesses/cli.d.ts.map +1 -0
- package/dist/harnesses/cli.js +16 -0
- package/dist/harnesses/cli.js.map +1 -0
- package/dist/harnesses/codex.d.ts +3 -0
- package/dist/harnesses/codex.d.ts.map +1 -0
- package/dist/harnesses/codex.js +183 -0
- package/dist/harnesses/codex.js.map +1 -0
- package/dist/harnesses/hermes.d.ts +16 -0
- package/dist/harnesses/hermes.d.ts.map +1 -0
- package/dist/harnesses/hermes.js +158 -0
- package/dist/harnesses/hermes.js.map +1 -0
- package/dist/harnesses/index.d.ts +12 -0
- package/dist/harnesses/index.d.ts.map +1 -0
- package/dist/harnesses/index.js +29 -0
- package/dist/harnesses/index.js.map +1 -0
- package/dist/harnesses/opencode.d.ts +3 -0
- package/dist/harnesses/opencode.d.ts.map +1 -0
- package/dist/harnesses/opencode.js +141 -0
- package/dist/harnesses/opencode.js.map +1 -0
- package/dist/harnesses/pi.d.ts +3 -0
- package/dist/harnesses/pi.d.ts.map +1 -0
- package/dist/harnesses/pi.js +72 -0
- package/dist/harnesses/pi.js.map +1 -0
- package/dist/harnesses/types.d.ts +48 -0
- package/dist/harnesses/types.d.ts.map +1 -0
- package/dist/harnesses/types.js +22 -0
- package/dist/harnesses/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/machine.d.ts +10 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +39 -0
- package/dist/machine.js.map +1 -0
- package/dist/parse-args.d.ts +12 -0
- package/dist/parse-args.d.ts.map +1 -0
- package/dist/parse-args.js +54 -0
- package/dist/parse-args.js.map +1 -0
- package/dist/paths.d.ts +32 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +75 -0
- package/dist/paths.js.map +1 -0
- package/dist/prompt.d.ts +53 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +165 -0
- package/dist/prompt.js.map +1 -0
- package/dist/runtime.d.ts +45 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +370 -0
- package/dist/runtime.js.map +1 -0
- package/dist/semver.d.ts +13 -0
- package/dist/semver.d.ts.map +1 -0
- package/dist/semver.js +98 -0
- package/dist/semver.js.map +1 -0
- package/dist/server/admin.d.ts +31 -0
- package/dist/server/admin.d.ts.map +1 -0
- package/dist/server/admin.js +110 -0
- package/dist/server/admin.js.map +1 -0
- package/dist/server/boot.d.ts +51 -0
- package/dist/server/boot.d.ts.map +1 -0
- package/dist/server/boot.js +233 -0
- package/dist/server/boot.js.map +1 -0
- package/dist/server/deploy-state.d.ts +33 -0
- package/dist/server/deploy-state.d.ts.map +1 -0
- package/dist/server/deploy-state.js +79 -0
- package/dist/server/deploy-state.js.map +1 -0
- package/dist/server/docker.d.ts +37 -0
- package/dist/server/docker.d.ts.map +1 -0
- package/dist/server/docker.js +138 -0
- package/dist/server/docker.js.map +1 -0
- package/dist/server/down.d.ts +19 -0
- package/dist/server/down.d.ts.map +1 -0
- package/dist/server/down.js +62 -0
- package/dist/server/down.js.map +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +48 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/logs.d.ts +50 -0
- package/dist/server/logs.d.ts.map +1 -0
- package/dist/server/logs.js +162 -0
- package/dist/server/logs.js.map +1 -0
- package/dist/server/preflight.d.ts +24 -0
- package/dist/server/preflight.d.ts.map +1 -0
- package/dist/server/preflight.js +58 -0
- package/dist/server/preflight.js.map +1 -0
- package/dist/server/redact.d.ts +2 -0
- package/dist/server/redact.d.ts.map +1 -0
- package/dist/server/redact.js +26 -0
- package/dist/server/redact.js.map +1 -0
- package/dist/server/status.d.ts +20 -0
- package/dist/server/status.d.ts.map +1 -0
- package/dist/server/status.js +103 -0
- package/dist/server/status.js.map +1 -0
- package/dist/server/up.d.ts +211 -0
- package/dist/server/up.d.ts.map +1 -0
- package/dist/server/up.js +625 -0
- package/dist/server/up.js.map +1 -0
- package/dist/server/update.d.ts +35 -0
- package/dist/server/update.d.ts.map +1 -0
- package/dist/server/update.js +308 -0
- package/dist/server/update.js.map +1 -0
- package/dist/status.d.ts +18 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +113 -0
- package/dist/status.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +20 -0
- package/dist/version.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/server/logs.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,2EAA2E;AAC3E,oFAAoF;AACpF,iFAAiF;AACjF,0EAA0E;AAC1E,EAAE;AACF,0DAA0D;AAC1D,+EAA+E;AAC/E,qFAAqF;AACrF,sEAAsE;AACtE,+EAA+E;AAC/E,kFAAkF;AAClF,2EAA2E;AAC3E,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,oCAAoC;AACpC,+EAA+E;AAC/E,+EAA+E;AAC/E,kEAAkE;AAClE,6EAA6E;AAC7E,8EAA8E;AAC9E,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,2EAA2E;AAC3E,wEAAwE;AACxE,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKzC,MAAM,QAAQ,GAA2B,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;AAkBrE,uFAAuF;AACvF,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAgBD,2EAA2E;AAC3E,SAAS,cAAc,CAAC,GAAuB;IAC7C,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO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AQ,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A preflight failure carrying an actionable, teaching message. The CLI
|
|
3
|
+
* runtime renders `error.message` as one clean stderr line (no stack trace),
|
|
4
|
+
* so this message IS what the user reads.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PreflightError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export interface PreflightOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The host platform, defaulting to `process.platform`. Injectable so the
|
|
12
|
+
* macOS "Docker Desktop" daemon hint is testable from any host.
|
|
13
|
+
*/
|
|
14
|
+
platform?: NodeJS.Platform;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Confirm `docker` (daemon reachable) and `git` are available, or throw a
|
|
18
|
+
* `PreflightError` with a teaching message. Resolves to nothing on success.
|
|
19
|
+
*
|
|
20
|
+
* Order matters: report a missing binary before probing the daemon, so a host
|
|
21
|
+
* without Docker is told to install it (not told the daemon is down).
|
|
22
|
+
*/
|
|
23
|
+
export declare function preflight(options?: PreflightOptions): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/server/preflight.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC5B;AAoBD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB7E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Preflight for the `server` command group.
|
|
2
|
+
//
|
|
3
|
+
// Every `server` subcommand that drives a container (up / update / down /
|
|
4
|
+
// status / logs / boot / admin) first confirms the host actually has the tools
|
|
5
|
+
// it needs: `docker` installed AND its daemon reachable, and `git` installed.
|
|
6
|
+
// A missing or unreachable tool is a TEACHING error (what to install, or "is
|
|
7
|
+
// the daemon running?") — never a stack trace, never a bare "error".
|
|
8
|
+
//
|
|
9
|
+
// The check goes through the `docker.ts` seam, so tests stub it and a real
|
|
10
|
+
// daemon is never contacted. `platform` is injectable so the macOS-specific
|
|
11
|
+
// "Docker Desktop" hint is testable on any host.
|
|
12
|
+
import { run, which } from "./docker.js";
|
|
13
|
+
/**
|
|
14
|
+
* A preflight failure carrying an actionable, teaching message. The CLI
|
|
15
|
+
* runtime renders `error.message` as one clean stderr line (no stack trace),
|
|
16
|
+
* so this message IS what the user reads.
|
|
17
|
+
*/
|
|
18
|
+
export class PreflightError extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "PreflightError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const DOCKER_INSTALL = "Docker is required but was not found on your PATH. " +
|
|
25
|
+
"Install Docker Engine (Linux) or Docker Desktop (macOS) — " +
|
|
26
|
+
"see https://docs.docker.com/get-docker/ — then re-run this command.";
|
|
27
|
+
const GIT_INSTALL = "git is required but was not found on your PATH. " +
|
|
28
|
+
"Install git (e.g. `apt install git`, `brew install git`, or " +
|
|
29
|
+
"https://git-scm.com/downloads), then re-run this command.";
|
|
30
|
+
function dockerDaemonHint(platform) {
|
|
31
|
+
const start = platform === "darwin"
|
|
32
|
+
? "Is Docker Desktop running? Start Docker Desktop and wait for it to report ready, then re-run this command."
|
|
33
|
+
: "Is the Docker daemon running? Start it (e.g. `sudo systemctl start docker`) and confirm `docker info` succeeds, then re-run this command.";
|
|
34
|
+
return `Docker is installed but its daemon is unreachable. ${start}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Confirm `docker` (daemon reachable) and `git` are available, or throw a
|
|
38
|
+
* `PreflightError` with a teaching message. Resolves to nothing on success.
|
|
39
|
+
*
|
|
40
|
+
* Order matters: report a missing binary before probing the daemon, so a host
|
|
41
|
+
* without Docker is told to install it (not told the daemon is down).
|
|
42
|
+
*/
|
|
43
|
+
export async function preflight(options = {}) {
|
|
44
|
+
const platform = options.platform ?? process.platform;
|
|
45
|
+
if ((await which("docker")) === null) {
|
|
46
|
+
throw new PreflightError(DOCKER_INSTALL);
|
|
47
|
+
}
|
|
48
|
+
// Daemon probe: `docker info` exits non-zero (and prints to stderr) when the
|
|
49
|
+
// engine isn't reachable. We only care about the exit code here.
|
|
50
|
+
const info = await run("docker", ["info"]);
|
|
51
|
+
if (info.code !== 0) {
|
|
52
|
+
throw new PreflightError(dockerDaemonHint(platform));
|
|
53
|
+
}
|
|
54
|
+
if ((await which("git")) === null) {
|
|
55
|
+
throw new PreflightError(GIT_INSTALL);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/server/preflight.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,iDAAiD;AAEjD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAUD,MAAM,cAAc,GAClB,qDAAqD;IACrD,4DAA4D;IAC5D,qEAAqE,CAAC;AAExE,MAAM,WAAW,GACf,kDAAkD;IAClD,8DAA8D;IAC9D,2DAA2D,CAAC;AAE9D,SAAS,gBAAgB,CAAC,QAAyB;IACjD,MAAM,KAAK,GACT,QAAQ,KAAK,QAAQ;QACnB,CAAC,CAAC,4GAA4G;QAC9G,CAAC,CAAC,2IAA2I,CAAC;IAClJ,OAAO,sDAAsD,KAAK,EAAE,CAAC;AACvE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAA4B,EAAE;IAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAEtD,IAAI,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACrC,MAAM,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,6EAA6E;IAC7E,iEAAiE;IACjE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,cAAc,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAClC,MAAM,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/server/redact.ts"],"names":[],"mappings":"AAiBA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOlD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Secret redaction for captured docker/git output before it reaches a
|
|
2
|
+
// user-facing error or log (C1 / I-3 / S-2).
|
|
3
|
+
//
|
|
4
|
+
// `up`, `update`, and `admin` all surface a failed step's stderr/stdout so the
|
|
5
|
+
// operator can triage — but those streams can carry secrets: the server's
|
|
6
|
+
// one-time admin-token generation notice emits the token BY VALUE
|
|
7
|
+
// (`packages/mcp-server/src/bin/http.ts`), a `docker run -e
|
|
8
|
+
// LIBRARIAN_AGENT_TOKEN=…`/`restore --secret-key …` failure can echo the argv,
|
|
9
|
+
// and a master key is a raw 64-hex run. This single helper is the shared choke
|
|
10
|
+
// point so every surface redacts identically (no surface forgets).
|
|
11
|
+
//
|
|
12
|
+
// We defend three ways:
|
|
13
|
+
// - drop any whole line carrying the admin-token generation notice;
|
|
14
|
+
// - redact any `libadmin_<base64url>` token substring (the bearer shape);
|
|
15
|
+
// - redact any standalone 64-hex run (a raw key/token shape: the master key
|
|
16
|
+
// and the CSPRNG agent token are both 64-hex).
|
|
17
|
+
// The redacted remainder is still surfaced so debugging works — just no secrets.
|
|
18
|
+
export function redactSecrets(text) {
|
|
19
|
+
return text
|
|
20
|
+
.split("\n")
|
|
21
|
+
.filter((line) => !/Generated a new admin token/i.test(line))
|
|
22
|
+
.join("\n")
|
|
23
|
+
.replace(/libadmin_[A-Za-z0-9_-]+/g, "[redacted-admin-token]")
|
|
24
|
+
.replace(/\b[0-9a-fA-F]{64}\b/g, "[redacted]");
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/server/redact.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,6CAA6C;AAC7C,EAAE;AACF,+EAA+E;AAC/E,0EAA0E;AAC1E,kEAAkE;AAClE,4DAA4D;AAC5D,+EAA+E;AAC/E,+EAA+E;AAC/E,mEAAmE;AACnE,EAAE;AACF,wBAAwB;AACxB,sEAAsE;AACtE,4EAA4E;AAC5E,8EAA8E;AAC9E,mDAAmD;AACnD,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI;SACR,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC5D,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ServerStatusOptions {
|
|
2
|
+
/** Override home (tests). */
|
|
3
|
+
home?: string | undefined;
|
|
4
|
+
/** Deploy dir override. Default: `~/.librarian/server`. */
|
|
5
|
+
dir?: string | undefined;
|
|
6
|
+
/** Platform for preflight's daemon hint. Default `process.platform`. */
|
|
7
|
+
platform?: NodeJS.Platform | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface ServerStatusResult {
|
|
10
|
+
/** The rendered status report for stdout. */
|
|
11
|
+
output: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Run `server status`. Preflights docker, probes the container's running/health
|
|
15
|
+
* state, resolves the deployed + latest versions, and renders the report. Never
|
|
16
|
+
* throws on an offline latest-fetch or an absent deploy dir — those degrade to
|
|
17
|
+
* `unknown`/`?`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function serverStatus(options?: ServerStatusOptions): Promise<ServerStatusResult>;
|
|
20
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/server/status.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;CAChB;AAkCD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAcjG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// `librarian server status` — running? healthy? deployed-vs-latest.
|
|
2
|
+
//
|
|
3
|
+
// Reports, all from the injectable `docker.ts` runner + the injectable
|
|
4
|
+
// latest-release fetcher (so tests never touch a real daemon/network):
|
|
5
|
+
// - container running? (`docker inspect --format {{.State.Status}}`)
|
|
6
|
+
// - health (`docker inspect --format {{.State.Health.Status}}`)
|
|
7
|
+
// - the DEPLOYED version — the ref recorded in deploy-state.json, falling back
|
|
8
|
+
// to `git -C <dir> describe --tags` when no state file exists (e.g. a clone
|
|
9
|
+
// made before deploy-state existed)
|
|
10
|
+
// - the LATEST release (`fetchLatestVersion` — the same fetch `librarian
|
|
11
|
+
// status` uses for the harnesses)
|
|
12
|
+
// - an `up-to-date | update-available` badge via `isBehind(deployed, latest)`
|
|
13
|
+
//
|
|
14
|
+
// OFFLINE TOLERANCE (mirrors src/status.ts): an unreachable GitHub resolves
|
|
15
|
+
// latest to `unknown` and the badge to `?`; an unknown deployed version does the
|
|
16
|
+
// same. The command never crashes because the network was down or the deploy dir
|
|
17
|
+
// wasn't a git repo — it renders `unknown`/`?` and exits 0.
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { librarianDir } from "../paths.js";
|
|
20
|
+
import { isBehind } from "../semver.js";
|
|
21
|
+
import { fetchLatestVersion } from "../status.js";
|
|
22
|
+
import { readDeployState } from "./deploy-state.js";
|
|
23
|
+
import { run } from "./docker.js";
|
|
24
|
+
import { preflight } from "./preflight.js";
|
|
25
|
+
import { CONTAINER_NAME } from "./up.js";
|
|
26
|
+
/** The deploy dir `status` reads its recorded ref / git-describe fallback from. */
|
|
27
|
+
function resolveDeployDir(options) {
|
|
28
|
+
return options.dir ?? path.join(librarianDir(options.home), "server");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Read the container's `State.Status` (running / exited / …). Returns `null`
|
|
32
|
+
* when `docker inspect` fails — the container doesn't exist → "not running".
|
|
33
|
+
*/
|
|
34
|
+
async function inspectField(format) {
|
|
35
|
+
const result = await run("docker", ["inspect", "--format", format, CONTAINER_NAME]);
|
|
36
|
+
if (result.code !== 0)
|
|
37
|
+
return null;
|
|
38
|
+
return result.stdout.trim();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the deployed version: the deploy-state ref first (authoritative — it's
|
|
42
|
+
* exactly what `up` checked out + built), else `git -C <dir> describe --tags`.
|
|
43
|
+
* Returns `null` (→ "unknown") when neither is available.
|
|
44
|
+
*/
|
|
45
|
+
async function resolveDeployed(deployDir) {
|
|
46
|
+
const state = readDeployState(deployDir);
|
|
47
|
+
if (state?.ref)
|
|
48
|
+
return state.ref;
|
|
49
|
+
const described = await run("git", ["-C", deployDir, "describe", "--tags"]);
|
|
50
|
+
if (described.code === 0) {
|
|
51
|
+
const tag = described.stdout.trim();
|
|
52
|
+
if (tag)
|
|
53
|
+
return tag;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Run `server status`. Preflights docker, probes the container's running/health
|
|
59
|
+
* state, resolves the deployed + latest versions, and renders the report. Never
|
|
60
|
+
* throws on an offline latest-fetch or an absent deploy dir — those degrade to
|
|
61
|
+
* `unknown`/`?`.
|
|
62
|
+
*/
|
|
63
|
+
export async function serverStatus(options = {}) {
|
|
64
|
+
await preflight(options.platform ? { platform: options.platform } : {});
|
|
65
|
+
const deployDir = resolveDeployDir(options);
|
|
66
|
+
// Probe the container. A null status means `docker inspect` failed → absent.
|
|
67
|
+
const statusField = await inspectField("{{.State.Status}}");
|
|
68
|
+
const running = statusField === "running";
|
|
69
|
+
// Health is only meaningful when the container exists; an empty health string
|
|
70
|
+
// (no healthcheck, or container absent) renders "unknown".
|
|
71
|
+
const health = statusField === null ? null : await inspectField("{{.State.Health.Status}}");
|
|
72
|
+
const [deployed, latest] = await Promise.all([resolveDeployed(deployDir), fetchLatestVersion()]);
|
|
73
|
+
return { output: render({ statusField, running, health, deployed, latest }) };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The `up-to-date | update-available | ?` badge. `?` whenever either version is
|
|
77
|
+
* unknown — an offline run never lies about an available update (mirrors the
|
|
78
|
+
* harness `status` table's `update?` column).
|
|
79
|
+
*/
|
|
80
|
+
function badge(deployed, latest) {
|
|
81
|
+
if (!deployed || !latest)
|
|
82
|
+
return "?";
|
|
83
|
+
return isBehind(deployed, latest) ? "update-available" : "up-to-date";
|
|
84
|
+
}
|
|
85
|
+
function render(input) {
|
|
86
|
+
const { statusField, running, health, deployed, latest } = input;
|
|
87
|
+
const runningLabel = statusField === null ? "not running" : running ? "running" : statusField;
|
|
88
|
+
const healthLabel = health && health.length > 0 ? health : "unknown";
|
|
89
|
+
const lines = [
|
|
90
|
+
`The Librarian server (${CONTAINER_NAME}):`,
|
|
91
|
+
"",
|
|
92
|
+
` Running: ${runningLabel}`,
|
|
93
|
+
` Health: ${runningLabel === "not running" ? "—" : healthLabel}`,
|
|
94
|
+
` Deployed: ${deployed ?? "unknown"}`,
|
|
95
|
+
` Latest: ${latest ?? "unknown"}`,
|
|
96
|
+
` Update: ${badge(deployed, latest)}`,
|
|
97
|
+
];
|
|
98
|
+
if (latest === null) {
|
|
99
|
+
lines.push("", "latest release unknown (could not reach GitHub) — Update shows ?");
|
|
100
|
+
}
|
|
101
|
+
return lines.join("\n");
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/server/status.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;A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the deploy dir clones (same repo the latest-tag fetch targets). */
|
|
4
|
+
export declare const REPO_URL = "https://github.com/JimJafar/the-librarian";
|
|
5
|
+
/** The container name every `server` command operates on (single instance per host). */
|
|
6
|
+
export declare const CONTAINER_NAME = "the-librarian";
|
|
7
|
+
/** The named data volume default (`--data-volume` overrides). The volume is sacred. */
|
|
8
|
+
export declare const DEFAULT_DATA_VOLUME = "librarian_data";
|
|
9
|
+
/** Host loopback — the default, only-reachable-locally bind (spec §5/§6). */
|
|
10
|
+
export declare const LOCALHOST = "127.0.0.1";
|
|
11
|
+
/** Bind-all-interfaces — never the default; ask-first (spec §5.3, §11). */
|
|
12
|
+
export declare const ALL_INTERFACES = "0.0.0.0";
|
|
13
|
+
/** The warning printed beside the one-time master-key surfacing (spec §5.4). */
|
|
14
|
+
export declare const SAVE_KEY_WARNING = "SAVE THIS KEY \u2014 excluded from backups";
|
|
15
|
+
/**
|
|
16
|
+
* The 0600 deploy env-file fed to `docker run --env-file` (ADR 0008 P4). It
|
|
17
|
+
* lives in the deploy dir (alongside `deploy-state.json`) and carries the agent
|
|
18
|
+
* token + master key + (loopback) `LIBRARIAN_ALLOW_NO_AUTH`. It is DISTINCT from
|
|
19
|
+
* the client `~/.librarian/env` (env.ts). 0600, by construction.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEPLOY_ENV_FILE = "deploy.env";
|
|
22
|
+
/** `<deployDir>/deploy.env` — the 0600 deploy env-file path within a deploy dir. */
|
|
23
|
+
export declare function deployEnvFilePath(deployDir: string): string;
|
|
24
|
+
/** A sleep used between health polls. Injectable so tests don't actually wait. */
|
|
25
|
+
export type Sleep = (ms: number) => Promise<void>;
|
|
26
|
+
/** Override the health-poll sleep (tests inject a no-op so polling is instant). */
|
|
27
|
+
export declare function setSleep(next: Sleep): void;
|
|
28
|
+
/** Restore the real sleep (tests). */
|
|
29
|
+
export declare function resetSleep(): void;
|
|
30
|
+
/** Mint one CSPRNG agent token. Injectable so tests assert a deterministic value. */
|
|
31
|
+
export type TokenMinter = () => string;
|
|
32
|
+
/** Override the agent-token minter (tests). */
|
|
33
|
+
export declare function setTokenMinter(next: TokenMinter): void;
|
|
34
|
+
/** Restore the real CSPRNG minter (tests). */
|
|
35
|
+
export declare function resetTokenMinter(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Mint one agent token through the CURRENT minter. Exported so `update` mints a
|
|
38
|
+
* fresh token (when the old container's token can't be read back) via the same
|
|
39
|
+
* injectable seam `up` uses — a single deterministic value in tests.
|
|
40
|
+
*/
|
|
41
|
+
export declare function mintAgentToken(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Mint one CSPRNG master key (`LIBRARIAN_SECRET_KEY`). The format MUST be one
|
|
44
|
+
* `resolveSecretKey` (core) accepts — a 64-char hex string — so the server boots
|
|
45
|
+
* with the CLI-supplied key (env wins) and never writes `/data/secret.key`.
|
|
46
|
+
* Injectable so tests assert a deterministic value (mirrors {@link TokenMinter}).
|
|
47
|
+
*/
|
|
48
|
+
export type SecretKeyMinter = () => string;
|
|
49
|
+
/** Override the master-key minter (tests). */
|
|
50
|
+
export declare function setSecretKeyMinter(next: SecretKeyMinter): void;
|
|
51
|
+
/** Restore the real CSPRNG master-key minter (tests). */
|
|
52
|
+
export declare function resetSecretKeyMinter(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Mint one master key through the CURRENT minter. Exported so `update` can mint a
|
|
55
|
+
* fresh key (only when the old container's key can't be read back) via the same
|
|
56
|
+
* injectable seam `up` uses — a single deterministic value in tests.
|
|
57
|
+
*/
|
|
58
|
+
export declare function mintSecretKey(): string;
|
|
59
|
+
export interface UpOptions {
|
|
60
|
+
/** Pinned ref (`vX.Y.Z` tag or `main`). Default: the latest release tag. */
|
|
61
|
+
ref?: string | undefined;
|
|
62
|
+
/** Deploy dir override. Default: `~/.librarian/server`. */
|
|
63
|
+
dir?: string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Bind host. Default `127.0.0.1` (loopback only). `--host <addr>` sets it
|
|
66
|
+
* explicitly; `0.0.0.0` (all interfaces) is ask-first. An interactive run
|
|
67
|
+
* with no `--host` may be offered a detected Tailscale IP instead (§5.3).
|
|
68
|
+
*/
|
|
69
|
+
host?: string | undefined;
|
|
70
|
+
/** Named data volume. Default: `librarian_data`. */
|
|
71
|
+
dataVolume?: string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Enable boot persistence after a successful `up` (S6). On Linux, installs +
|
|
74
|
+
* enables the systemd unit; on macOS, prints the deferred notice and the `up`
|
|
75
|
+
* still succeeds. Opt-in: a plain `up` never enables boot silently.
|
|
76
|
+
*/
|
|
77
|
+
enableBoot?: boolean | undefined;
|
|
78
|
+
/** Auto-accept prompts (loop-closer `~/.librarian/env` offer). */
|
|
79
|
+
yes?: boolean | undefined;
|
|
80
|
+
/** Health-wait bound: how many polls before declaring failure (small in tests). */
|
|
81
|
+
healthAttempts?: number | undefined;
|
|
82
|
+
/** Milliseconds between health polls (0 in tests). */
|
|
83
|
+
healthIntervalMs?: number | undefined;
|
|
84
|
+
/** Lines of `docker logs` to surface on a failed health-wait. */
|
|
85
|
+
logTailLines?: number | undefined;
|
|
86
|
+
}
|
|
87
|
+
export interface UpDeps {
|
|
88
|
+
/** Override home (tests). */
|
|
89
|
+
home?: string | undefined;
|
|
90
|
+
/** Prompter for the loop-closer env offer and the bind-host offers. */
|
|
91
|
+
prompter: Prompter;
|
|
92
|
+
/** Platform for preflight's daemon hint. Default `process.platform`. */
|
|
93
|
+
platform?: NodeJS.Platform | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the run is interactive (a TTY is attached). Gates the best-effort
|
|
96
|
+
* Tailscale offer and the `0.0.0.0` confirm — a non-interactive run never
|
|
97
|
+
* silently exposes the server beyond localhost. Default `true`.
|
|
98
|
+
*/
|
|
99
|
+
interactive?: boolean | undefined;
|
|
100
|
+
}
|
|
101
|
+
/** A teaching error from `up`; the runtime renders `.message` as one stderr line. */
|
|
102
|
+
export declare class UpError extends Error {
|
|
103
|
+
constructor(message: string);
|
|
104
|
+
}
|
|
105
|
+
export interface RunArgsInput {
|
|
106
|
+
host: string;
|
|
107
|
+
dataVolume: string;
|
|
108
|
+
tag: string;
|
|
109
|
+
/**
|
|
110
|
+
* Absolute path to the 0600 deploy env-file ({@link writeDeployEnvFile}). The
|
|
111
|
+
* secrets (`LIBRARIAN_AGENT_TOKEN`, `LIBRARIAN_SECRET_KEY`) and the loopback
|
|
112
|
+
* `LIBRARIAN_ALLOW_NO_AUTH` are delivered via `--env-file <path>`, never inline
|
|
113
|
+
* on argv (ADR 0008 P4).
|
|
114
|
+
*/
|
|
115
|
+
envFile: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Construct the `docker run` argv (everything after `docker`). The SINGLE place
|
|
119
|
+
* the run vector is assembled.
|
|
120
|
+
*
|
|
121
|
+
* Secrets are delivered via `--env-file <path>` — NOT inline `-e` — so the agent
|
|
122
|
+
* token, the master key, and (loopback only) `LIBRARIAN_ALLOW_NO_AUTH` never
|
|
123
|
+
* appear on argv (ADR 0008 P4). `--env-file` keeps them off argv (and out of any
|
|
124
|
+
* argv-echoing error); it does NOT hide them from `docker inspect .Config.Env`
|
|
125
|
+
* (docker expands the file client-side into the same env list) — an accepted
|
|
126
|
+
* trade-off (the wins are off-argv + the master key off `/data`).
|
|
127
|
+
*
|
|
128
|
+
* The image runs `tini` as PID 1, so `--init` is deliberately omitted. The
|
|
129
|
+
* publish address is derived from `host`; the loopback no-auth bypass
|
|
130
|
+
* (`LIBRARIAN_ALLOW_NO_AUTH`) lives INSIDE the env-file (loopback-only — see
|
|
131
|
+
* {@link writeDeployEnvFile}), not on this argv.
|
|
132
|
+
*/
|
|
133
|
+
export declare function buildRunArgs(input: RunArgsInput): string[];
|
|
134
|
+
/** The secrets the deploy env-file carries (off argv, into `--env-file`). */
|
|
135
|
+
export interface DeployEnvInput {
|
|
136
|
+
/** The agent token (`LIBRARIAN_AGENT_TOKEN`) — minted by `up`, reused by `update`. */
|
|
137
|
+
agentToken: string;
|
|
138
|
+
/**
|
|
139
|
+
* The master key (`LIBRARIAN_SECRET_KEY`). `up` always supplies the CLI-minted
|
|
140
|
+
* key. `update` supplies the PRESERVED key read back from the old container, or
|
|
141
|
+
* OMITS it (undefined/empty) when the old env is unreadable — then the server
|
|
142
|
+
* resolves the key from `/data/secret.key` (env → file → generate), never a
|
|
143
|
+
* destructive fresh mint that would orphan already-encrypted secrets.
|
|
144
|
+
*/
|
|
145
|
+
secretKey?: string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* The resolved bind host — drives the loopback-only `LIBRARIAN_ALLOW_NO_AUTH`.
|
|
148
|
+
* `127.0.0.1` → write `LIBRARIAN_ALLOW_NO_AUTH=true` (loopback no-auth bypass);
|
|
149
|
+
* beyond localhost → omit it so /mcp requires the agent token (spec §6).
|
|
150
|
+
*/
|
|
151
|
+
host: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Write the 0600 deploy env-file `docker run --env-file` reads, returning its
|
|
155
|
+
* path. It carries `LIBRARIAN_AGENT_TOKEN`, `LIBRARIAN_SECRET_KEY` (when
|
|
156
|
+
* supplied), and (loopback only) `LIBRARIAN_ALLOW_NO_AUTH=true`. Mode 0600 on
|
|
157
|
+
* create AND an unconditional `chmodSync(0o600)` so a pre-existing looser file is
|
|
158
|
+
* tightened (same discipline as env.ts `writeEnvFile`). The directory is created
|
|
159
|
+
* if missing.
|
|
160
|
+
*
|
|
161
|
+
* Format is `KEY=VALUE` lines (docker's `--env-file` syntax — NOT shell, so no
|
|
162
|
+
* quoting/`export`). The minted secrets are 64-hex with no special chars, so a
|
|
163
|
+
* raw value is safe; we reject a value with a newline (it would corrupt the file
|
|
164
|
+
* / smuggle a second var) rather than emit a malformed file.
|
|
165
|
+
*/
|
|
166
|
+
export declare function writeDeployEnvFile(deployDir: string, input: DeployEnvInput): string;
|
|
167
|
+
export interface UpResult {
|
|
168
|
+
/** Human-readable report for stdout (carries the master key ONCE). */
|
|
169
|
+
output: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Run `server up`. Throws `UpError` (teaching message) on any failure; on a
|
|
173
|
+
* failed health-wait it rolls the container back first so no half-up state is
|
|
174
|
+
* left behind. Works for any resolved bind host (loopback / tailnet / all
|
|
175
|
+
* interfaces); the bind choice drives the auth model (§6).
|
|
176
|
+
*/
|
|
177
|
+
export declare function runUp(options: UpOptions, deps: UpDeps): Promise<UpResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Health-wait tuning shared by `up` and `update` (the bounded poll + log-tail).
|
|
180
|
+
* A subset of `UpOptions` so `update` can reuse {@link waitForHealthy} without
|
|
181
|
+
* importing the whole `UpOptions` shape.
|
|
182
|
+
*/
|
|
183
|
+
export interface HealthWaitOptions {
|
|
184
|
+
/** Health-wait bound: how many polls before declaring failure (small in tests). */
|
|
185
|
+
healthAttempts?: number | undefined;
|
|
186
|
+
/** Milliseconds between health polls (0 in tests). */
|
|
187
|
+
healthIntervalMs?: number | undefined;
|
|
188
|
+
/** Lines of `docker logs` to surface on a failed health-wait. */
|
|
189
|
+
logTailLines?: number | undefined;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Poll `docker inspect … Health.Status` until `healthy`, bounded. On timeout or
|
|
193
|
+
* an unhealthy report: surface `docker logs --tail` (REDACTED), roll the
|
|
194
|
+
* container back (`docker rm -f`), and throw — leaving NO half-up container.
|
|
195
|
+
*
|
|
196
|
+
* Exported so `update` recreates with the IDENTICAL health-wait + rollback
|
|
197
|
+
* pattern (a failed recreate force-removes the new container and never advances
|
|
198
|
+
* deploy-state). The thrown `UpError`'s message is already secret-redacted.
|
|
199
|
+
*/
|
|
200
|
+
export declare function waitForHealthy(options: HealthWaitOptions): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Check out `ref` in `dir` without letting a `--…`-shaped ref inject a git
|
|
203
|
+
* option (S-1). `git checkout` does NOT honor `--end-of-options` — it reads the
|
|
204
|
+
* marker itself as a pathspec (`pathspec '--end-of-options' did not match`,
|
|
205
|
+
* verified on git 2.43), so guarding the ref on the checkout fails outright.
|
|
206
|
+
* `git rev-parse` DOES honor `--end-of-options`, so we resolve the ref to a
|
|
207
|
+
* commit SHA there (the injection guard that actually works), then check out
|
|
208
|
+
* that SHA — a hex object id can never be parsed as an option.
|
|
209
|
+
*/
|
|
210
|
+
export declare function checkoutRef(dir: string, ref: string): Promise<void>;
|
|
211
|
+
//# sourceMappingURL=up.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/server/up.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAU7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,qFAAqF;AACrF,eAAO,MAAM,QAAQ,8CAA8C,CAAC;AAEpE,wFAAwF;AACxF,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C,uFAAuF;AACvF,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,6EAA6E;AAC7E,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,2EAA2E;AAC3E,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,+CAA0C,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAID,kFAAkF;AAClF,MAAM,MAAM,KAAK,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAMlD,mFAAmF;AACnF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,CAE1C;AAED,sCAAsC;AACtC,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAID,qFAAqF;AACrF,MAAM,MAAM,WAA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