@unson/brainbase-mcp 0.50.28 → 0.50.30
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/contracts/brainbase-public-contract.v1.json +1 -0
- package/dist/antigravity-judgment-hook.d.ts +191 -0
- package/dist/antigravity-judgment-hook.js +2042 -0
- package/dist/claude-code-judgment-hook.d.ts +23 -0
- package/dist/claude-code-judgment-hook.js +8 -5
- package/dist/cli.js +273 -6
- package/dist/graph-retrieval.d.ts +4 -0
- package/dist/graph-retrieval.js +4 -0
- package/dist/judgment-event-adapter.d.ts +37 -2
- package/dist/judgment-event-adapter.js +88 -3
- package/dist/judgment-event-outbox.d.ts +9 -1
- package/dist/judgment-event-outbox.js +45 -8
- package/dist/judgment-execution-outcome.d.ts +2 -1
- package/dist/judgment-execution-outcome.js +2 -1
- package/dist/judgment-frame.d.ts +26 -4
- package/dist/judgment-frame.js +190 -15
- package/dist/judgment-host.d.ts +30 -0
- package/dist/judgment-host.js +170 -22
- package/dist/judgment-model-outcome.d.ts +29 -1
- package/dist/judgment-model-outcome.js +69 -1
- package/dist/judgment-offline-binary-audit.d.ts +360 -0
- package/dist/judgment-offline-binary-audit.js +555 -0
- package/dist/judgment-project-binding.d.ts +1 -1
- package/dist/judgment-project-binding.js +2 -1
- package/dist/judgment-reasoning-audit.d.ts +115 -0
- package/dist/judgment-reasoning-audit.js +623 -0
- package/dist/judgment-reasoning-gate-prompt.d.ts +42 -0
- package/dist/judgment-reasoning-gate-prompt.js +83 -0
- package/dist/judgment-runtime-resolution.d.ts +2 -2
- package/dist/judgment-runtime-resolution.js +2 -2
- package/dist/judgment-runtime-resolution.public.d.ts +2 -2
- package/dist/judgment-session-world-model.d.ts +163 -0
- package/dist/judgment-session-world-model.js +408 -0
- package/dist/mcp-tool-schema-portability.d.ts +54 -0
- package/dist/mcp-tool-schema-portability.js +1013 -0
- package/dist/organization-graph.js +9 -1
- package/dist/remote-judgment-hook-http.d.ts +36 -3
- package/dist/remote-judgment-hook-http.js +94 -15
- package/package.json +14 -2
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { type AccessTokenOptions } from './brainbase-login.js';
|
|
2
|
+
import { type PersonToken } from './claude-code-judgment-hook.js';
|
|
3
|
+
export declare const ANTIGRAVITY_HOOK_CONFIG_SCHEMA = "brainbase-antigravity-judgment-hook-v1";
|
|
4
|
+
export declare const ANTIGRAVITY_HOOK_COMMAND = "judgment:antigravity-hook";
|
|
5
|
+
export declare const ANTIGRAVITY_HOOK_KEY = "brainbase-judgment";
|
|
6
|
+
export declare const DEFAULT_ANTIGRAVITY_TIMEOUTS_MS: {
|
|
7
|
+
readonly PreInvocation: 4000;
|
|
8
|
+
readonly PreToolUse: 2500;
|
|
9
|
+
readonly PostToolUse: 2500;
|
|
10
|
+
readonly Stop: 5000;
|
|
11
|
+
};
|
|
12
|
+
export interface AntigravityHookTimeoutsMs {
|
|
13
|
+
PreInvocation?: number;
|
|
14
|
+
PreToolUse?: number;
|
|
15
|
+
PostToolUse?: number;
|
|
16
|
+
Stop?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface AntigravityHookConfig {
|
|
19
|
+
schema_version: typeof ANTIGRAVITY_HOOK_CONFIG_SCHEMA;
|
|
20
|
+
/** Base URL of the hosted MCP serving `host/judgment/hook` (path prefix such as `/runtime-mcp` is preserved). */
|
|
21
|
+
origin: string;
|
|
22
|
+
/** Optional explicit hook endpoint URL (overrides `origin` + `host/judgment/hook`). */
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
/** Origin of the Brainbase API the person logged in to via `brainbase login`. */
|
|
25
|
+
login_server: string;
|
|
26
|
+
/** Sent as `x-brainbase-project-code`. Required for non-git workspaces. */
|
|
27
|
+
project_code?: string;
|
|
28
|
+
/** Allow auditing non-git directories when `project_code` is configured. */
|
|
29
|
+
allow_non_git?: boolean;
|
|
30
|
+
/** Optional canonical directory prefixes allowed for auditing (canary & scope control). */
|
|
31
|
+
cwd_prefixes?: string[];
|
|
32
|
+
/** Optional audited repositories allowlist (`host/owner/name`). */
|
|
33
|
+
repositories?: string[];
|
|
34
|
+
/** Registration identity tying this config to one Antigravity `hooks.json` entry. */
|
|
35
|
+
registration: {
|
|
36
|
+
id: string;
|
|
37
|
+
settings: string;
|
|
38
|
+
};
|
|
39
|
+
/** Optional per-event HTTP timeout overrides in milliseconds. */
|
|
40
|
+
timeouts_ms?: AntigravityHookTimeoutsMs;
|
|
41
|
+
}
|
|
42
|
+
export type AntigravityHookPayload = Record<string, unknown>;
|
|
43
|
+
export type AntigravityHookOutput = Record<string, unknown>;
|
|
44
|
+
export interface AntigravityHookOptions {
|
|
45
|
+
env?: NodeJS.ProcessEnv;
|
|
46
|
+
fetch?: typeof fetch;
|
|
47
|
+
/** Overrides how the person token is obtained (tests). */
|
|
48
|
+
accessToken?: () => Promise<string | PersonToken>;
|
|
49
|
+
credentials?: AccessTokenOptions;
|
|
50
|
+
/** The hook config file; the installer passes it as `--config`. */
|
|
51
|
+
configPath?: string;
|
|
52
|
+
/** The registration id the installer put in the command as `--registration`. */
|
|
53
|
+
registrationId?: string;
|
|
54
|
+
/** Clock override for stale-turn crash recovery tests. */
|
|
55
|
+
now?: () => number;
|
|
56
|
+
/** Stale active turn threshold in ms (default 30 minutes). */
|
|
57
|
+
staleTurnMs?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Explicit allowed transcript root directories (primarily for tests).
|
|
60
|
+
* When omitted, defaults to Antigravity / Gemini conversation brain directories
|
|
61
|
+
* (or `BRAINBASE_ANTIGRAVITY_TRANSCRIPT_ROOTS`).
|
|
62
|
+
*/
|
|
63
|
+
allowedTranscriptRoots?: readonly string[];
|
|
64
|
+
/** Optional OS turn-state lock overrides (primarily for tests). */
|
|
65
|
+
turnLock?: TurnStateLockOptions;
|
|
66
|
+
/** Optional Linux `openat2` helper executable override for transcript reads (strictly for tests). */
|
|
67
|
+
transcriptOpenatBinary?: string;
|
|
68
|
+
/** Optional runtime platform override (strictly for tests). */
|
|
69
|
+
platform?: NodeJS.Platform;
|
|
70
|
+
}
|
|
71
|
+
export interface TranscriptReadOptions {
|
|
72
|
+
conversationId: string;
|
|
73
|
+
allowedTranscriptRoots?: readonly string[];
|
|
74
|
+
env?: NodeJS.ProcessEnv;
|
|
75
|
+
/** Override for the Linux `openat2` helper executable path (strictly for tests). */
|
|
76
|
+
openatHelperBinary?: string;
|
|
77
|
+
/** Override runtime platform check (strictly for tests). */
|
|
78
|
+
platform?: NodeJS.Platform;
|
|
79
|
+
}
|
|
80
|
+
export declare function defaultAntigravityHookConfigPath(env?: NodeJS.ProcessEnv): string;
|
|
81
|
+
export declare function defaultAntigravityHooksJsonPath(env?: NodeJS.ProcessEnv): string;
|
|
82
|
+
/** Fail-open stdout contract per Antigravity lifecycle event. */
|
|
83
|
+
export declare function antigravityFailOpenOutput(eventName: unknown): AntigravityHookOutput;
|
|
84
|
+
/**
|
|
85
|
+
* Validates and normalizes a hosted MCP base URL while preserving its path
|
|
86
|
+
* prefix (e.g. `https://bb.unson.jp/runtime-mcp`).
|
|
87
|
+
*/
|
|
88
|
+
export declare function normalizeAntigravityHookBaseUrl(value: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Resolves the concrete judgment hook endpoint URL without dropping base URL
|
|
91
|
+
* path prefixes such as `/runtime-mcp`.
|
|
92
|
+
*/
|
|
93
|
+
export declare function resolveAntigravityHookEndpoint(config: Pick<AntigravityHookConfig, 'origin' | 'endpoint'>): URL;
|
|
94
|
+
export declare function readAntigravityHookConfig(path: string): AntigravityHookConfig | null;
|
|
95
|
+
/** Parses an Antigravity hook config from JSON text, or null if unusable. */
|
|
96
|
+
export declare function parseAntigravityHookConfig(text: string): AntigravityHookConfig | null;
|
|
97
|
+
export declare function isAntigravityHookConfigFile(path: string): boolean;
|
|
98
|
+
export declare function isAntigravityHookConfigText(text: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Normalizes Antigravity MCP tool names to the canonical Brainbase Host format
|
|
101
|
+
* (`mcp__brainbase__<tool>`):
|
|
102
|
+
* - `mcp_brainbase_<tool>` or `mcp_brainbase-<suffix>_<tool>` -> `mcp__brainbase__<tool>`
|
|
103
|
+
* - `call_mcp_tool` with `ServerName` matching `^brainbase(?:-.+)?$` -> `mcp__brainbase__<ToolName>`
|
|
104
|
+
*/
|
|
105
|
+
export declare function normalizeAntigravityToolName(name: string, args?: unknown): string;
|
|
106
|
+
interface TranscriptEntry {
|
|
107
|
+
step_index?: unknown;
|
|
108
|
+
source?: unknown;
|
|
109
|
+
type?: unknown;
|
|
110
|
+
content?: unknown;
|
|
111
|
+
}
|
|
112
|
+
interface TranscriptOpenatTestFaults {
|
|
113
|
+
/** Force Linux openat2(2) to fail with the specified errno to verify immediate fail-closed rejection (no fallback). */
|
|
114
|
+
forceOpenat2Errno?: 'ENOSYS' | 'EPERM';
|
|
115
|
+
/** Rename a path inside the helper right after reading tail bytes from file_fd. */
|
|
116
|
+
renameAfterTailRead?: {
|
|
117
|
+
from: string;
|
|
118
|
+
to: string;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
interface TranscriptOpenTestHooks {
|
|
122
|
+
onBeforeOpen?: (canonicalPath: string) => void;
|
|
123
|
+
/** Override for the Linux `openat2` helper executable path (strictly for tests). */
|
|
124
|
+
openatHelperBinary?: string;
|
|
125
|
+
/** Override fixed absolute candidate binaries searched when no explicit binary override is set (strictly for tests). */
|
|
126
|
+
openatHelperCandidates?: readonly string[];
|
|
127
|
+
/** Override timeout in ms for the Linux `openat2` helper (strictly for tests). */
|
|
128
|
+
helperTimeoutMs?: number;
|
|
129
|
+
/** Override platform check to test non-Linux fail-closed behavior. */
|
|
130
|
+
platform?: NodeJS.Platform;
|
|
131
|
+
/** Deterministic fault injection inside the openat2 helper (strictly for tests). */
|
|
132
|
+
openatTestFaults?: TranscriptOpenatTestFaults;
|
|
133
|
+
}
|
|
134
|
+
declare function resolveOpenatHelperBinary(override?: string, platform?: NodeJS.Platform, candidates?: readonly string[]): string | null;
|
|
135
|
+
declare function readTranscriptTailEntries(transcriptPath: unknown, options?: TranscriptReadOptions, testHooks?: TranscriptOpenTestHooks): TranscriptEntry[];
|
|
136
|
+
/**
|
|
137
|
+
* Identifies system-injected USER_INPUT messages (e.g. Reason Network hooks)
|
|
138
|
+
* so they never masquerade as a fresh human prompt or trigger duplicate turns.
|
|
139
|
+
*/
|
|
140
|
+
export declare function isSystemInjectedUserInput(text: string, source?: unknown): boolean;
|
|
141
|
+
export declare function extractLatestNonSystemUserInput(transcriptPath: unknown, options?: TranscriptReadOptions): {
|
|
142
|
+
stepIndex: number | null;
|
|
143
|
+
content: string;
|
|
144
|
+
} | null;
|
|
145
|
+
export declare function extractLastAssistantMessage(transcriptPath: unknown, options?: TranscriptReadOptions): string | undefined;
|
|
146
|
+
export declare function extractToolResultFromTranscript(transcriptPath: unknown, stepIdx: unknown, options?: TranscriptReadOptions): string | null;
|
|
147
|
+
declare function turnKey(conversationId: string, configPath: string): string;
|
|
148
|
+
declare function statePath(env: NodeJS.ProcessEnv, key: string): string;
|
|
149
|
+
declare function lockPathFor(env: NodeJS.ProcessEnv, key: string): string;
|
|
150
|
+
export interface TurnStateLockOptions {
|
|
151
|
+
timeoutMs?: number;
|
|
152
|
+
/** Override for the `flock` executable path (strictly for tests). */
|
|
153
|
+
flockBinary?: string;
|
|
154
|
+
}
|
|
155
|
+
declare function withTurnStateLock<T>(env: NodeJS.ProcessEnv, key: string, fn: () => T | Promise<T>, options?: TurnStateLockOptions): Promise<T>;
|
|
156
|
+
/** Namespaces session and turn IDs per registration, matching Claude Code isolation. */
|
|
157
|
+
export declare function antigravityNamespacedId(id: string, config: Pick<AntigravityHookConfig, 'registration'>): string;
|
|
158
|
+
/** Handles one Antigravity lifecycle hook event. Never throws. */
|
|
159
|
+
export declare function handleAntigravityJudgmentHook(payload: AntigravityHookPayload, options?: AntigravityHookOptions): Promise<AntigravityHookOutput>;
|
|
160
|
+
/** Builds the POSIX-quoted command registered in Antigravity `hooks.json`. */
|
|
161
|
+
export declare function antigravityHookCommand(nodePath: string, cliPath: string, configPath: string, registrationId: string): string;
|
|
162
|
+
export declare function installedAntigravityHookRegistration(hook: unknown): {
|
|
163
|
+
configPath: string;
|
|
164
|
+
registrationId: string;
|
|
165
|
+
} | null;
|
|
166
|
+
/** True when `hooksJson` contains a Brainbase Antigravity registration for `configPath`. */
|
|
167
|
+
export declare function hasInstalledAntigravityHooks(hooksJson: Record<string, unknown>, configPath: string): boolean;
|
|
168
|
+
/** Generates the `"brainbase-judgment"` hook block for Antigravity `hooks.json`. */
|
|
169
|
+
export declare function antigravityJudgmentHookEntry(command: string): Record<string, unknown>;
|
|
170
|
+
/**
|
|
171
|
+
* Idempotently updates or removes only the `"brainbase-judgment"` top-level key
|
|
172
|
+
* of Antigravity `hooks.json`, preserving every other hook entry untouched.
|
|
173
|
+
*/
|
|
174
|
+
export declare function registerAntigravityJudgmentHooks(hooksJson: Record<string, unknown>, options: {
|
|
175
|
+
command?: string;
|
|
176
|
+
configPath: string;
|
|
177
|
+
registrationId?: string;
|
|
178
|
+
remove?: boolean;
|
|
179
|
+
removedIds?: Set<string>;
|
|
180
|
+
}): Record<string, unknown>;
|
|
181
|
+
/** @internal Exposed strictly for deterministic concurrency and TOCTOU regression tests. */
|
|
182
|
+
export declare const __antigravityHookTestInternals: {
|
|
183
|
+
withTurnStateLock: typeof withTurnStateLock;
|
|
184
|
+
readTranscriptTailEntries: typeof readTranscriptTailEntries;
|
|
185
|
+
resolveOpenatHelperBinary: typeof resolveOpenatHelperBinary;
|
|
186
|
+
PYTHON_OPENAT_TAIL_READER: string;
|
|
187
|
+
turnKey: typeof turnKey;
|
|
188
|
+
lockPathFor: typeof lockPathFor;
|
|
189
|
+
statePath: typeof statePath;
|
|
190
|
+
};
|
|
191
|
+
export {};
|