borgmcp-server 0.1.1 → 0.1.5
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/README.md +70 -22
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/dist/cli.js +62 -11
- package/dist/cli.js.map +1 -1
- package/dist/coordination-api.d.ts +3 -1
- package/dist/coordination-api.js +476 -78
- package/dist/coordination-api.js.map +1 -1
- package/dist/credentials.d.ts +13 -7
- package/dist/credentials.js +77 -15
- package/dist/credentials.js.map +1 -1
- package/dist/debug-log.d.ts +76 -0
- package/dist/debug-log.js +124 -0
- package/dist/debug-log.js.map +1 -0
- package/dist/enrollment.d.ts +3 -11
- package/dist/enrollment.js +21 -60
- package/dist/enrollment.js.map +1 -1
- package/dist/https-server.d.ts +5 -20
- package/dist/https-server.js +108 -50
- package/dist/https-server.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/message-taxonomy.d.ts +38 -0
- package/dist/message-taxonomy.js +218 -0
- package/dist/message-taxonomy.js.map +1 -0
- package/dist/migrations.d.ts +4 -0
- package/dist/migrations.js +99 -0
- package/dist/migrations.js.map +1 -1
- package/dist/operator-error.d.ts +2 -1
- package/dist/operator-error.js +23 -5
- package/dist/operator-error.js.map +1 -1
- package/dist/role-section.d.ts +14 -0
- package/dist/role-section.js +87 -0
- package/dist/role-section.js.map +1 -0
- package/dist/service.d.ts +14 -4
- package/dist/service.js +243 -25
- package/dist/service.js.map +1 -1
- package/dist/start-options.d.ts +5 -1
- package/dist/start-options.js +17 -3
- package/dist/start-options.js.map +1 -1
- package/dist/store.d.ts +106 -8
- package/dist/store.js +772 -120
- package/dist/store.js.map +1 -1
- package/npm-shrinkwrap.json +6 -7
- package/package.json +2 -2
- package/src/cli.ts +61 -11
- package/src/coordination-api.ts +490 -72
- package/src/credentials.ts +103 -19
- package/src/debug-log.ts +165 -0
- package/src/enrollment.ts +32 -78
- package/src/https-server.ts +113 -78
- package/src/index.ts +1 -1
- package/src/message-taxonomy.ts +284 -0
- package/src/migrations.ts +102 -0
- package/src/operator-error.ts +40 -6
- package/src/role-section.ts +108 -0
- package/src/service.ts +268 -27
- package/src/start-options.ts +21 -4
- package/src/store.ts +887 -142
- package/dist/protocol-draft.d.ts +0 -2
- package/dist/protocol-draft.js +0 -31
- package/dist/protocol-draft.js.map +0 -1
- package/src/protocol-draft.ts +0 -32
package/dist/operator-error.js
CHANGED
|
@@ -5,6 +5,9 @@ const publicMessages = Object.freeze({
|
|
|
5
5
|
START_HOST_MISSING: "Provide an IP address after --host.",
|
|
6
6
|
START_PORT_MISSING: "Provide a port number after --port.",
|
|
7
7
|
START_PORT_INVALID: "Provide --port as an integer from 0 to 65535.",
|
|
8
|
+
START_LOG_LEVEL_DUPLICATE: "Provide --log-level only once.",
|
|
9
|
+
START_LOG_LEVEL_MISSING: "Provide debug after --log-level.",
|
|
10
|
+
START_LOG_LEVEL_INVALID: "Use --log-level debug or omit the option.",
|
|
8
11
|
START_OPTION_UNKNOWN: "Use only documented start options; run borg-mcp-server help.",
|
|
9
12
|
BIND_PORT_INVALID: "Configure the listen port as an integer from 0 to 65535.",
|
|
10
13
|
BIND_HOST_INVALID: "Configure --host as an explicit IP address.",
|
|
@@ -13,8 +16,9 @@ const publicMessages = Object.freeze({
|
|
|
13
16
|
BIND_LAN_CONSENT: "Add --lan to consent to this private-LAN start.",
|
|
14
17
|
SERVER_FILES_MISSING: "Configure BORG_SERVER_DATA_DIR or the required TLS file variables.",
|
|
15
18
|
DATA_PATH_SYMLINK: "Choose a BORG_SERVER_DATA_DIR path that contains no symbolic links.",
|
|
19
|
+
INSTALLATION_EXISTS: "An installation already exists in BORG_SERVER_DATA_DIR. To destroy and recreate it, stop the server and run borg-mcp-server setup --reinitialize.",
|
|
16
20
|
LAN_CA_KEY_ONLINE: "Move ca.key out of the runtime data directory before private-LAN startup.",
|
|
17
|
-
RUNTIME_ACTIVE: "Stop the server before running offline
|
|
21
|
+
RUNTIME_ACTIVE: "Stop the server before running setup or offline administration.",
|
|
18
22
|
RUNTIME_LOCK_UNSAFE: "Ensure runtime.lock is a private regular file before retrying.",
|
|
19
23
|
RUNTIME_LOCK_INVALID: "Confirm the server is stopped, then remove the invalid runtime.lock.",
|
|
20
24
|
RUNTIME_LOCK_STALE: "Confirm the recorded server process is stopped, then remove runtime.lock.",
|
|
@@ -24,26 +28,34 @@ const publicMessages = Object.freeze({
|
|
|
24
28
|
CLIENT_NOT_FOUND: "Provide an existing active client ID.",
|
|
25
29
|
GRANT_NOT_FOUND: "Provide an existing client cube grant.",
|
|
26
30
|
RECOVERY_INVALID: "Provide the active recovery credential through the private prompt.",
|
|
31
|
+
INVITATION_BUSY: "Confirm no invitation or offline administration command is running, then remove invitation-mint.lock.",
|
|
32
|
+
INVITATION_CONTENTION: "Retry invitation minting after the current server database write completes.",
|
|
33
|
+
INVITATION_SCHEMA_MISMATCH: "Invitation minting is unavailable while a server with an incompatible schema is running. Stop the server and rerun this command, or use the CLI version that matches the running server.",
|
|
34
|
+
INVITATION_CUBE_NOT_FOUND: "Provide an existing cube name or full cube ID.",
|
|
35
|
+
INVITATION_CUBE_SELECTOR_INVALID: "Provide a full canonical cube UUID or an exact case-sensitive cube name.",
|
|
36
|
+
INVITATION_CUBE_AMBIGUOUS: "Cube name is ambiguous. Rerun with the full cube ID.",
|
|
27
37
|
});
|
|
28
38
|
const operatorErrorCodes = new WeakMap();
|
|
39
|
+
const operatorErrorMessages = new WeakMap();
|
|
29
40
|
const operatorErrorCapability = Object.freeze({});
|
|
30
41
|
class OperatorError extends Error {
|
|
31
42
|
#operatorCode;
|
|
32
|
-
constructor(capability, code) {
|
|
33
|
-
super(Object.hasOwn(publicMessages, code) ? publicMessages[code] : "Operator error rejected.");
|
|
43
|
+
constructor(capability, code, publicMessage) {
|
|
44
|
+
super(publicMessage ?? (Object.hasOwn(publicMessages, code) ? publicMessages[code] : "Operator error rejected."));
|
|
34
45
|
if (capability !== operatorErrorCapability || !Object.hasOwn(publicMessages, code)) {
|
|
35
46
|
throw new Error("Operator error construction is unavailable.");
|
|
36
47
|
}
|
|
37
48
|
this.name = "OperatorError";
|
|
38
49
|
this.#operatorCode = code;
|
|
39
50
|
operatorErrorCodes.set(this, code);
|
|
51
|
+
operatorErrorMessages.set(this, this.message);
|
|
40
52
|
Object.freeze(this);
|
|
41
53
|
}
|
|
42
54
|
get code() {
|
|
43
55
|
return this.#operatorCode;
|
|
44
56
|
}
|
|
45
57
|
get publicMessage() {
|
|
46
|
-
return publicMessages[this.#operatorCode];
|
|
58
|
+
return operatorErrorMessages.get(this) ?? publicMessages[this.#operatorCode];
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
61
|
export const operatorErrors = Object.freeze(Object.fromEntries(Object.keys(publicMessages).map((code) => [
|
|
@@ -58,6 +70,12 @@ export function operatorPublicMessage(error) {
|
|
|
58
70
|
return null;
|
|
59
71
|
if (Object.getPrototypeOf(error) !== OperatorError.prototype || !Object.isFrozen(error))
|
|
60
72
|
return null;
|
|
61
|
-
return publicMessages[code];
|
|
73
|
+
return operatorErrorMessages.get(error) ?? publicMessages[code];
|
|
74
|
+
}
|
|
75
|
+
export function invitationCubeAmbiguousError(candidateIds) {
|
|
76
|
+
if (candidateIds.length < 2 || candidateIds.some((id) => !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(id))) {
|
|
77
|
+
throw new Error("Ambiguous cube candidates must contain canonical cube IDs.");
|
|
78
|
+
}
|
|
79
|
+
return new OperatorError(operatorErrorCapability, "INVITATION_CUBE_AMBIGUOUS", `Cube name is ambiguous. Rerun with the full cube ID. Candidate cube IDs: ${candidateIds.join(", ")}`);
|
|
62
80
|
}
|
|
63
81
|
//# sourceMappingURL=operator-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-error.js","sourceRoot":"","sources":["../src/operator-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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CACjD,CAAC,CAC4C,CACjD,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7D,MAAM,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,aAAa,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrG,OAAO,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,YAA+B;IAC1E,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CACtD,CAAC,4EAA4E,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC1F,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,IAAI,aAAa,CACtB,uBAAuB,EACvB,2BAA2B,EAC3B,4EAA4E,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type RoleSectionPatchOp = {
|
|
2
|
+
readonly action: "replace";
|
|
3
|
+
readonly heading: string;
|
|
4
|
+
readonly body: string;
|
|
5
|
+
} | {
|
|
6
|
+
readonly action: "insert";
|
|
7
|
+
readonly heading: string;
|
|
8
|
+
readonly body: string;
|
|
9
|
+
readonly after?: string | null;
|
|
10
|
+
} | {
|
|
11
|
+
readonly action: "delete";
|
|
12
|
+
readonly heading: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function patchRoleSectionText(text: string, operation: RoleSectionPatchOp): string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export function patchRoleSectionText(text, operation) {
|
|
2
|
+
validateHeading(operation.heading);
|
|
3
|
+
const sections = parseSections(text);
|
|
4
|
+
const target = normalizedHeading(operation.heading);
|
|
5
|
+
const index = sections.findIndex((section) => section.heading !== null && normalizedHeading(section.heading) === target);
|
|
6
|
+
if (operation.action === "replace") {
|
|
7
|
+
if (index === -1)
|
|
8
|
+
throw new Error("Role section not found.");
|
|
9
|
+
sections[index] = renderedSection(operation.heading, operation.body);
|
|
10
|
+
return serializeSections(sections);
|
|
11
|
+
}
|
|
12
|
+
if (operation.action === "delete") {
|
|
13
|
+
if (index === -1)
|
|
14
|
+
throw new Error("Role section not found.");
|
|
15
|
+
sections.splice(index, 1);
|
|
16
|
+
return serializeSections(sections);
|
|
17
|
+
}
|
|
18
|
+
if (index !== -1)
|
|
19
|
+
throw new Error("Role section already exists.");
|
|
20
|
+
const section = renderedSection(operation.heading, operation.body);
|
|
21
|
+
if (operation.after == null) {
|
|
22
|
+
ensureTrailingNewline(sections, sections.length - 1);
|
|
23
|
+
sections.push(section);
|
|
24
|
+
return serializeSections(sections);
|
|
25
|
+
}
|
|
26
|
+
validateHeading(operation.after);
|
|
27
|
+
const after = normalizedHeading(operation.after);
|
|
28
|
+
const afterIndex = sections.findIndex((candidate) => candidate.heading !== null && normalizedHeading(candidate.heading) === after);
|
|
29
|
+
if (afterIndex === -1)
|
|
30
|
+
throw new Error("Role section insertion point does not exist.");
|
|
31
|
+
ensureTrailingNewline(sections, afterIndex);
|
|
32
|
+
sections.splice(afterIndex + 1, 0, section);
|
|
33
|
+
return serializeSections(sections);
|
|
34
|
+
}
|
|
35
|
+
function parseSections(text) {
|
|
36
|
+
const sections = [];
|
|
37
|
+
const lines = text.split("\n");
|
|
38
|
+
let heading = null;
|
|
39
|
+
let body = "";
|
|
40
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
41
|
+
const line = lines[index];
|
|
42
|
+
const sourceLine = index < lines.length - 1 ? `${line}\n` : line;
|
|
43
|
+
if (isLabelLine(line)) {
|
|
44
|
+
sections.push({ heading, body });
|
|
45
|
+
heading = line.slice(0, -1).trim();
|
|
46
|
+
body = sourceLine;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
body += sourceLine;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
sections.push({ heading, body });
|
|
53
|
+
return sections;
|
|
54
|
+
}
|
|
55
|
+
function isLabelLine(line) {
|
|
56
|
+
if (/^\s/u.test(line) || !line.endsWith(":"))
|
|
57
|
+
return false;
|
|
58
|
+
const label = line.slice(0, -1);
|
|
59
|
+
return label.length > 0 && label.length <= 60 && !label.includes(":") &&
|
|
60
|
+
!/^[*\-#>`]/u.test(label);
|
|
61
|
+
}
|
|
62
|
+
function renderedSection(heading, body) {
|
|
63
|
+
const normalizedBody = body === "" || body.endsWith("\n") ? body : `${body}\n`;
|
|
64
|
+
return {
|
|
65
|
+
heading: heading.trim(),
|
|
66
|
+
body: `${heading.trim()}:\n${normalizedBody}`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function ensureTrailingNewline(sections, index) {
|
|
70
|
+
const section = sections[index];
|
|
71
|
+
if (section !== undefined && section.body !== "" && !section.body.endsWith("\n")) {
|
|
72
|
+
sections[index] = { ...section, body: `${section.body}\n` };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function serializeSections(sections) {
|
|
76
|
+
return sections.map((section) => section.body).join("");
|
|
77
|
+
}
|
|
78
|
+
function normalizedHeading(heading) {
|
|
79
|
+
return heading.trim().toLowerCase();
|
|
80
|
+
}
|
|
81
|
+
function validateHeading(heading) {
|
|
82
|
+
if (typeof heading !== "string" || /[\r\n]/u.test(heading) ||
|
|
83
|
+
!isLabelLine(`${heading.trim()}:`)) {
|
|
84
|
+
throw new TypeError("Role section heading is invalid.");
|
|
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L,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE;QACvB,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,MAAM,cAAc,EAAE;KAC9C,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAuB,EAAE,KAAa;IACnE,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjF,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAgC;IACzD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe;IACxC,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC;QACtD,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
|
package/dist/service.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { type BootstrapResult } from "./bootstrap.js";
|
|
2
|
+
import { type CubeInvitationResult } from "./credentials.js";
|
|
2
3
|
import { type HttpsServerOptions, type RunningServer } from "./https-server.js";
|
|
3
|
-
import { openStore, type StorageLimits } from "./store.js";
|
|
4
|
+
import { openStore, type LivenessStore, type StorageLimits } from "./store.js";
|
|
4
5
|
import type { CubeAccess } from "./store.js";
|
|
5
6
|
export interface ServerService {
|
|
6
7
|
readonly start: (args: readonly string[]) => Promise<void>;
|
|
7
|
-
readonly setup?: () => Promise<BootstrapResult>;
|
|
8
|
+
readonly setup?: (options: SetupOptions) => Promise<BootstrapResult>;
|
|
8
9
|
readonly rotateClient?: (clientId: string) => Promise<string>;
|
|
9
10
|
readonly revokeClient?: (clientId: string) => Promise<void>;
|
|
10
11
|
readonly grantClient?: (clientId: string, cubeId: string, access: CubeAccess) => Promise<void>;
|
|
11
12
|
readonly ungrantClient?: (clientId: string, cubeId: string) => Promise<void>;
|
|
12
|
-
readonly createClientInvitation?: (recoveryCredential: string) => Promise<string>;
|
|
13
|
+
readonly createClientInvitation?: (recoveryCredential: string, cubeSelector?: string, access?: CubeAccess) => Promise<string | CubeInvitationResult>;
|
|
13
14
|
readonly replaceOwnerInvitation?: (recoveryCredential: string) => Promise<string>;
|
|
14
15
|
}
|
|
16
|
+
export interface SetupOptions {
|
|
17
|
+
readonly reinitialize: boolean;
|
|
18
|
+
}
|
|
15
19
|
export interface ServerEnvironment {
|
|
16
20
|
readonly BORG_SERVER_TLS_KEY_FILE?: string;
|
|
17
21
|
readonly BORG_SERVER_TLS_CERT_FILE?: string;
|
|
@@ -29,11 +33,15 @@ interface ServiceDependencies {
|
|
|
29
33
|
readonly startServer: (options: HttpsServerOptions) => Promise<RunningServer>;
|
|
30
34
|
readonly onStarted: (origin: string) => void;
|
|
31
35
|
readonly waitForShutdown: (server: RunningServer, signal?: AbortSignal) => Promise<void>;
|
|
36
|
+
readonly debugOutput?: (line: string) => void;
|
|
32
37
|
readonly installShutdownHandlers?: () => {
|
|
33
38
|
readonly signal: AbortSignal;
|
|
34
39
|
readonly dispose: () => void;
|
|
35
40
|
};
|
|
36
41
|
readonly openStore?: typeof openStore;
|
|
42
|
+
readonly startLivenessScheduler?: (liveness: LivenessStore) => {
|
|
43
|
+
readonly stop: () => void;
|
|
44
|
+
};
|
|
37
45
|
readonly onStartupPhase?: (phase: "pre-lock" | "post-lock" | "pre-listen") => Promise<void>;
|
|
38
46
|
}
|
|
39
47
|
export interface NodeServerTestHooks {
|
|
@@ -48,12 +56,14 @@ export declare function assertLanCaKeyOffline(runtimeDataDirectory: string): Pro
|
|
|
48
56
|
export declare function selectServerEnvironment(environment: NodeJS.ProcessEnv): ServerEnvironment;
|
|
49
57
|
export declare function resolveStorageLimits(environment: ServerEnvironment): StorageLimits;
|
|
50
58
|
export declare const nodeServerService: ServerService;
|
|
59
|
+
export declare function setupNodeServerInstallation(setupDataDirectory: string, bindHost: string, options: SetupOptions): Promise<BootstrapResult>;
|
|
51
60
|
export declare function createOfflineCredentialService(offlineDataDirectory: string): Pick<Required<ServerService>, "rotateClient" | "revokeClient" | "grantClient" | "ungrantClient" | "createClientInvitation" | "replaceOwnerInvitation">;
|
|
52
61
|
interface RuntimeLock {
|
|
53
62
|
readonly release: () => Promise<void>;
|
|
54
63
|
}
|
|
55
64
|
export declare function isFatalTeardownError(error: unknown): boolean;
|
|
56
|
-
export declare function acquireRuntimeLock(runtimeDataDirectory: string): Promise<RuntimeLock>;
|
|
65
|
+
export declare function acquireRuntimeLock(runtimeDataDirectory: string, purpose?: "server" | "exclusive-admin"): Promise<RuntimeLock>;
|
|
66
|
+
export declare function acquireInvitationMintLock(runtimeDataDirectory: string): Promise<RuntimeLock>;
|
|
57
67
|
export declare function installProcessShutdownHandlers(): {
|
|
58
68
|
readonly signal: AbortSignal;
|
|
59
69
|
readonly dispose: () => void;
|