@unson/brainbase-mcp 0.50.9 → 0.50.11

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.
@@ -88,6 +88,12 @@
88
88
  "event"
89
89
  ]
90
90
  },
91
+ {
92
+ "name": "personal_knowledge_reject",
93
+ "requiredInput": [
94
+ "event_id"
95
+ ]
96
+ },
91
97
  {
92
98
  "name": "personal_knowledge_search",
93
99
  "requiredInput": [
@@ -122,6 +128,7 @@
122
128
  "toolNames": [
123
129
  "personal_knowledge_context",
124
130
  "personal_knowledge_register",
131
+ "personal_knowledge_reject",
125
132
  "personal_knowledge_search"
126
133
  ]
127
134
  },
@@ -1,4 +1,4 @@
1
- /** The context header used by the v1 register and search contracts. */
1
+ /** The context header used by the v1 register, search, and reject contracts. */
2
2
  export declare const PERSONAL_KNOWLEDGE_CONTEXT_HEADER = "X-Brainbase-Personal-Context";
3
3
  export declare const PERSONAL_KNOWLEDGE_CONTEXT_VERSION_HEADER = "X-Brainbase-Personal-Context-Version";
4
4
  /** Short alias retained for consumers that call this a personal context header. */
@@ -126,6 +126,11 @@ export declare class PersonalKnowledgeClient {
126
126
  getContext(): Promise<PersonalKnowledgeContextEnvelope>;
127
127
  register(input: PersonalKnowledgeEventInput): Promise<PersonalKnowledgeRegisterEnvelope>;
128
128
  search(query: string, limit?: number): Promise<PersonalKnowledgeSearchEnvelope>;
129
+ reject(eventId: string): Promise<{
130
+ event_id: string;
131
+ action: 'reject';
132
+ semantic_state: 'retracted';
133
+ }>;
129
134
  private request;
130
135
  }
131
136
  export declare function createPersonalKnowledgeClient(options: PersonalKnowledgeClientOptions): PersonalKnowledgeClient;
@@ -4,7 +4,7 @@ import { hostname, userInfo } from 'node:os';
4
4
  import { chmod, open, mkdir, readFile, rename, rm, stat } from 'node:fs/promises';
5
5
  import { dirname, join } from 'node:path';
6
6
  import { resolveDataDir } from './paths.js';
7
- /** The context header used by the v1 register and search contracts. */
7
+ /** The context header used by the v1 register, search, and reject contracts. */
8
8
  export const PERSONAL_KNOWLEDGE_CONTEXT_HEADER = 'X-Brainbase-Personal-Context';
9
9
  export const PERSONAL_KNOWLEDGE_CONTEXT_VERSION_HEADER = 'X-Brainbase-Personal-Context-Version';
10
10
  /** Short alias retained for consumers that call this a personal context header. */
@@ -685,6 +685,23 @@ export class PersonalKnowledgeClient {
685
685
  });
686
686
  return assertSearchEnvelope(payload, this.expectedContext);
687
687
  }
688
+ async reject(eventId) {
689
+ if (typeof eventId !== 'string' || !eventId.trim()) {
690
+ throw new Error('Personal Knowledge rejection requires a non-empty event_id.');
691
+ }
692
+ const event_id = eventId.trim();
693
+ await this.getContext();
694
+ const receipt = await this.request('/api/personal-knowledge/feedback', {
695
+ method: 'POST',
696
+ body: { event_id, action: 'reject' },
697
+ expectedHeader: true
698
+ });
699
+ if (!isRecord(receipt) || receipt.event_id !== event_id || receipt.action !== 'reject'
700
+ || receipt.semantic_state !== 'retracted' || 'error' in receipt) {
701
+ throw new PersonalKnowledgeClientError('Personal Knowledge reject response schema is invalid.');
702
+ }
703
+ return { event_id, action: 'reject', semantic_state: 'retracted' };
704
+ }
688
705
  async request(path, options) {
689
706
  let token;
690
707
  try {
package/dist/server.d.ts CHANGED
@@ -195,6 +195,24 @@ export declare const toolDefinitions: readonly [{
195
195
  };
196
196
  };
197
197
  };
198
+ }, {
199
+ readonly name: "personal_knowledge_reject";
200
+ readonly description: "Retract an event through the authenticated Personal Knowledge API. Requires API storage; identity comes from trusted configuration. This is not physical deletion.";
201
+ readonly annotations: {
202
+ readonly readOnlyHint: false;
203
+ readonly destructiveHint: true;
204
+ };
205
+ readonly inputSchema: {
206
+ readonly type: "object";
207
+ readonly required: readonly ["event_id"];
208
+ readonly additionalProperties: false;
209
+ readonly properties: {
210
+ readonly event_id: {
211
+ readonly type: "string";
212
+ readonly minLength: 1;
213
+ };
214
+ };
215
+ };
198
216
  }, {
199
217
  readonly name: "personal_knowledge_search";
200
218
  readonly description: "Search the explicitly configured v1 personal knowledge context. The result includes the verified context and never falls back to another store.";
package/dist/server.js CHANGED
@@ -17,7 +17,7 @@ import { auditPersonalOsDirectory } from './ontology-ssot.js';
17
17
  import { getOntologyImpact, inferPersonalOs, portableOntology, resolveOntologyVersion } from './ontology.js';
18
18
  import { loadPersonalOs } from './ssot.js';
19
19
  import { getContext, listEntities, onboardingStatus, searchAll, searchPersonalKg } from './tools.js';
20
- import { createLocalPersonalKnowledgeStore, createPersonalKnowledgeClient, decodePersonalKnowledgeContextHeader, PERSONAL_KNOWLEDGE_CONTRACT_VERSION, validatePersonalKnowledgeContext } from './personal-knowledge.js';
20
+ import { createLocalPersonalKnowledgeStore, createPersonalKnowledgeClient, decodePersonalKnowledgeContextHeader, PERSONAL_KNOWLEDGE_CONTRACT_VERSION, validatePersonalKnowledgeContext, PersonalKnowledgeClient } from './personal-knowledge.js';
21
21
  const argsSchema = z.object({
22
22
  dataDir: z.string().optional(),
23
23
  query: z.string().optional(),
@@ -54,6 +54,7 @@ const personalKnowledgeEventSchema = z.object({
54
54
  tags: z.array(z.string().min(1)).optional(),
55
55
  metadata: z.record(z.string(), z.unknown()).optional()
56
56
  }).strict();
57
+ const personalKnowledgeRejectSchema = z.object({ event_id: z.string().trim().min(1) }).strict();
57
58
  const personalKnowledgeContextSchema = z.object({}).strict();
58
59
  const personalKnowledgeRegisterSchema = z.object({ event: personalKnowledgeEventSchema }).strict();
59
60
  const personalKnowledgeSearchSchema = z.object({
@@ -254,6 +255,17 @@ export const toolDefinitions = [
254
255
  }
255
256
  }
256
257
  },
258
+ {
259
+ name: 'personal_knowledge_reject',
260
+ description: 'Retract an event through the authenticated Personal Knowledge API. Requires API storage; identity comes from trusted configuration. This is not physical deletion.',
261
+ annotations: { readOnlyHint: false, destructiveHint: true },
262
+ inputSchema: {
263
+ type: 'object',
264
+ required: ['event_id'],
265
+ additionalProperties: false,
266
+ properties: { event_id: { type: 'string', minLength: 1 } }
267
+ }
268
+ },
257
269
  {
258
270
  name: 'personal_knowledge_search',
259
271
  description: 'Search the explicitly configured v1 personal knowledge context. The result includes the verified context and never falls back to another store.',
@@ -434,6 +446,7 @@ export const toolDefinitions = [
434
446
  const managedPersonalKnowledgeToolNames = new Set([
435
447
  'personal_knowledge_context',
436
448
  'personal_knowledge_register',
449
+ 'personal_knowledge_reject',
437
450
  'personal_knowledge_search'
438
451
  ]);
439
452
  function isPersonalKnowledgeTool(name) {
@@ -518,6 +531,14 @@ function configuredPersonalKnowledgeRuntime() {
518
531
  });
519
532
  }
520
533
  async function callPersonalKnowledgeTool(name, rawArgs) {
534
+ if (name === 'personal_knowledge_reject') {
535
+ const args = personalKnowledgeRejectSchema.parse(rawArgs ?? {});
536
+ const runtime = configuredPersonalKnowledgeRuntime();
537
+ if (!(runtime instanceof PersonalKnowledgeClient)) {
538
+ throw new Error('Personal Knowledge rejection requires authenticated API storage; local retraction is not supported.');
539
+ }
540
+ return runtime.reject(args.event_id);
541
+ }
521
542
  const runtime = configuredPersonalKnowledgeRuntime();
522
543
  if (name === 'personal_knowledge_context') {
523
544
  personalKnowledgeContextSchema.parse(rawArgs ?? {});
@@ -536,7 +557,7 @@ async function callPersonalKnowledgeTool(name, rawArgs) {
536
557
  export async function callBrainbaseTool(name, rawArgs = {}, options = {}) {
537
558
  const mode = configuredPersonalKnowledgeMode();
538
559
  if (mode === 'managed_cloud' && !isPersonalKnowledgeTool(name)) {
539
- throw new Error('managed_cloud Personal Knowledge MCP only permits personal_knowledge_context, personal_knowledge_register, and personal_knowledge_search.');
560
+ throw new Error('managed_cloud Personal Knowledge MCP only permits personal_knowledge_context, personal_knowledge_register, personal_knowledge_reject, and personal_knowledge_search.');
540
561
  }
541
562
  if (name.startsWith('foundation_'))
542
563
  return callFoundationPublicTool(name, rawArgs, options.foundation);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unson/brainbase-mcp",
3
- "version": "0.50.9",
3
+ "version": "0.50.11",
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",
@@ -624,6 +624,7 @@
624
624
  "@types/node": "^22.15.29",
625
625
  "@types/pg": "^8.23.1",
626
626
  "esbuild": "0.28.2",
627
+ "modern-web-guidance": "1.0.0",
627
628
  "pg": "^8.23.1",
628
629
  "three": "0.186.1",
629
630
  "tsx": "^4.19.4",
@@ -644,5 +645,5 @@
644
645
  "url": "https://github.com/Unson-LLC/brainbase/issues"
645
646
  },
646
647
  "homepage": "https://github.com/Unson-LLC/brainbase#readme",
647
- "gitHead": "70cfdd6b6628a3cd90b1d73ca39e0dde1199ab40"
648
+ "gitHead": "0eb8f0dcc9261d17af72f5b54441414bad00d937"
648
649
  }
@@ -107,6 +107,21 @@ export function workspaceTopbar(doc, { title = '', query } = {}) {
107
107
  return header;
108
108
  }
109
109
 
110
+ /**
111
+ * Backdrop click closes a modal. Browsers with `closedby` do it natively and fire `cancel`,
112
+ * which the caller already handles; the pointer check is the fallback where it is missing (Safari).
113
+ */
114
+ function workspaceLightDismiss(doc, dialog, close) {
115
+ dialog.setAttribute('closedby', 'any');
116
+ const NativeDialog = doc.defaultView?.HTMLDialogElement;
117
+ if (NativeDialog && 'closedBy' in NativeDialog.prototype) return;
118
+ dialog.addEventListener('click', event => {
119
+ if (event.target !== dialog) return;
120
+ const rect = dialog.getBoundingClientRect();
121
+ if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) close();
122
+ });
123
+ }
124
+
110
125
  /** A reusable right inspector whose content can refresh without replacing the modal. */
111
126
  export function workspaceDetailDrawer(doc, { title = '詳細', opener, onClose } = {}) {
112
127
  const dialog = workspaceApplyDrawer(el(doc, 'dialog', { className: 'bb-ws-dialog bb-ws-detail-drawer' }));
@@ -135,11 +150,7 @@ export function workspaceDetailDrawer(doc, { title = '詳細', opener, onClose }
135
150
  const button = workspaceButton(doc, { text: '閉じる', onClick: () => close() });
136
151
  head.append(label, button); dialog.append(head, body); doc.body.append(dialog);
137
152
  dialog.addEventListener('cancel', event => { event.preventDefault(); close(); });
138
- dialog.addEventListener('click', event => {
139
- if (event.target !== dialog) return;
140
- const rect = dialog.getBoundingClientRect();
141
- if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) close();
142
- });
153
+ workspaceLightDismiss(doc, dialog, () => close());
143
154
  return {
144
155
  dialog,
145
156
  setContent(...content) { if (!disposed) body.replaceChildren(...content); },
@@ -432,11 +443,7 @@ export function workspaceDialog(doc, { title, content, opener, presentation = 'c
432
443
  const body = el(doc, 'div', { className: 'bb-ws-dialog-body' }); appendContent(body, doc, content);
433
444
  dialog.append(head, body); doc.body.append(dialog);
434
445
  dialog.addEventListener('cancel', event => { event.preventDefault(); dialog.close(); });
435
- dialog.addEventListener('click', event => {
436
- if (event.target !== dialog) return;
437
- const rect = dialog.getBoundingClientRect();
438
- if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) dialog.close();
439
- });
446
+ workspaceLightDismiss(doc, dialog, () => dialog.close());
440
447
  dialog.addEventListener('close', cleanup, { once: true });
441
448
  try { dialog.showModal(); close.focus(); } catch (error) { cleanup(); throw error; }
442
449
  return dialog;