run402-mcp 4.61.0 → 4.62.0
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/core/dist/config.d.ts.map +1 -1
- package/core/dist/config.js +12 -3
- package/core/dist/config.js.map +1 -1
- package/core/dist/profiles.d.ts.map +1 -1
- package/core/dist/profiles.js +5 -1
- package/core/dist/profiles.js.map +1 -1
- package/core/dist/redact.d.ts +44 -0
- package/core/dist/redact.d.ts.map +1 -0
- package/core/dist/redact.js +64 -0
- package/core/dist/redact.js.map +1 -0
- package/dist/tools/rooms-shared.d.ts.map +1 -1
- package/dist/tools/rooms-shared.js +12 -2
- package/dist/tools/rooms-shared.js.map +1 -1
- package/package.json +1 -1
- package/sdk/core-dist/config.js +12 -3
- package/sdk/core-dist/profiles.js +5 -1
- package/sdk/core-dist/redact.d.ts +44 -0
- package/sdk/core-dist/redact.js +64 -0
- package/sdk/dist/namespaces/gitvault.d.ts +30 -3
- package/sdk/dist/namespaces/gitvault.d.ts.map +1 -1
- package/sdk/dist/namespaces/gitvault.js +99 -10
- package/sdk/dist/namespaces/gitvault.js.map +1 -1
- package/sdk/dist/node/gitvault-publication.d.ts +67 -1
- package/sdk/dist/node/gitvault-publication.d.ts.map +1 -1
- package/sdk/dist/node/gitvault-publication.js +60 -2
- package/sdk/dist/node/gitvault-publication.js.map +1 -1
- package/sdk/dist/node/index.d.ts +2 -2
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +1 -1
- package/sdk/dist/node/index.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,2BAA2B,CAAC;AAEzD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS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E,MAAM,CAAA;CAAO,GACvF,eAAe,CAiBjB;AAED,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAKpD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAGhD;AAeD,wBAAgB,eAAe,IAAI,OAAO,CAQzC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAoBzC"}
|
package/core/dist/config.js
CHANGED
|
@@ -2,6 +2,7 @@ import { homedir } from "node:os";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { existsSync, renameSync, mkdirSync, chmodSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
5
|
+
import { describeRejectedValue } from "./redact.js";
|
|
5
6
|
export const DEFAULT_API_BASE = "https://api.run402.com";
|
|
6
7
|
/**
|
|
7
8
|
* Validate a user-supplied API base URL. Throws a clear error message that
|
|
@@ -25,10 +26,10 @@ function validateApiBase(envVar, raw, fallback) {
|
|
|
25
26
|
u = new URL(raw);
|
|
26
27
|
}
|
|
27
28
|
catch {
|
|
28
|
-
throw new Error(`${envVar} is not a valid URL: ${JSON.stringify(raw)}. Expected an http(s) URL like https://api.run402.com.`);
|
|
29
|
+
throw new Error(`${envVar} is not a valid URL: ${JSON.stringify(describeRejectedValue(raw))}. Expected an http(s) URL like https://api.run402.com.`);
|
|
29
30
|
}
|
|
30
31
|
if (u.protocol !== "https:" && u.protocol !== "http:") {
|
|
31
|
-
throw new Error(`${envVar} must use http(s):, got ${u.protocol} (full value: ${JSON.stringify(raw)}).`);
|
|
32
|
+
throw new Error(`${envVar} must use http(s):, got ${u.protocol} (full value: ${JSON.stringify(describeRejectedValue(raw))}).`);
|
|
32
33
|
}
|
|
33
34
|
return raw;
|
|
34
35
|
}
|
|
@@ -81,7 +82,15 @@ function assertSafeProfileName(name) {
|
|
|
81
82
|
if (name === DEFAULT_PROFILE)
|
|
82
83
|
return;
|
|
83
84
|
if (!isValidProfileName(name)) {
|
|
84
|
-
|
|
85
|
+
// A value that failed this check is a value we know nothing about — the
|
|
86
|
+
// most likely mistake is a typo, but kychee-com/run402-private#640 was a
|
|
87
|
+
// Base-mainnet private key pasted into RUN402_WALLET (a NAME field), and
|
|
88
|
+
// the raw value used to be echoed straight into this message and
|
|
89
|
+
// wherever it propagated (terminal, logs, session transcripts).
|
|
90
|
+
// describeRejectedValue() shows short/plain values in full (useful for
|
|
91
|
+
// an actual typo) and redacts anything long or hex-shaped enough to be
|
|
92
|
+
// a secret instead of a name.
|
|
93
|
+
throw new Error(`Invalid wallet/profile name ${JSON.stringify(describeRejectedValue(name))}. ` +
|
|
85
94
|
"Names must match /^[a-z0-9][a-z0-9_-]{0,63}$/ (lowercase letters, digits, '_' and '-'). " +
|
|
86
95
|
"Check the RUN402_WALLET / RUN402_PROFILE env var.");
|
|
87
96
|
}
|
package/core/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;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,KAAK,SAAS,IAAI,wBAAwB,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAChG,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAChF,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACzC,2EAA2E;IAC3E,yEAAyE;IACzE,oEAAoE;IACpE,wEAAwE;IACxE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAChD,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC;YACH,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,uEAAuE;YACvE,sCAAsC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAsBH,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAqBD,wBAAgB,cAAc,IAAI,UAAU,CAU3C;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAErD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAGzC;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAInD;AAID,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBrD;AAMD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAUzD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAG/D;AAID,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAa3C;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAKhD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CA0CpE"}
|
package/core/dist/profiles.js
CHANGED
|
@@ -18,6 +18,7 @@ import { readFileSync, writeFileSync, mkdirSync, renameSync, chmodSync, existsSy
|
|
|
18
18
|
import { dirname, join } from "node:path";
|
|
19
19
|
import { randomBytes } from "node:crypto";
|
|
20
20
|
import { getConfigBaseDir, getProfilesDir, DEFAULT_PROFILE, isValidProfileName, } from "./config.js";
|
|
21
|
+
import { describeRejectedValue } from "./redact.js";
|
|
21
22
|
function atomicWrite(p, content, mode) {
|
|
22
23
|
const dir = dirname(p);
|
|
23
24
|
mkdirSync(dir, { recursive: true });
|
|
@@ -153,7 +154,10 @@ export function removeProfile(name) {
|
|
|
153
154
|
*/
|
|
154
155
|
export function renameProfile(oldName, newName) {
|
|
155
156
|
if (!isValidProfileName(newName)) {
|
|
156
|
-
|
|
157
|
+
// See describeRejectedValue()'s doc comment (kychee-com/run402-private#640):
|
|
158
|
+
// a rejected value may be a secret pasted into a name field, so it is
|
|
159
|
+
// never safe to echo verbatim here.
|
|
160
|
+
throw new Error(`Invalid wallet name ${JSON.stringify(describeRejectedValue(newName))}.`);
|
|
157
161
|
}
|
|
158
162
|
if (newName === oldName)
|
|
159
163
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,GACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,GACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,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C,WAAW,OAAO,cAAc,CAAC,CAAC;IACpD,CAAC;IACD,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe-echo policy for values that failed local (client-side) validation.
|
|
3
|
+
*
|
|
4
|
+
* A value rejected by a format/existence check is a value we know nothing
|
|
5
|
+
* about — the CLI has only established what it is NOT. The likeliest
|
|
6
|
+
* failure is an ordinary typo, but the second likeliest, demonstrated in
|
|
7
|
+
* practice, is a credential pasted into the wrong slot:
|
|
8
|
+
* kychee-com/run402-private#640 — a Base-mainnet private key holding real
|
|
9
|
+
* funds landed in `RUN402_WALLET` (which takes a wallet NAME, not a key),
|
|
10
|
+
* failed the name check, and was printed verbatim to a terminal, a log, and
|
|
11
|
+
* a session transcript.
|
|
12
|
+
*
|
|
13
|
+
* `describeRejectedValue` is the one place that decides what a rejected
|
|
14
|
+
* value is safe to show, so every call site — wallet names, org ids, room
|
|
15
|
+
* keys, unknown commands/subcommands, "not found" lookups — gets the same
|
|
16
|
+
* answer instead of each reinventing (or forgetting) the judgment call.
|
|
17
|
+
*
|
|
18
|
+
* Short, low-entropy values (ordinary typos) are returned unchanged — that
|
|
19
|
+
* is what makes the resulting error message useful. Long or
|
|
20
|
+
* high-entropy-looking values are replaced with a shape-only description
|
|
21
|
+
* (character count only), never a substring or prefix of the original:
|
|
22
|
+
* even a short prefix of a private key is more than a debugging aid needs
|
|
23
|
+
* and more than a leak should give up.
|
|
24
|
+
*
|
|
25
|
+
* This is a heuristic, not a content-aware secret scanner: treat "returned
|
|
26
|
+
* unchanged" as "short and plain enough to be a typo," not as proof the
|
|
27
|
+
* value holds no secret. Callers with a value that is never supposed to be
|
|
28
|
+
* secret-shaped in the first place (a service key, an admin key) should
|
|
29
|
+
* still never echo it at all, redacted or not — this helper is for slots
|
|
30
|
+
* that normally hold a plain identifier and occasionally, by mistake,
|
|
31
|
+
* don't.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Return `value` unchanged when it is short and plain enough to be a
|
|
35
|
+
* harmless typo; otherwise return a shape-only placeholder (character count
|
|
36
|
+
* only — never a substring) that is still safe to embed in a message or a
|
|
37
|
+
* structured `details` field.
|
|
38
|
+
*
|
|
39
|
+
* Never throws. Coerces non-string input the same way template-literal
|
|
40
|
+
* interpolation would, so a caller can pass whatever it already has without
|
|
41
|
+
* a separate type check.
|
|
42
|
+
*/
|
|
43
|
+
export declare function describeRejectedValue(value: unknown): string;
|
|
44
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAmBH;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM5D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe-echo policy for values that failed local (client-side) validation.
|
|
3
|
+
*
|
|
4
|
+
* A value rejected by a format/existence check is a value we know nothing
|
|
5
|
+
* about — the CLI has only established what it is NOT. The likeliest
|
|
6
|
+
* failure is an ordinary typo, but the second likeliest, demonstrated in
|
|
7
|
+
* practice, is a credential pasted into the wrong slot:
|
|
8
|
+
* kychee-com/run402-private#640 — a Base-mainnet private key holding real
|
|
9
|
+
* funds landed in `RUN402_WALLET` (which takes a wallet NAME, not a key),
|
|
10
|
+
* failed the name check, and was printed verbatim to a terminal, a log, and
|
|
11
|
+
* a session transcript.
|
|
12
|
+
*
|
|
13
|
+
* `describeRejectedValue` is the one place that decides what a rejected
|
|
14
|
+
* value is safe to show, so every call site — wallet names, org ids, room
|
|
15
|
+
* keys, unknown commands/subcommands, "not found" lookups — gets the same
|
|
16
|
+
* answer instead of each reinventing (or forgetting) the judgment call.
|
|
17
|
+
*
|
|
18
|
+
* Short, low-entropy values (ordinary typos) are returned unchanged — that
|
|
19
|
+
* is what makes the resulting error message useful. Long or
|
|
20
|
+
* high-entropy-looking values are replaced with a shape-only description
|
|
21
|
+
* (character count only), never a substring or prefix of the original:
|
|
22
|
+
* even a short prefix of a private key is more than a debugging aid needs
|
|
23
|
+
* and more than a leak should give up.
|
|
24
|
+
*
|
|
25
|
+
* This is a heuristic, not a content-aware secret scanner: treat "returned
|
|
26
|
+
* unchanged" as "short and plain enough to be a typo," not as proof the
|
|
27
|
+
* value holds no secret. Callers with a value that is never supposed to be
|
|
28
|
+
* secret-shaped in the first place (a service key, an admin key) should
|
|
29
|
+
* still never echo it at all, redacted or not — this helper is for slots
|
|
30
|
+
* that normally hold a plain identifier and occasionally, by mistake,
|
|
31
|
+
* don't.
|
|
32
|
+
*/
|
|
33
|
+
// Real hand-typed identifiers (wallet names, room keys, command names) top
|
|
34
|
+
// out well under this, and it comfortably clears a UUID (36 chars — the
|
|
35
|
+
// canonical shape of an org id, and *itself* a public, harmless-to-echo
|
|
36
|
+
// identifier even when it's the "wrong" one in a conflict, not a secret).
|
|
37
|
+
// Secrets that land in the wrong slot (private keys, API tokens, JWTs) are
|
|
38
|
+
// almost always well past it — the private key in #640 was 64-66 characters.
|
|
39
|
+
const MAX_SAFE_ECHO_LENGTH = 40;
|
|
40
|
+
// A contiguous hex run (with or without a `0x` prefix) reads as key
|
|
41
|
+
// material or a hash rather than a human-typed identifier, even when short
|
|
42
|
+
// enough to pass the length check above — the exact shape of #640.
|
|
43
|
+
const HEX_RUN_RE = /^(0x)?[0-9a-fA-F]{16,}$/;
|
|
44
|
+
function looksSecretShaped(str) {
|
|
45
|
+
return str.length > MAX_SAFE_ECHO_LENGTH || HEX_RUN_RE.test(str);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Return `value` unchanged when it is short and plain enough to be a
|
|
49
|
+
* harmless typo; otherwise return a shape-only placeholder (character count
|
|
50
|
+
* only — never a substring) that is still safe to embed in a message or a
|
|
51
|
+
* structured `details` field.
|
|
52
|
+
*
|
|
53
|
+
* Never throws. Coerces non-string input the same way template-literal
|
|
54
|
+
* interpolation would, so a caller can pass whatever it already has without
|
|
55
|
+
* a separate type check.
|
|
56
|
+
*/
|
|
57
|
+
export function describeRejectedValue(value) {
|
|
58
|
+
const str = typeof value === "string" ? value : String(value ?? "");
|
|
59
|
+
if (looksSecretShaped(str)) {
|
|
60
|
+
return `${str.length} chars, not shown — too long or hex-shaped to be a typo (may be a credential that landed in the wrong place)`;
|
|
61
|
+
}
|
|
62
|
+
return str;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,2EAA2E;AAC3E,wEAAwE;AACxE,wEAAwE;AACxE,0EAA0E;AAC1E,2EAA2E;AAC3E,6EAA6E;AAC7E,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,oEAAoE;AACpE,2EAA2E;AAC3E,mEAAmE;AACnE,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAE7C,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,GAAG,oBAAoB,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACpE,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,GAAG,GAAG,CAAC,MAAM,8GAA8G,CAAC;IACrI,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rooms-shared.d.ts","sourceRoot":"","sources":["../../src/tools/rooms-shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rooms-shared.d.ts","sourceRoot":"","sources":["../../src/tools/rooms-shared.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAChC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA6EjC,wBAAsB,eAAe,CACnC,IAAI,EAAE,eAAe,EACrB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAO,GACnD,OAAO,CAAC,iBAAiB,CAAC,CAmC5B;AAQD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAIvE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAOpG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAEvD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACvE,OAAO,CAAC,CAAC,CAAC,CAoBZ"}
|
|
@@ -18,6 +18,7 @@ import { getSdk } from "../sdk.js";
|
|
|
18
18
|
import { mapSdkError } from "../errors.js";
|
|
19
19
|
import { findBindingKey } from "../../core/dist/binding-file.js";
|
|
20
20
|
import { getActiveOrgId } from "../../core/dist/profile-state.js";
|
|
21
|
+
import { describeRejectedValue } from "../../core/dist/redact.js";
|
|
21
22
|
import { getSessionKey } from "../harness-context.js";
|
|
22
23
|
const ORG_ENV = "RUN402_ORG";
|
|
23
24
|
const ROOM_ENV = "RUN402_ROOM";
|
|
@@ -52,7 +53,11 @@ function resolveAmbientRoom(cwd, env) {
|
|
|
52
53
|
if (envRoom) {
|
|
53
54
|
const slash = envRoom.indexOf("/");
|
|
54
55
|
if (slash <= 0 || slash === envRoom.length - 1) {
|
|
55
|
-
|
|
56
|
+
// A malformed env value is a value we know nothing about — see
|
|
57
|
+
// core/dist/redact.js's doc comment (kychee-com/run402-private#640):
|
|
58
|
+
// it must not be echoed raw, since the same class of mistake that put
|
|
59
|
+
// a private key into RUN402_WALLET can put one into RUN402_ROOM.
|
|
60
|
+
return { ok: false, error: `${ROOM_ENV} must be "<org_id>/<room_key>" — got ${JSON.stringify(describeRejectedValue(envRoom))}.` };
|
|
56
61
|
}
|
|
57
62
|
return { ok: true, room: { orgId: envRoom.slice(0, slash), roomKey: envRoom.slice(slash + 1) } };
|
|
58
63
|
}
|
|
@@ -68,9 +73,14 @@ function resolveAmbientRoom(cwd, env) {
|
|
|
68
73
|
// worth stopping on — the CLI stops here too, and for the same reason. A
|
|
69
74
|
// binding outranking the PROFILE stays silent; that is what a binding is for.
|
|
70
75
|
if (envOrg && bindingOrg && envOrg !== bindingOrg.value) {
|
|
76
|
+
// envOrg is unvalidated here (this resolver does no org-id shape check —
|
|
77
|
+
// see the module doc comment on why it's a deliberately separate, minimal
|
|
78
|
+
// implementation), so it must be redacted the same way a rejected value
|
|
79
|
+
// would be. bindingOrg.value comes from a committed .run402.json, which
|
|
80
|
+
// by convention never holds a secret.
|
|
71
81
|
return {
|
|
72
82
|
ok: false,
|
|
73
|
-
error: `Ambiguous organization: ${ORG_ENV}=${envOrg} but ${bindingOrg.file} binds ${bindingOrg.value}. `
|
|
83
|
+
error: `Ambiguous organization: ${ORG_ENV}=${describeRejectedValue(envOrg)} but ${bindingOrg.file} binds ${bindingOrg.value}. `
|
|
74
84
|
+ "Pass org_id + room_key on this call, unset the variable, or edit the binding file.",
|
|
75
85
|
};
|
|
76
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rooms-shared.js","sourceRoot":"","sources":["../../src/tools/rooms-shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAiBtD,MAAM,OAAO,GAAG,YAAY,CAAC;AAC7B,MAAM,QAAQ,GAAG,aAAa,CAAC;AAE/B,MAAM,OAAO,GAAG,CAAC,CAAU,EAAiB,EAAE,CAC5C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAS,kBAAkB,CAAC,GAAW,EAAE,GAAsB;IAC7D,4EAA4E;IAC5E,4DAA4D;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvC,IAAI,OAAO,EAAE,CAAC;QACZ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AI,GAAmD,EAAE,IAAI,EAAE,IAAI;eACvE,GAAyB,EAAE,IAAI,CAAC;QACtC,IAAI,IAAI,KAAK,kBAAkB,IAAI,UAAU,EAAE,CAAC;YAC9C,cAAc,CAAC,IAAI,CAAC,CAAC;YACrB,MAAM,aAAa,GAAG,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/D,MAAM,WAAW,GAAG,MAAM,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE;gBAClF,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3C,UAAU;aACX,CAAC,CAAC;YACH,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run402-mcp",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.62.0",
|
|
4
4
|
"packageManager": "npm@11.19.0",
|
|
5
5
|
"mcpName": "com.run402/mcp",
|
|
6
6
|
"description": "MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.",
|
package/sdk/core-dist/config.js
CHANGED
|
@@ -2,6 +2,7 @@ import { homedir } from "node:os";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { existsSync, renameSync, mkdirSync, chmodSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
5
|
+
import { describeRejectedValue } from "./redact.js";
|
|
5
6
|
export const DEFAULT_API_BASE = "https://api.run402.com";
|
|
6
7
|
/**
|
|
7
8
|
* Validate a user-supplied API base URL. Throws a clear error message that
|
|
@@ -25,10 +26,10 @@ function validateApiBase(envVar, raw, fallback) {
|
|
|
25
26
|
u = new URL(raw);
|
|
26
27
|
}
|
|
27
28
|
catch {
|
|
28
|
-
throw new Error(`${envVar} is not a valid URL: ${JSON.stringify(raw)}. Expected an http(s) URL like https://api.run402.com.`);
|
|
29
|
+
throw new Error(`${envVar} is not a valid URL: ${JSON.stringify(describeRejectedValue(raw))}. Expected an http(s) URL like https://api.run402.com.`);
|
|
29
30
|
}
|
|
30
31
|
if (u.protocol !== "https:" && u.protocol !== "http:") {
|
|
31
|
-
throw new Error(`${envVar} must use http(s):, got ${u.protocol} (full value: ${JSON.stringify(raw)}).`);
|
|
32
|
+
throw new Error(`${envVar} must use http(s):, got ${u.protocol} (full value: ${JSON.stringify(describeRejectedValue(raw))}).`);
|
|
32
33
|
}
|
|
33
34
|
return raw;
|
|
34
35
|
}
|
|
@@ -81,7 +82,15 @@ function assertSafeProfileName(name) {
|
|
|
81
82
|
if (name === DEFAULT_PROFILE)
|
|
82
83
|
return;
|
|
83
84
|
if (!isValidProfileName(name)) {
|
|
84
|
-
|
|
85
|
+
// A value that failed this check is a value we know nothing about — the
|
|
86
|
+
// most likely mistake is a typo, but kychee-com/run402-private#640 was a
|
|
87
|
+
// Base-mainnet private key pasted into RUN402_WALLET (a NAME field), and
|
|
88
|
+
// the raw value used to be echoed straight into this message and
|
|
89
|
+
// wherever it propagated (terminal, logs, session transcripts).
|
|
90
|
+
// describeRejectedValue() shows short/plain values in full (useful for
|
|
91
|
+
// an actual typo) and redacts anything long or hex-shaped enough to be
|
|
92
|
+
// a secret instead of a name.
|
|
93
|
+
throw new Error(`Invalid wallet/profile name ${JSON.stringify(describeRejectedValue(name))}. ` +
|
|
85
94
|
"Names must match /^[a-z0-9][a-z0-9_-]{0,63}$/ (lowercase letters, digits, '_' and '-'). " +
|
|
86
95
|
"Check the RUN402_WALLET / RUN402_PROFILE env var.");
|
|
87
96
|
}
|
|
@@ -18,6 +18,7 @@ import { readFileSync, writeFileSync, mkdirSync, renameSync, chmodSync, existsSy
|
|
|
18
18
|
import { dirname, join } from "node:path";
|
|
19
19
|
import { randomBytes } from "node:crypto";
|
|
20
20
|
import { getConfigBaseDir, getProfilesDir, DEFAULT_PROFILE, isValidProfileName, } from "./config.js";
|
|
21
|
+
import { describeRejectedValue } from "./redact.js";
|
|
21
22
|
function atomicWrite(p, content, mode) {
|
|
22
23
|
const dir = dirname(p);
|
|
23
24
|
mkdirSync(dir, { recursive: true });
|
|
@@ -153,7 +154,10 @@ export function removeProfile(name) {
|
|
|
153
154
|
*/
|
|
154
155
|
export function renameProfile(oldName, newName) {
|
|
155
156
|
if (!isValidProfileName(newName)) {
|
|
156
|
-
|
|
157
|
+
// See describeRejectedValue()'s doc comment (kychee-com/run402-private#640):
|
|
158
|
+
// a rejected value may be a secret pasted into a name field, so it is
|
|
159
|
+
// never safe to echo verbatim here.
|
|
160
|
+
throw new Error(`Invalid wallet name ${JSON.stringify(describeRejectedValue(newName))}.`);
|
|
157
161
|
}
|
|
158
162
|
if (newName === oldName)
|
|
159
163
|
return;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe-echo policy for values that failed local (client-side) validation.
|
|
3
|
+
*
|
|
4
|
+
* A value rejected by a format/existence check is a value we know nothing
|
|
5
|
+
* about — the CLI has only established what it is NOT. The likeliest
|
|
6
|
+
* failure is an ordinary typo, but the second likeliest, demonstrated in
|
|
7
|
+
* practice, is a credential pasted into the wrong slot:
|
|
8
|
+
* kychee-com/run402-private#640 — a Base-mainnet private key holding real
|
|
9
|
+
* funds landed in `RUN402_WALLET` (which takes a wallet NAME, not a key),
|
|
10
|
+
* failed the name check, and was printed verbatim to a terminal, a log, and
|
|
11
|
+
* a session transcript.
|
|
12
|
+
*
|
|
13
|
+
* `describeRejectedValue` is the one place that decides what a rejected
|
|
14
|
+
* value is safe to show, so every call site — wallet names, org ids, room
|
|
15
|
+
* keys, unknown commands/subcommands, "not found" lookups — gets the same
|
|
16
|
+
* answer instead of each reinventing (or forgetting) the judgment call.
|
|
17
|
+
*
|
|
18
|
+
* Short, low-entropy values (ordinary typos) are returned unchanged — that
|
|
19
|
+
* is what makes the resulting error message useful. Long or
|
|
20
|
+
* high-entropy-looking values are replaced with a shape-only description
|
|
21
|
+
* (character count only), never a substring or prefix of the original:
|
|
22
|
+
* even a short prefix of a private key is more than a debugging aid needs
|
|
23
|
+
* and more than a leak should give up.
|
|
24
|
+
*
|
|
25
|
+
* This is a heuristic, not a content-aware secret scanner: treat "returned
|
|
26
|
+
* unchanged" as "short and plain enough to be a typo," not as proof the
|
|
27
|
+
* value holds no secret. Callers with a value that is never supposed to be
|
|
28
|
+
* secret-shaped in the first place (a service key, an admin key) should
|
|
29
|
+
* still never echo it at all, redacted or not — this helper is for slots
|
|
30
|
+
* that normally hold a plain identifier and occasionally, by mistake,
|
|
31
|
+
* don't.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Return `value` unchanged when it is short and plain enough to be a
|
|
35
|
+
* harmless typo; otherwise return a shape-only placeholder (character count
|
|
36
|
+
* only — never a substring) that is still safe to embed in a message or a
|
|
37
|
+
* structured `details` field.
|
|
38
|
+
*
|
|
39
|
+
* Never throws. Coerces non-string input the same way template-literal
|
|
40
|
+
* interpolation would, so a caller can pass whatever it already has without
|
|
41
|
+
* a separate type check.
|
|
42
|
+
*/
|
|
43
|
+
export declare function describeRejectedValue(value: unknown): string;
|
|
44
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe-echo policy for values that failed local (client-side) validation.
|
|
3
|
+
*
|
|
4
|
+
* A value rejected by a format/existence check is a value we know nothing
|
|
5
|
+
* about — the CLI has only established what it is NOT. The likeliest
|
|
6
|
+
* failure is an ordinary typo, but the second likeliest, demonstrated in
|
|
7
|
+
* practice, is a credential pasted into the wrong slot:
|
|
8
|
+
* kychee-com/run402-private#640 — a Base-mainnet private key holding real
|
|
9
|
+
* funds landed in `RUN402_WALLET` (which takes a wallet NAME, not a key),
|
|
10
|
+
* failed the name check, and was printed verbatim to a terminal, a log, and
|
|
11
|
+
* a session transcript.
|
|
12
|
+
*
|
|
13
|
+
* `describeRejectedValue` is the one place that decides what a rejected
|
|
14
|
+
* value is safe to show, so every call site — wallet names, org ids, room
|
|
15
|
+
* keys, unknown commands/subcommands, "not found" lookups — gets the same
|
|
16
|
+
* answer instead of each reinventing (or forgetting) the judgment call.
|
|
17
|
+
*
|
|
18
|
+
* Short, low-entropy values (ordinary typos) are returned unchanged — that
|
|
19
|
+
* is what makes the resulting error message useful. Long or
|
|
20
|
+
* high-entropy-looking values are replaced with a shape-only description
|
|
21
|
+
* (character count only), never a substring or prefix of the original:
|
|
22
|
+
* even a short prefix of a private key is more than a debugging aid needs
|
|
23
|
+
* and more than a leak should give up.
|
|
24
|
+
*
|
|
25
|
+
* This is a heuristic, not a content-aware secret scanner: treat "returned
|
|
26
|
+
* unchanged" as "short and plain enough to be a typo," not as proof the
|
|
27
|
+
* value holds no secret. Callers with a value that is never supposed to be
|
|
28
|
+
* secret-shaped in the first place (a service key, an admin key) should
|
|
29
|
+
* still never echo it at all, redacted or not — this helper is for slots
|
|
30
|
+
* that normally hold a plain identifier and occasionally, by mistake,
|
|
31
|
+
* don't.
|
|
32
|
+
*/
|
|
33
|
+
// Real hand-typed identifiers (wallet names, room keys, command names) top
|
|
34
|
+
// out well under this, and it comfortably clears a UUID (36 chars — the
|
|
35
|
+
// canonical shape of an org id, and *itself* a public, harmless-to-echo
|
|
36
|
+
// identifier even when it's the "wrong" one in a conflict, not a secret).
|
|
37
|
+
// Secrets that land in the wrong slot (private keys, API tokens, JWTs) are
|
|
38
|
+
// almost always well past it — the private key in #640 was 64-66 characters.
|
|
39
|
+
const MAX_SAFE_ECHO_LENGTH = 40;
|
|
40
|
+
// A contiguous hex run (with or without a `0x` prefix) reads as key
|
|
41
|
+
// material or a hash rather than a human-typed identifier, even when short
|
|
42
|
+
// enough to pass the length check above — the exact shape of #640.
|
|
43
|
+
const HEX_RUN_RE = /^(0x)?[0-9a-fA-F]{16,}$/;
|
|
44
|
+
function looksSecretShaped(str) {
|
|
45
|
+
return str.length > MAX_SAFE_ECHO_LENGTH || HEX_RUN_RE.test(str);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Return `value` unchanged when it is short and plain enough to be a
|
|
49
|
+
* harmless typo; otherwise return a shape-only placeholder (character count
|
|
50
|
+
* only — never a substring) that is still safe to embed in a message or a
|
|
51
|
+
* structured `details` field.
|
|
52
|
+
*
|
|
53
|
+
* Never throws. Coerces non-string input the same way template-literal
|
|
54
|
+
* interpolation would, so a caller can pass whatever it already has without
|
|
55
|
+
* a separate type check.
|
|
56
|
+
*/
|
|
57
|
+
export function describeRejectedValue(value) {
|
|
58
|
+
const str = typeof value === "string" ? value : String(value ?? "");
|
|
59
|
+
if (looksSecretShaped(str)) {
|
|
60
|
+
return `${str.length} chars, not shown — too long or hex-shaped to be a typo (may be a credential that landed in the wrong place)`;
|
|
61
|
+
}
|
|
62
|
+
return str;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
import type { Client } from "../kernel.js";
|
|
32
32
|
import { GITVAULT_DURABILITY_STATEMENT, GITVAULT_MIRROR_KEYSTORE_STILL_REQUIRED_STATEMENT, GITVAULT_MIRROR_VALIDITY_NOT_FRESHNESS_STATEMENT, GITVAULT_TERMINAL_LOSS_DOCTOR_TEXT, GITVAULT_TERMINAL_LOSS_STATEMENT } from "./gitvault.crypto.js";
|
|
33
33
|
import type { GitvaultCaptureReceipt, GitvaultHeadsListingPage, GitvaultHeadsListingRequest, GitvaultHeadTarget, GitvaultOpenReceipt, GitvaultRecipientConfirmationReceipt, GitvaultRecoveryReceipt, GitvaultRotationReason } from "./gitvault.types.js";
|
|
34
|
-
import type { GitvaultMaintenanceLease, GitvaultMaintenanceLeaseRequest, GitvaultTransport, GitvaultVaultRecord } from "../node/gitvault-publication.js";
|
|
34
|
+
import type { GitvaultCompactionGrant, GitvaultMaintenanceLease, GitvaultMaintenanceLeaseRequest, GitvaultTransport, GitvaultVaultRecord } from "../node/gitvault-publication.js";
|
|
35
35
|
import type { GitvaultDeployOptions, GitvaultDeployResult } from "../node/gitvault-deploy.js";
|
|
36
36
|
import type { GitvaultPublishResult, GitvaultRefMap, GitvaultReconcileEnvelopeRecipientsResult, GitvaultVerifiedState } from "../node/gitvault-publication.js";
|
|
37
37
|
import type { GitvaultCreationResult } from "../node/gitvault-creation-journal.js";
|
|
@@ -228,16 +228,29 @@ export interface GitvaultCompactResult {
|
|
|
228
228
|
export interface GitvaultCompactHeadroom {
|
|
229
229
|
/** Pooled storage the org is already using, across every project it owns. */
|
|
230
230
|
pool_used_bytes: number;
|
|
231
|
-
/** The org's pooled tier storage limit. */
|
|
231
|
+
/** The org's plain, unraised pooled tier storage limit — always the tier's own figure, never the grant-raised one, so a disclosed "used of X pooled" never implies the tier itself grew. */
|
|
232
232
|
pool_limit_bytes: number;
|
|
233
233
|
/** The vault's billed `source_bytes` — the checkpoint-size proxy (design D1). */
|
|
234
234
|
vault_source_bytes: number;
|
|
235
235
|
/** `pool_used_bytes + vault_source_bytes`. */
|
|
236
236
|
projected_transient_bytes: number;
|
|
237
|
-
/** `false` when the projection exceeds the limit. */
|
|
237
|
+
/** `false` when the projection exceeds the EFFECTIVE limit (`effective_pool_limit_bytes` when a grant is active, else `pool_limit_bytes`). */
|
|
238
238
|
ok: boolean;
|
|
239
239
|
/** `true` when the caller passed the override and a `false` `ok` was proceeded past anyway. */
|
|
240
240
|
overridden: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* gitvault-checkpoint-cadence design D3: `pool_limit_bytes` PLUS an active
|
|
243
|
+
* compaction grant's `granted_bytes`, when one is active for this cycle —
|
|
244
|
+
* the limit `ok`/`projected_transient_bytes` are actually computed
|
|
245
|
+
* against. Equal to `pool_limit_bytes` (and omittable) when no grant is
|
|
246
|
+
* active.
|
|
247
|
+
*/
|
|
248
|
+
effective_pool_limit_bytes?: number;
|
|
249
|
+
/** The grant this compaction opened for itself, when one was opened and is still tracked at disclosure time — `null`/absent otherwise (no grant, an older gateway, or one already closed). */
|
|
250
|
+
compaction_grant?: {
|
|
251
|
+
granted_bytes: number;
|
|
252
|
+
expires_at: string;
|
|
253
|
+
} | null;
|
|
241
254
|
}
|
|
242
255
|
/**
|
|
243
256
|
* `run402 gitvault snapshot --dry-run`'s report shape
|
|
@@ -1111,6 +1124,20 @@ export declare class Gitvault {
|
|
|
1111
1124
|
* figures cannot be read.
|
|
1112
1125
|
*/
|
|
1113
1126
|
compactHeadroom(options?: GitvaultVaultHandleOptions): Promise<GitvaultCompactHeadroom | null>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Open this vault's compaction headroom grant directly (gitvault-checkpoint-cadence
|
|
1129
|
+
* design D3) — `compact()` already does this internally; this standalone
|
|
1130
|
+
* entry point exists for callers that need to inspect or drive the grant
|
|
1131
|
+
* without also running a full compaction cycle (tests; a future
|
|
1132
|
+
* operator/diagnostic surface). Throws `GITVAULT_COMPACTION_GRANT_ACTIVE`
|
|
1133
|
+
* (409) verbatim when another compaction already holds this project's
|
|
1134
|
+
* grant.
|
|
1135
|
+
*/
|
|
1136
|
+
openCompactionGrant(options?: GitvaultVaultHandleOptions): Promise<GitvaultCompactionGrant>;
|
|
1137
|
+
/** Close this vault's compaction headroom grant directly — idempotent; `{closed: false}` when nothing was active. */
|
|
1138
|
+
closeCompactionGrant(options?: GitvaultVaultHandleOptions): Promise<{
|
|
1139
|
+
closed: boolean;
|
|
1140
|
+
}>;
|
|
1114
1141
|
/**
|
|
1115
1142
|
* Publish a checkpoint covering the canonical refs, every root unexpired at
|
|
1116
1143
|
* the cutoff, and the `HEAD` target — under a maintenance lease so a
|