@unson/brainbase-mcp 0.50.0 → 0.50.1

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.
@@ -13,11 +13,11 @@
13
13
  },
14
14
  {
15
15
  "path": "contracts/judgment-dag/source-lock.json",
16
- "sha256": "4d3fbc2f82c07f709d901fcda68718b12b45a0d11a16354edec32b3406370bfe"
16
+ "sha256": "e810c141907c9c8cf6a2e9faf48b185c101b0961b6cc9ed9be257d8db3d4aad0"
17
17
  },
18
18
  {
19
19
  "path": "docs/architecture/judgment-dag-core.md",
20
- "sha256": "24305aaa97df9c734d468c49f52784e94b77a4f506bae41d482bee05625d7e2a"
20
+ "sha256": "c3d9c9020fc3013ea1018f89a9d4d5d04b7066e1b871a7a27b7ca624b43efc6f"
21
21
  },
22
22
  {
23
23
  "path": "docs/management/judgment-dag-milestones.md",
@@ -28,5 +28,5 @@
28
28
  "sha256": "38f2f0f783bba47f83950cdc286dc03a3e0ee6190b0fbb67d72002e0402c5805"
29
29
  }
30
30
  ],
31
- "digest": "fa45bdca9bc397be78314d8f24c5a383637e6c016c61d7635f85fc50e3c04800"
31
+ "digest": "0fd9169ce73843df02df995648b8d616f343639f4b46ad5ea4db85811f9b29a4"
32
32
  }
@@ -72,7 +72,7 @@
72
72
  {
73
73
  "kind": "architecture",
74
74
  "path": "docs/architecture/judgment-dag-core.md",
75
- "sha256": "24305aaa97df9c734d468c49f52784e94b77a4f506bae41d482bee05625d7e2a"
75
+ "sha256": "c3d9c9020fc3013ea1018f89a9d4d5d04b7066e1b871a7a27b7ca624b43efc6f"
76
76
  },
77
77
  {
78
78
  "kind": "milestones",
@@ -167,6 +167,24 @@ function withdrawInput(body, minutesId, key, fingerprint) {
167
167
  ...idempotencyFields(key, fingerprint)
168
168
  };
169
169
  }
170
+ function listOptionsFromQuery(params) {
171
+ const result = {};
172
+ const limitRaw = params.get('limit');
173
+ if (limitRaw !== null) {
174
+ const limit = Number(limitRaw);
175
+ if (!/^\d+$/u.test(limitRaw) || !Number.isInteger(limit) || limit < 1) {
176
+ throw new LocalWebHttpError(422, 'invalid_limit', 'limit must be a positive integer');
177
+ }
178
+ result.limit = limit;
179
+ }
180
+ const cursor = params.get('cursor');
181
+ if (cursor !== null) {
182
+ if (cursor.trim() === '')
183
+ throw new LocalWebHttpError(422, 'invalid_cursor', 'cursor must not be empty');
184
+ result.cursor = cursor;
185
+ }
186
+ return result;
187
+ }
170
188
  export function createMeetingMinutesHttpHandler(options) {
171
189
  if (!options || !options.store || typeof options.resolveContext !== 'function') {
172
190
  throw new TypeError('store and resolveContext are required');
@@ -175,12 +193,22 @@ export function createMeetingMinutesHttpHandler(options) {
175
193
  const bodyLimitBytes = options.bodyLimitBytes ?? DEFAULT_BODY_LIMIT_BYTES;
176
194
  if (!Number.isInteger(bodyLimitBytes) || bodyLimitBytes <= 0)
177
195
  throw new TypeError('bodyLimitBytes must be a positive integer');
178
- async function execute(route, body, context, key, fingerprint) {
196
+ async function execute(route, body, context, key, fingerprint, listOptions = {}) {
179
197
  try {
180
198
  switch (route.kind) {
181
199
  case 'collection':
182
- if (body === undefined)
183
- return { statusCode: 200, body: { state: 'ready', meetings: await options.store.list_meetings(context), absence_confirmed: true } };
200
+ if (body === undefined) {
201
+ const page = await options.store.list_meetings(context, listOptions);
202
+ return {
203
+ statusCode: 200,
204
+ body: {
205
+ state: 'ready',
206
+ meetings: page.meetings,
207
+ absence_confirmed: true,
208
+ ...(page.next_cursor === undefined ? {} : { next_cursor: page.next_cursor })
209
+ }
210
+ };
211
+ }
184
212
  return { statusCode: 201, body: await options.store.create_meeting(createInput(body, key, fingerprint), context) };
185
213
  case 'meeting':
186
214
  return { statusCode: 200, body: await options.store.get_meeting(route.meetingId ?? '', context) };
@@ -233,7 +261,8 @@ export function createMeetingMinutesHttpHandler(options) {
233
261
  }
234
262
  }
235
263
  return async (request, response) => {
236
- const path = requestUrl(request).pathname;
264
+ const url = requestUrl(request);
265
+ const path = url.pathname;
237
266
  const route = routeFor(path, basePath);
238
267
  if (!route)
239
268
  return false;
@@ -254,10 +283,11 @@ export function createMeetingMinutesHttpHandler(options) {
254
283
  const body = method === 'POST' ? await readJsonObjectBody(request, bodyLimitBytes) : undefined;
255
284
  const key = method === 'POST' ? idempotencyKey(request) : undefined;
256
285
  const fingerprint = key === undefined ? undefined : requestFingerprint({ method, path, body: body ?? null });
286
+ const listOptions = route.kind === 'collection' && method === 'GET' ? listOptionsFromQuery(url.searchParams) : {};
257
287
  // Idempotency is persisted by the domain store in the same CAS snapshot
258
288
  // as the mutation. Keeping no result cache here ensures retries after a
259
289
  // restart, and retries after ACL changes, are reauthorized by the store.
260
- const result = await execute(route, body, context, key, fingerprint);
290
+ const result = await execute(route, body, context, key, fingerprint, listOptions);
261
291
  writeJson(response, result.statusCode, result.body);
262
292
  }
263
293
  catch (error) {
@@ -53,6 +53,24 @@ function routeFor(pathname, basePath) {
53
53
  }
54
54
  return { kind: 'meeting' };
55
55
  }
56
+ function listOptionsFromQuery(params) {
57
+ const options = {};
58
+ const limitRaw = params.get('limit');
59
+ if (limitRaw !== null) {
60
+ const limit = Number(limitRaw);
61
+ if (!/^\d+$/u.test(limitRaw) || !Number.isInteger(limit) || limit < 1) {
62
+ throw new LocalWebHttpError(422, 'invalid_limit', 'limit must be a positive integer');
63
+ }
64
+ options.limit = limit;
65
+ }
66
+ const cursor = params.get('cursor');
67
+ if (cursor !== null) {
68
+ if (cursor.trim() === '')
69
+ throw new LocalWebHttpError(422, 'invalid_cursor', 'cursor must not be empty');
70
+ options.cursor = cursor;
71
+ }
72
+ return options;
73
+ }
56
74
  function canonicalJson(value) {
57
75
  if (value === null || typeof value !== 'object')
58
76
  return JSON.stringify(value);
@@ -212,12 +230,21 @@ export function createMeetingMinutesStorageHttpHandler(options) {
212
230
  const bodyLimitBytes = options.bodyLimitBytes ?? DEFAULT_BODY_LIMIT_BYTES;
213
231
  if (!Number.isInteger(bodyLimitBytes) || bodyLimitBytes <= 0)
214
232
  throw new TypeError('bodyLimitBytes must be a positive integer');
215
- async function execute(route, body, context, key, fingerprint) {
233
+ async function execute(route, body, context, key, fingerprint, listOptions = {}) {
216
234
  try {
217
235
  switch (route.kind) {
218
236
  case 'collection': {
219
237
  if (body === undefined) {
220
- return { statusCode: 200, body: { state: 'ready', meetings: await options.store.list_meetings(context), absence_confirmed: true } };
238
+ const page = await options.store.list_meetings(context, listOptions);
239
+ return {
240
+ statusCode: 200,
241
+ body: {
242
+ state: 'ready',
243
+ meetings: page.meetings,
244
+ absence_confirmed: true,
245
+ ...(page.next_cursor === undefined ? {} : { next_cursor: page.next_cursor }),
246
+ },
247
+ };
221
248
  }
222
249
  const input = createInput(body, key, fingerprint);
223
250
  return {
@@ -278,7 +305,8 @@ export function createMeetingMinutesStorageHttpHandler(options) {
278
305
  }
279
306
  }
280
307
  return async (request, response) => {
281
- const path = requestUrl(request).pathname;
308
+ const url = requestUrl(request);
309
+ const path = url.pathname;
282
310
  const route = routeFor(path, basePath);
283
311
  if (!route)
284
312
  return false;
@@ -298,7 +326,8 @@ export function createMeetingMinutesStorageHttpHandler(options) {
298
326
  const body = method === 'POST' ? await readJsonObjectBody(request, bodyLimitBytes) : undefined;
299
327
  const key = method === 'POST' ? idempotencyKey(request) : undefined;
300
328
  const fingerprint = key === undefined ? undefined : requestFingerprint({ method, path, body: body ?? null });
301
- const result = await execute(route, body, context, key, fingerprint);
329
+ const listOptions = route.kind === 'collection' && method === 'GET' ? listOptionsFromQuery(url.searchParams) : {};
330
+ const result = await execute(route, body, context, key, fingerprint, listOptions);
302
331
  writeJson(response, result.statusCode, result.body);
303
332
  }
304
333
  catch (error) {
@@ -3,6 +3,14 @@ export declare const MEETING_MINUTES_CONTRACT_VERSION: "brainbase.meeting-minute
3
3
  export declare const MEETING_MINUTES_SNAPSHOT_VERSION: 1;
4
4
  export declare const MEETING_MINUTES_SIDECAR: "meeting-minutes.json";
5
5
  export declare const MEETING_MINUTES_BODY_DIGEST_ALGORITHM: "sha256";
6
+ /**
7
+ * A list page is bounded so one listing never has to serialize every meeting.
8
+ * The default applies when a caller asks for no limit, so an old caller that
9
+ * never paged keeps working while the response stays small; the maximum caps
10
+ * what a single page may request.
11
+ */
12
+ export declare const MEETING_MINUTES_LIST_DEFAULT_LIMIT: 100;
13
+ export declare const MEETING_MINUTES_LIST_MAX_LIMIT: 500;
6
14
  export type MeetingId = string;
7
15
  export type MinutesId = string;
8
16
  export type MinutesVersionId = string;
@@ -164,6 +172,23 @@ export interface MeetingMinutesDetail extends MeetingMinutesSummary {
164
172
  readonly versions: readonly MinutesVersionRecord[];
165
173
  readonly snapshot_revision: number;
166
174
  }
175
+ /** Caller-supplied bounds for one listing page. Both fields are optional. */
176
+ export interface MeetingMinutesListOptions {
177
+ /** Maximum summaries in the page. Defaults to MEETING_MINUTES_LIST_DEFAULT_LIMIT, capped at the maximum. */
178
+ readonly limit?: number;
179
+ /** Opaque continuation token from a previous page's next_cursor. */
180
+ readonly cursor?: string;
181
+ }
182
+ /**
183
+ * One listing page. `meetings` carries meeting and minutes-document summaries
184
+ * only — never a minutes version body. The body is read through get_meeting /
185
+ * the detail endpoint. `next_cursor` is present only while more readable
186
+ * meetings follow the page.
187
+ */
188
+ export interface MeetingMinutesListPage {
189
+ readonly meetings: readonly MeetingMinutesSummary[];
190
+ readonly next_cursor?: string;
191
+ }
167
192
  export type MeetingMinutesErrorCode = 'invalid_input' | 'not_found' | 'revision_conflict' | 'authorization_denied' | 'corrupt_record' | 'storage_unavailable' | 'readback_mismatch' | 'idempotency_conflict';
168
193
  export declare class MeetingMinutesError extends Error {
169
194
  readonly code: MeetingMinutesErrorCode;
@@ -191,7 +216,13 @@ export interface MeetingMinutesExternalSourceHook {
191
216
  register(source_ref: MeetingMinutesSourceRef, identity: MeetingMinutesExternalSourceIdentity): Promise<void>;
192
217
  }
193
218
  export interface MeetingMinutesStore {
219
+ /**
220
+ * Without options the store returns every readable summary as an array, the
221
+ * shape every caller before 0.50.1 depends on. Passing options (even `{}`)
222
+ * opts into one bounded page with an optional `next_cursor`.
223
+ */
194
224
  list_meetings(context: MeetingMinutesRequestContext): Promise<readonly MeetingMinutesSummary[]>;
225
+ list_meetings(context: MeetingMinutesRequestContext, options: MeetingMinutesListOptions): Promise<MeetingMinutesListPage>;
195
226
  create_meeting(input: MeetingCreateInput, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
196
227
  create_minutes(meeting_id: MeetingId, input: CreateMinutesInput, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
197
228
  get_meeting(meeting_id: MeetingId, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
@@ -7,6 +7,14 @@ export const MEETING_MINUTES_CONTRACT_VERSION = 'brainbase.meeting-minutes.v1';
7
7
  export const MEETING_MINUTES_SNAPSHOT_VERSION = 1;
8
8
  export const MEETING_MINUTES_SIDECAR = 'meeting-minutes.json';
9
9
  export const MEETING_MINUTES_BODY_DIGEST_ALGORITHM = 'sha256';
10
+ /**
11
+ * A list page is bounded so one listing never has to serialize every meeting.
12
+ * The default applies when a caller asks for no limit, so an old caller that
13
+ * never paged keeps working while the response stays small; the maximum caps
14
+ * what a single page may request.
15
+ */
16
+ export const MEETING_MINUTES_LIST_DEFAULT_LIMIT = 100;
17
+ export const MEETING_MINUTES_LIST_MAX_LIMIT = 500;
10
18
  export class MeetingMinutesError extends Error {
11
19
  code;
12
20
  constructor(code, message) {
@@ -636,6 +644,29 @@ function findExternalSourceIdentity(snapshot, source) {
636
644
  return undefined;
637
645
  return { meeting_id: match.meeting_id, minutes_id: match.minutes_id, version_id: match.version_id };
638
646
  }
647
+ function encodeListCursor(meetingId) {
648
+ return Buffer.from(meetingId, 'utf8').toString('base64url');
649
+ }
650
+ function decodeListCursor(value) {
651
+ const token = nonEmptyString(value, 'cursor');
652
+ const decoded = Buffer.from(token, 'base64url').toString('utf8');
653
+ if (decoded.trim() === '')
654
+ throw invalid('cursor is invalid');
655
+ return decoded;
656
+ }
657
+ function normalizeListOptions(options) {
658
+ if (!isRecord(options))
659
+ throw invalid('list options must be an object');
660
+ let limit = MEETING_MINUTES_LIST_DEFAULT_LIMIT;
661
+ if (options.limit !== undefined) {
662
+ if (typeof options.limit !== 'number' || !Number.isInteger(options.limit) || options.limit < 1) {
663
+ throw invalid('limit must be a positive integer');
664
+ }
665
+ limit = Math.min(options.limit, MEETING_MINUTES_LIST_MAX_LIMIT);
666
+ }
667
+ const startAfter = options.cursor === undefined ? undefined : decodeListCursor(options.cursor);
668
+ return { limit, startAfter };
669
+ }
639
670
  export function createMeetingMinutesStore(options) {
640
671
  const storage = defaultStorage(options);
641
672
  const now = options.now ?? (() => new Date());
@@ -711,8 +742,16 @@ export function createMeetingMinutesStore(options) {
711
742
  // never make the caller retry a write that is already durable.
712
743
  }
713
744
  }
714
- async function list_meetings(context) {
745
+ async function list_meetings(context, options) {
715
746
  assertPrincipal(context);
747
+ if (options === undefined)
748
+ return listAllMeetings(context);
749
+ return listMeetingsPage(context, options);
750
+ }
751
+ // The array form callers relied on before paging existed (organization
752
+ // server-parts read it with Array.isArray). It stays unbounded on purpose:
753
+ // callers that need bounded responses pass options and get a page.
754
+ async function listAllMeetings(context) {
716
755
  const snapshot = await readSnapshot();
717
756
  const output = [];
718
757
  for (const meeting of snapshot.meetings) {
@@ -722,6 +761,37 @@ export function createMeetingMinutesStore(options) {
722
761
  }
723
762
  return freezeClone(output);
724
763
  }
764
+ async function listMeetingsPage(context, options) {
765
+ const { limit, startAfter } = normalizeListOptions(options);
766
+ const snapshot = await readSnapshot();
767
+ const meetings = snapshot.meetings;
768
+ // Meetings are only ever appended, so their stored order is stable and a
769
+ // cursor can resume after a known meeting_id. An unknown cursor cannot be
770
+ // resumed safely, so it is rejected rather than silently restarted.
771
+ let index = 0;
772
+ if (startAfter !== undefined) {
773
+ const found = meetings.findIndex((meeting) => meeting.meeting_id === startAfter);
774
+ if (found === -1)
775
+ throw invalid('cursor is invalid');
776
+ index = found + 1;
777
+ }
778
+ const output = [];
779
+ let next_cursor;
780
+ for (; index < meetings.length; index += 1) {
781
+ const meeting = meetings[index];
782
+ if (!(await canReadMeeting(snapshot, meeting, context)))
783
+ continue;
784
+ if (output.length < limit) {
785
+ output.push(summary(snapshot, meeting));
786
+ continue;
787
+ }
788
+ // A full page has at least one more readable meeting after it, so the
789
+ // last returned meeting_id becomes the continuation token.
790
+ next_cursor = encodeListCursor(output[output.length - 1].meeting.meeting_id);
791
+ break;
792
+ }
793
+ return freezeClone({ meetings: output, ...(next_cursor === undefined ? {} : { next_cursor }) });
794
+ }
725
795
  async function canReadMeeting(snapshot, meeting, context) {
726
796
  if (!(await allowed(authorizer, 'read', meeting, context)))
727
797
  return false;
@@ -14,11 +14,11 @@ Brainbase OSS and organization deployments share the same Judgment DAG semantic
14
14
 
15
15
  Brainbase is not only a memory/knowledge store. Its core responsibility is to externalize, preserve, replay, evaluate, and improve the structure by which a person or organization turns context into judgment and action.
16
16
 
17
- The prior product boundary that limited OSS Brainbase to `Remember / Organize / Retrieve / Learn` is revised. Brainbase owns the **judgment substrate**; Mana may own autonomous operating loops, continuous follow-through, and outcome ownership on top of that substrate.
17
+ The prior product boundary that limited OSS Brainbase to `Remember / Organize / Retrieve / Learn` is revised. Brainbase owns the **judgment substrate**. [ADR-026](https://github.com/Unson-LLC/brainbase-project/blob/main/docs/architecture/adr/ADR-026-review-promises-and-external-agents.md) retires Mana and makes Brainbase the canonical home of review promises, read by external agents such as Grok Bot and, for enterprise use, Claude (Duet).
18
18
 
19
19
  ```text
20
20
  Brainbase = Remember / Organize / Retrieve / Judge / Replay / Learn
21
- Mana = Operate / Prioritize continuously / Act autonomously / Follow-through
21
+ External agents = Check agreed review dates / Read promises and actuals / Propose the agreed next step
22
22
  ```
23
23
 
24
24
  Brainbase may represent and execute judgment nodes. It does not become an always-on autonomous operator merely because it can execute a DAG.
@@ -269,19 +269,24 @@ Organization/Enterprise adds operational concerns rather than a different brain
269
269
  - cross-project governance
270
270
  - enterprise security boundaries
271
271
 
272
- ## Mana boundary after this decision
272
+ ## Review promises and external-agent boundary
273
273
 
274
- Mana is no longer defined as the only place where judgment can occur.
274
+ [ADR-026](https://github.com/Unson-LLC/brainbase-project/blob/main/docs/architecture/adr/ADR-026-review-promises-and-external-agents.md) supersedes the former Mana operating boundary. Brainbase is not paired with Mana; Mana is retired by product decision.
275
275
 
276
- Brainbase owns **what the judgment graph is, what it depends on, who/what can run it, what it produced, and how it evaluated**.
276
+ Brainbase owns **what the judgment graph is, what it depends on, who/what can run it, what it produced, and how it evaluated**. It is also the canonical home of the review promise for each world-model hypothesis and prediction: one metric, an acceptable deviation, a review date (check even without a deviation), and the action agreed in advance if it deviates.
277
277
 
278
- Mana owns the higher-order operating behavior that repeatedly decides *when* to run graphs, prioritizes across goals, initiates work, monitors progress, follows through, and intervenes over time.
278
+ The human sets that promise when placing the hypothesis. The AI does not invent or change review conditions when results arrive. Grok Bot routines are the current intended watcher: read the promise and actuals on the review date, then produce the agreed replanning proposal or return the decision to Sato. Enterprise Claude (Duet) should be able to read the same promise. Brainbase does not depend on a particular watcher.
279
+
280
+ ADR-014 F5's return to a human when relying on a refuted world model remains one of these agreed actions; the promise does not grant additional execution or adoption authority. Recording the promise version, observations, check, and resulting action must allow later inspection of whether the agent followed the agreement.
279
281
 
280
282
  ```text
281
- Brainbase: executable organizational cognition
282
- Mana: autonomous organizational operation
283
+ Brainbase: judgment substrate and canonical review promises
284
+ External agents: scheduled observation and the pre-agreed next step
285
+ Human: hypotheses, review conditions, and required adoption/approval decisions
283
286
  ```
284
287
 
288
+ This is an accepted design direction. Promise fields in schemas/contracts, watcher integrations, and operational rollout remain Planned in ADR-026's next steps; this document update does not implement them or stop a running bot.
289
+
285
290
  ## Non-goals
286
291
 
287
292
  - Do not migrate the entire Brainbase ontology to a large Company Ontology in one release.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unson/brainbase-mcp",
3
- "version": "0.50.0",
3
+ "version": "0.50.1",
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",
@@ -644,5 +644,5 @@
644
644
  "url": "https://github.com/Unson-LLC/brainbase/issues"
645
645
  },
646
646
  "homepage": "https://github.com/Unson-LLC/brainbase#readme",
647
- "gitHead": "4e2b7f753300d797a8b44ef53b8fbb83c09aca3e"
647
+ "gitHead": "75bd4a34f5092032688284d857badc7d8984cd73"
648
648
  }
@@ -1956,10 +1956,23 @@ export function createMeetingMinutesUI({
1956
1956
  state.loading = true;
1957
1957
  if (!quiet) setStatus('会議一覧を読み込んでいます。');
1958
1958
  try {
1959
- const payload = await call('');
1960
- if (!isCurrentRequest()) return state.meetings;
1961
- if (!isRecord(payload) || !Array.isArray(payload.meetings) || payload.absence_confirmed !== true) throw new Error('会議一覧の形式を確認できません。');
1962
- state.meetings = sortMeetings(payload.meetings);
1959
+ // The list carries no version body and the host caps each page, so even a long
1960
+ // history reads as a run of small responses instead of one large one. The cursor
1961
+ // walks the append-only meetings to the end and every page is gathered, so the
1962
+ // screen still shows every meeting (UNS-264). The first page keeps the bare path
1963
+ // so a host without paging keeps answering the single request it always has.
1964
+ const collected = [];
1965
+ let cursor = null;
1966
+ for (let page = 0; ; page += 1) {
1967
+ const payload = await call(cursor === null ? '' : `?cursor=${encodeURIComponent(cursor)}`);
1968
+ if (!isCurrentRequest()) return state.meetings;
1969
+ if (!isRecord(payload) || !Array.isArray(payload.meetings) || payload.absence_confirmed !== true) throw new Error('会議一覧の形式を確認できません。');
1970
+ for (const entry of payload.meetings) collected.push(entry);
1971
+ const next = typeof payload.next_cursor === 'string' ? payload.next_cursor.trim() : '';
1972
+ if (!next || next === cursor || page >= 10000) break;
1973
+ cursor = next;
1974
+ }
1975
+ state.meetings = sortMeetings(collected);
1963
1976
  state.listError = null;
1964
1977
  const selectedMeetingStillListed = state.meetingId !== null
1965
1978
  && state.meetings.some((entry) => entry?.meeting?.meeting_id === state.meetingId);