@unson/brainbase-mcp 0.50.29 → 0.50.31
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/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 +10 -2
- package/ui/README.md +31 -0
- package/ui/graph-own-share.js +106 -50
- package/ui/graph-projects-view.js +4 -4
- package/ui/graph-view-shared.css +3 -0
- package/ui/workspace-kit.css +141 -0
- package/ui/workspace-kit.js +50 -1
- package/ui/world/world-view.js +1 -1
|
@@ -29,6 +29,22 @@ function isInternalJudgmentControlTool(payload) {
|
|
|
29
29
|
'mcp__brainbase__brainbase_judgment_audit_read',
|
|
30
30
|
'mcp__brainbase__brainbase_judgment_repair_read'].includes(toolName);
|
|
31
31
|
}
|
|
32
|
+
function invokeFailOpenObserver(observer, details) {
|
|
33
|
+
if (!observer)
|
|
34
|
+
return;
|
|
35
|
+
try {
|
|
36
|
+
const result = observer(details);
|
|
37
|
+
if (result !== null && (typeof result === 'object' || typeof result === 'function')
|
|
38
|
+
&& typeof result.then === 'function') {
|
|
39
|
+
Promise.resolve(result).catch(() => {
|
|
40
|
+
/* Fail-open observer cannot affect the hook response or emit unhandled rejections. */
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
/* Fail-open observer cannot affect the hook response. */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
32
48
|
function safeCauseReasonCode(error) {
|
|
33
49
|
let current = typeof error === 'object' && error && 'cause' in error ? error.cause : undefined;
|
|
34
50
|
const visited = new Set();
|
|
@@ -40,6 +56,27 @@ function safeCauseReasonCode(error) {
|
|
|
40
56
|
}
|
|
41
57
|
return undefined;
|
|
42
58
|
}
|
|
59
|
+
const REPOSITORY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/;
|
|
60
|
+
async function resolveHostedProjectCode(request, principal) {
|
|
61
|
+
const repository = request.repository?.trim();
|
|
62
|
+
if (repository && REPOSITORY_PATTERN.test(repository) && request.resolveProjectCode) {
|
|
63
|
+
let mapped;
|
|
64
|
+
try {
|
|
65
|
+
mapped = await request.resolveProjectCode({ repository, principal });
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// A failed lookup is not "no mapping": the repository may belong to a
|
|
69
|
+
// project outside the person's scope. Record nothing; the caller retries.
|
|
70
|
+
return { kind: 'lookup_failed' };
|
|
71
|
+
}
|
|
72
|
+
if (typeof mapped === 'string' && mapped)
|
|
73
|
+
return { kind: 'resolved', projectCode: mapped };
|
|
74
|
+
}
|
|
75
|
+
const projects = [...new Set(principal.projectCodes)];
|
|
76
|
+
return projects.length === 1
|
|
77
|
+
? { kind: 'resolved', projectCode: projects[0] }
|
|
78
|
+
: { kind: 'unresolved' };
|
|
79
|
+
}
|
|
43
80
|
export async function handleRemoteJudgmentHookRequest(request) {
|
|
44
81
|
if (request.method !== 'POST' || request.url !== REMOTE_JUDGMENT_HOOK_PATH)
|
|
45
82
|
return null;
|
|
@@ -70,28 +107,51 @@ export async function handleRemoteJudgmentHookRequest(request) {
|
|
|
70
107
|
}
|
|
71
108
|
const personHostedClaudeCode = request.personHostedClaudeCodeAllowed === true
|
|
72
109
|
&& request.trustedAuthKind === 'brainbase-jwt';
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
110
|
+
let host;
|
|
111
|
+
if (request.declaredHost === undefined || request.declaredHost === '') {
|
|
112
|
+
host = 'remote';
|
|
113
|
+
}
|
|
114
|
+
else if (request.declaredHost === 'claude-code' || request.declaredHost === 'antigravity') {
|
|
115
|
+
host = request.declaredHost;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return { status: 400, body: { error: 'judgment_hook_host_unsupported' } };
|
|
119
|
+
}
|
|
120
|
+
const isInteractiveHost = host === 'claude-code' || host === 'antigravity';
|
|
121
|
+
if (isInteractiveHost && (request.localClaudeCodeAllowed !== true && !personHostedClaudeCode)) {
|
|
77
122
|
return { status: 400, body: { error: 'judgment_hook_host_unsupported' } };
|
|
78
123
|
}
|
|
79
124
|
if (host === 'remote' && !SUPPORTED_HOOK_EVENTS.has(eventName)) {
|
|
80
125
|
return { status: 400, body: { error: 'unsupported_hook_event' } };
|
|
81
126
|
}
|
|
82
|
-
// A local
|
|
127
|
+
// A local interactive turn may leave the project to the Host, which derives
|
|
83
128
|
// it from the turn's cwd exactly as for Codex.
|
|
84
|
-
const requiresProjectScope = host === 'remote' || (
|
|
85
|
-
if (
|
|
129
|
+
const requiresProjectScope = host === 'remote' || (isInteractiveHost && personHostedClaudeCode);
|
|
130
|
+
if (isInteractiveHost && personHostedClaudeCode
|
|
86
131
|
&& !request.trustedPrincipal?.tenantId?.trim()) {
|
|
87
132
|
return { status: 403, body: { error: 'authenticated_history_principal_unavailable' } };
|
|
88
133
|
}
|
|
89
|
-
|
|
90
|
-
|
|
134
|
+
let projectCode = request.projectCode;
|
|
135
|
+
if (isInteractiveHost && personHostedClaudeCode && request.trustedPrincipal
|
|
136
|
+
&& (projectCode === undefined || projectCode === '')) {
|
|
137
|
+
// A person's Claude Code need not name the project. The Host decides it:
|
|
138
|
+
// its own repository mapping first, then the person's only project. When
|
|
139
|
+
// neither decides, nothing is recorded and the caller is told why.
|
|
140
|
+
const resolution = await resolveHostedProjectCode(request, request.trustedPrincipal);
|
|
141
|
+
if (resolution.kind === 'lookup_failed') {
|
|
142
|
+
return { status: 503, body: { error: 'judgment_project_lookup_failed' } };
|
|
143
|
+
}
|
|
144
|
+
if (resolution.kind === 'unresolved') {
|
|
145
|
+
return { status: 400, body: { error: 'judgment_project_unresolved' } };
|
|
146
|
+
}
|
|
147
|
+
projectCode = resolution.projectCode;
|
|
148
|
+
}
|
|
149
|
+
if ((requiresProjectScope || projectCode !== undefined)
|
|
150
|
+
&& (!projectCode || !PROJECT_CODE_PATTERN.test(projectCode))) {
|
|
91
151
|
return { status: 400, body: { error: 'invalid_project_code' } };
|
|
92
152
|
}
|
|
93
153
|
if (requiresProjectScope && request.trustedPrincipal
|
|
94
|
-
&& (!
|
|
154
|
+
&& (!projectCode || !request.trustedPrincipal.projectCodes.includes(projectCode))) {
|
|
95
155
|
return { status: 403, body: { error: 'project_not_authorized' } };
|
|
96
156
|
}
|
|
97
157
|
if (request.trustedPrincipal && !request.trustedPrincipal.tenantId?.trim()) {
|
|
@@ -112,13 +172,32 @@ export async function handleRemoteJudgmentHookRequest(request) {
|
|
|
112
172
|
...(request.companyAuthorityResponse
|
|
113
173
|
? { companyAuthorityResponse: request.companyAuthorityResponse }
|
|
114
174
|
: {}),
|
|
175
|
+
...(request.sessionWorldModelUpdater
|
|
176
|
+
? { sessionWorldModelUpdater: request.sessionWorldModelUpdater }
|
|
177
|
+
: {}),
|
|
115
178
|
}
|
|
116
|
-
: {
|
|
117
|
-
|
|
179
|
+
: {
|
|
180
|
+
host,
|
|
181
|
+
...(request.sessionWorldModelUpdater
|
|
182
|
+
? { sessionWorldModelUpdater: request.sessionWorldModelUpdater }
|
|
183
|
+
: {}),
|
|
184
|
+
};
|
|
185
|
+
const dispatchResult = await request.dispatch(hookPayload, projectCode, dispatchOptions);
|
|
118
186
|
const { output } = dispatchResult;
|
|
119
187
|
if (!output || typeof output !== 'object' || Array.isArray(output)) {
|
|
120
188
|
return { status: 503, body: { error: 'judgment_hook_output_invalid' } };
|
|
121
189
|
}
|
|
190
|
+
if (typeof dispatchResult.reasoningGateApplied === 'boolean'
|
|
191
|
+
&& dispatchResult.reasoningGateMode !== undefined) {
|
|
192
|
+
invokeFailOpenObserver(request.onReasoningGateTelemetry, {
|
|
193
|
+
eventName,
|
|
194
|
+
sessionId,
|
|
195
|
+
turnId,
|
|
196
|
+
...(projectCode ? { projectCode } : {}),
|
|
197
|
+
reasoning_gate_applied: dispatchResult.reasoningGateApplied,
|
|
198
|
+
reasoning_gate_mode: dispatchResult.reasoningGateMode,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
122
201
|
// The remote runtime's stream validator needs an audit line per tool. A
|
|
123
202
|
// local Claude Code turn has no such validator; the Host decides alone.
|
|
124
203
|
if (host === 'remote' && (eventName === 'PostToolUse' || eventName === 'PostToolUseFailure')
|
|
@@ -132,7 +211,7 @@ export async function handleRemoteJudgmentHookRequest(request) {
|
|
|
132
211
|
|| !/^[a-f0-9]{64}$/.test(dispatchResult.routeResolutionSha256))) {
|
|
133
212
|
return { status: 503, body: { error: 'judgment_hook_route_receipt_missing' } };
|
|
134
213
|
}
|
|
135
|
-
if (eventName === 'Stop' &&
|
|
214
|
+
if (eventName === 'Stop' && isInteractiveHost && personHostedClaudeCode
|
|
136
215
|
&& request.localClaudeCodeAllowed !== true) {
|
|
137
216
|
const report = (reason) => {
|
|
138
217
|
try {
|
|
@@ -149,7 +228,7 @@ export async function handleRemoteJudgmentHookRequest(request) {
|
|
|
149
228
|
try {
|
|
150
229
|
await Promise.race([
|
|
151
230
|
Promise.resolve().then(() => request.journalTurnPublisher({
|
|
152
|
-
sessionId, turnId, projectCode:
|
|
231
|
+
sessionId, turnId, projectCode: projectCode, trustedToken: request.trustedToken,
|
|
153
232
|
trustedPrincipal: { personId: request.trustedPrincipal.personId, tenantId: request.trustedPrincipal.tenantId },
|
|
154
233
|
})),
|
|
155
234
|
new Promise((_resolve, reject) => {
|
|
@@ -194,7 +273,7 @@ export async function handleRemoteJudgmentHookRequest(request) {
|
|
|
194
273
|
? error.code
|
|
195
274
|
: undefined;
|
|
196
275
|
const causeReasonCode = safeCauseReasonCode(error);
|
|
197
|
-
request.onDispatchError
|
|
276
|
+
invokeFailOpenObserver(request.onDispatchError, {
|
|
198
277
|
eventName,
|
|
199
278
|
reason,
|
|
200
279
|
errorName: error instanceof Error ? error.name : 'UnknownError',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unson/brainbase-mcp",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.31",
|
|
4
4
|
"description": "Local-first Brainbase judgment OS that lets supported AI agents reuse a user's approved goals, priorities, decisions, and judgment criteria.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"types": "./dist/judgment-frame.d.ts",
|
|
40
40
|
"import": "./dist/judgment-frame.js"
|
|
41
41
|
},
|
|
42
|
+
"./judgment-reasoning-audit": {
|
|
43
|
+
"types": "./dist/judgment-reasoning-audit.d.ts",
|
|
44
|
+
"import": "./dist/judgment-reasoning-audit.js"
|
|
45
|
+
},
|
|
42
46
|
"./judgment-history": {
|
|
43
47
|
"types": "./dist/judgment-history.d.ts",
|
|
44
48
|
"import": "./dist/judgment-history.js"
|
|
@@ -179,6 +183,10 @@
|
|
|
179
183
|
"types": "./dist/claude-code-judgment-hook.d.ts",
|
|
180
184
|
"import": "./dist/claude-code-judgment-hook.js"
|
|
181
185
|
},
|
|
186
|
+
"./antigravity-judgment-hook": {
|
|
187
|
+
"types": "./dist/antigravity-judgment-hook.d.ts",
|
|
188
|
+
"import": "./dist/antigravity-judgment-hook.js"
|
|
189
|
+
},
|
|
182
190
|
"./company-os-evaluation": {
|
|
183
191
|
"types": "./dist/company-os-evaluation.d.ts",
|
|
184
192
|
"import": "./dist/company-os-evaluation.js"
|
|
@@ -673,5 +681,5 @@
|
|
|
673
681
|
"url": "https://github.com/Unson-LLC/brainbase/issues"
|
|
674
682
|
},
|
|
675
683
|
"homepage": "https://github.com/Unson-LLC/brainbase#readme",
|
|
676
|
-
"gitHead": "
|
|
684
|
+
"gitHead": "6b864deb46fbb8ac8105f1f4e1f870afaf3e1264"
|
|
677
685
|
}
|
package/ui/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Shared browser UI
|
|
2
|
+
|
|
3
|
+
The browser modules in this directory accept a document, DOM roots and host
|
|
4
|
+
callbacks. Load `brainbase-tokens.css`, `workspace-kit.css` and the feature's
|
|
5
|
+
stylesheet. The host owns authorization, navigation and persistence. See the
|
|
6
|
+
[common UI specification](../docs/specs/oss-common-ui-spec.md) for component
|
|
7
|
+
appearance, accessibility and compatibility contracts.
|
|
8
|
+
|
|
9
|
+
## Imported records
|
|
10
|
+
|
|
11
|
+
`createOwnShareView` from `@unson/brainbase-mcp/ui/graph-own-share` uses the
|
|
12
|
+
existing read-only snapshot routes. By default it renders its searchable list
|
|
13
|
+
and inline selected-record details. A host that already renders the same list
|
|
14
|
+
can explicitly select `presentation: 'details-only'` and consume `onState` or
|
|
15
|
+
`controller.state.search` for the original results and completeness information.
|
|
16
|
+
|
|
17
|
+
Open a record with
|
|
18
|
+
`controller.openEntity(id, { opener, expectedHandover: { graphId, digest } })`.
|
|
19
|
+
Use the snapshot identity from the row that was activated. The shared drawer
|
|
20
|
+
checks the response identity and preserves record details, judgment rationale
|
|
21
|
+
and relation navigation. `opener` accepts a Node or a function returning the
|
|
22
|
+
current trigger. Call `controller.destroy()` when leaving the host view; late
|
|
23
|
+
responses cannot revive the drawer. This presentation does not add candidate
|
|
24
|
+
search, writes, or an organization mapping model to the shared UI.
|
|
25
|
+
|
|
26
|
+
`workspaceStepBand` and `workspaceCandidateChoices` from
|
|
27
|
+
`@unson/brainbase-mcp/ui/workspace-kit` display supplied steps and candidate
|
|
28
|
+
choices. They return DOM nodes with an `update(value)` method. Candidate choices
|
|
29
|
+
also accept `update(value, { disabled })`. Their callbacks report intent; hosts
|
|
30
|
+
confirm a choice and update the controlled display. Completion, legal candidates,
|
|
31
|
+
counts and permissions are never inferred by these components.
|