@unson/brainbase-mcp 0.50.0 → 0.50.2

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,24 @@ 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, ordered by scheduled_at descending, then undated imports
184
+ * by created_at descending (meeting_id breaks ties). `meetings` carries meeting and minutes-document summaries
185
+ * only — never a minutes version body. The body is read through get_meeting /
186
+ * the detail endpoint. `next_cursor` is present only while more readable
187
+ * meetings follow the page.
188
+ */
189
+ export interface MeetingMinutesListPage {
190
+ readonly meetings: readonly MeetingMinutesSummary[];
191
+ readonly next_cursor?: string;
192
+ }
167
193
  export type MeetingMinutesErrorCode = 'invalid_input' | 'not_found' | 'revision_conflict' | 'authorization_denied' | 'corrupt_record' | 'storage_unavailable' | 'readback_mismatch' | 'idempotency_conflict';
168
194
  export declare class MeetingMinutesError extends Error {
169
195
  readonly code: MeetingMinutesErrorCode;
@@ -191,7 +217,13 @@ export interface MeetingMinutesExternalSourceHook {
191
217
  register(source_ref: MeetingMinutesSourceRef, identity: MeetingMinutesExternalSourceIdentity): Promise<void>;
192
218
  }
193
219
  export interface MeetingMinutesStore {
220
+ /**
221
+ * Without options the store returns every readable summary as an array, the
222
+ * shape every caller before 0.50.1 depends on. Passing options (even `{}`)
223
+ * opts into one bounded page with an optional `next_cursor`.
224
+ */
194
225
  list_meetings(context: MeetingMinutesRequestContext): Promise<readonly MeetingMinutesSummary[]>;
226
+ list_meetings(context: MeetingMinutesRequestContext, options: MeetingMinutesListOptions): Promise<MeetingMinutesListPage>;
195
227
  create_meeting(input: MeetingCreateInput, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
196
228
  create_minutes(meeting_id: MeetingId, input: CreateMinutesInput, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
197
229
  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,42 @@ 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
+ // Page the newest meeting dates first; undated imports follow by creation
768
+ // time. The ID tie-breaker keeps equal timestamps deterministic. Resume by
769
+ // ID so newly inserted meetings before the cursor cannot shift later pages.
770
+ const meetings = [...snapshot.meetings].sort((left, right) => {
771
+ if (Boolean(left.scheduled_at) !== Boolean(right.scheduled_at))
772
+ return left.scheduled_at ? -1 : 1;
773
+ const byDate = Date.parse(right.scheduled_at ?? right.created_at) - Date.parse(left.scheduled_at ?? left.created_at);
774
+ return byDate || right.meeting_id.localeCompare(left.meeting_id);
775
+ });
776
+ let index = 0;
777
+ if (startAfter !== undefined) {
778
+ const found = meetings.findIndex((meeting) => meeting.meeting_id === startAfter);
779
+ if (found === -1)
780
+ throw invalid('cursor is invalid');
781
+ index = found + 1;
782
+ }
783
+ const output = [];
784
+ let next_cursor;
785
+ for (; index < meetings.length; index += 1) {
786
+ const meeting = meetings[index];
787
+ if (!(await canReadMeeting(snapshot, meeting, context)))
788
+ continue;
789
+ if (output.length < limit) {
790
+ output.push(summary(snapshot, meeting));
791
+ continue;
792
+ }
793
+ // A full page has at least one more readable meeting after it, so the
794
+ // last returned meeting_id becomes the continuation token.
795
+ next_cursor = encodeListCursor(output[output.length - 1].meeting.meeting_id);
796
+ break;
797
+ }
798
+ return freezeClone({ meetings: output, ...(next_cursor === undefined ? {} : { next_cursor }) });
799
+ }
725
800
  async function canReadMeeting(snapshot, meeting, context) {
726
801
  if (!(await allowed(authorizer, 'read', meeting, context)))
727
802
  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.2",
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": "b7649210b7d3e3c27ac61780abe0ad2cc13b5d05"
648
648
  }
@@ -20,6 +20,8 @@ export const MEETING_MINUTES_UI_CONTRACT_VERSION = 'brainbase.meeting-minutes-ui
20
20
 
21
21
  const WEEKDAYS = ['日', '月', '火', '水', '木', '金', '土'];
22
22
  const TOKYO = 'Asia/Tokyo';
23
+ // The screen chooses 50; the core's independent default remains 100.
24
+ const LIST_PAGE_SIZE = 50;
23
25
  const SORTS = Object.freeze([
24
26
  { value: 'scheduled-desc', label: '会議の日時が新しい順' },
25
27
  { value: 'scheduled-asc', label: '会議の日時が古い順' },
@@ -713,6 +715,8 @@ export function createMeetingMinutesUI({
713
715
  minutesId: null,
714
716
  versionId: null,
715
717
  loading: false,
718
+ nextCursor: null,
719
+ moreError: null,
716
720
  listError: null,
717
721
  detailError: null,
718
722
  filters: { ...EMPTY_FILTERS },
@@ -727,6 +731,7 @@ export function createMeetingMinutesUI({
727
731
  };
728
732
  let disposed = false;
729
733
  let listRequestGeneration = 0;
734
+ let seenListCursors = new Set();
730
735
  let detailRequestGeneration = 0;
731
736
  let createReasonSequence = 0;
732
737
  let connectionsSlot = null;
@@ -1450,6 +1455,19 @@ export function createMeetingMinutesUI({
1450
1455
  return item;
1451
1456
  }
1452
1457
 
1458
+ function appendMore(parent) {
1459
+ if (!state.nextCursor) return;
1460
+ if (state.moreError) {
1461
+ parent.append(makeElement(doc, 'p', {
1462
+ className: 'bb-minutes-error', textContent: state.moreError, attrs: { role: 'alert' },
1463
+ }));
1464
+ parent.append(button(doc, '一覧を再読み込み', () => loadMeetings({ restoreFocus: true })));
1465
+ }
1466
+ parent.append(button(doc, state.loading ? '読み込んでいます。' : 'もっと見る', () => loadMeetings({ append: true }), {
1467
+ disabled: state.loading,
1468
+ }));
1469
+ }
1470
+
1453
1471
  function renderList() {
1454
1472
  clear(listPane);
1455
1473
  const head = makeElement(doc, 'div', { className: 'bb-minutes-pane-head' });
@@ -1464,7 +1482,7 @@ export function createMeetingMinutesUI({
1464
1482
  const narrowed = clientFiltersActive();
1465
1483
  head.append(makeElement(doc, 'p', {
1466
1484
  className: 'bb-minutes-sort-note',
1467
- textContent: narrowed ? `${meetings.length}件中${visible.length}件` : `${meetings.length}件`,
1485
+ textContent: `${narrowed ? `${meetings.length}件中${visible.length}件` : `${meetings.length}件`}${state.nextCursor ? '(続きあり・絞り込みは読込済みの会議が対象)' : ''}`,
1468
1486
  }));
1469
1487
  if (compactToolbar) {
1470
1488
  const create = head.querySelector('button');
@@ -1489,17 +1507,20 @@ export function createMeetingMinutesUI({
1489
1507
  : 'まだ議事録はありません。会議を取り込むと、ここに新しい順で並びます。',
1490
1508
  }));
1491
1509
  if (filtersActive() && !compact) listPane.append(button(doc, '条件を外す', () => clearFilters()));
1510
+ appendMore(listPane);
1492
1511
  return;
1493
1512
  }
1494
1513
  if (visible.length === 0) {
1495
- listPane.append(makeElement(doc, 'p', { className: 'bb-minutes-empty', textContent: '条件に合う会議はありません。' }));
1514
+ listPane.append(makeElement(doc, 'p', { className: 'bb-minutes-empty', textContent: state.nextCursor ? '読み込んだ会議に条件に合うものはありません。' : '条件に合う会議はありません。' }));
1496
1515
  if (!compact) listPane.append(button(doc, '条件を外す', () => clearFilters()));
1516
+ appendMore(listPane);
1497
1517
  return;
1498
1518
  }
1499
1519
  const list = makeElement(doc, 'div', { className: 'bb-minutes-meeting-list' });
1500
1520
  if (state.sort === 'updated-desc' && !compact) {
1501
1521
  for (const entry of visible) list.append(renderMeetingRow(entry, { flat: true }));
1502
1522
  listPane.append(list);
1523
+ appendMore(listPane);
1503
1524
  return;
1504
1525
  }
1505
1526
  const updatedOrder = compact && state.sort === 'updated-desc';
@@ -1528,6 +1549,7 @@ export function createMeetingMinutesUI({
1528
1549
  for (const entry of unregistered) list.append(renderMeetingRow(entry));
1529
1550
  }
1530
1551
  listPane.append(list);
1552
+ appendMore(listPane);
1531
1553
  }
1532
1554
 
1533
1555
  function renderRail(version, documentRecord, meeting) {
@@ -1950,20 +1972,33 @@ export function createMeetingMinutesUI({
1950
1972
  detailPane.append(form);
1951
1973
  }
1952
1974
 
1953
- async function loadMeetings({ restoreFocus = false, quiet = false } = {}) {
1975
+ async function loadMeetings({ restoreFocus = false, quiet = false, append = false } = {}) {
1976
+ if (append && (state.loading || !state.nextCursor)) return state.meetings;
1954
1977
  const requestGeneration = ++listRequestGeneration;
1955
1978
  const isCurrentRequest = () => !disposed && requestGeneration === listRequestGeneration;
1956
1979
  state.loading = true;
1980
+ state.moreError = null;
1981
+ if (append) renderList();
1957
1982
  if (!quiet) setStatus('会議一覧を読み込んでいます。');
1958
1983
  try {
1959
- const payload = await call('');
1984
+ const cursor = append ? state.nextCursor : null;
1985
+ const payload = await call(`?limit=${LIST_PAGE_SIZE}${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`);
1960
1986
  if (!isCurrentRequest()) return state.meetings;
1961
1987
  if (!isRecord(payload) || !Array.isArray(payload.meetings) || payload.absence_confirmed !== true) throw new Error('会議一覧の形式を確認できません。');
1962
- state.meetings = sortMeetings(payload.meetings);
1988
+ if (payload.meetings.some(entry => !isRecord(entry?.meeting) || typeof entry.meeting.meeting_id !== 'string' || !entry.meeting.meeting_id.trim())) throw new Error('会議一覧の形式を確認できません。');
1989
+ if (payload.next_cursor != null && (typeof payload.next_cursor !== 'string' || !payload.next_cursor.trim())) throw new Error('会議一覧の続きの形式を確認できません。');
1990
+ const next = payload.next_cursor ?? null;
1991
+ if (next && (next === cursor || (append && seenListCursors.has(next)))) throw new Error('会議一覧の続きが進みません。再読み込みしてください。');
1992
+ const entries = append ? [...state.meetings, ...payload.meetings] : payload.meetings;
1993
+ const unique = new Map(entries.map(entry => [entry?.meeting?.meeting_id, entry]));
1994
+ state.meetings = sortMeetings([...unique.values()]);
1995
+ state.nextCursor = next;
1996
+ if (!append) seenListCursors = new Set();
1997
+ if (next) seenListCursors.add(next);
1963
1998
  state.listError = null;
1964
1999
  const selectedMeetingStillListed = state.meetingId !== null
1965
2000
  && state.meetings.some((entry) => entry?.meeting?.meeting_id === state.meetingId);
1966
- if (state.meetingId !== null && !selectedMeetingStillListed) {
2001
+ if (state.meetingId !== null && !selectedMeetingStillListed && !append) {
1967
2002
  detailRequestGeneration += 1;
1968
2003
  state.detail = null;
1969
2004
  state.meetingId = null;
@@ -1982,10 +2017,17 @@ export function createMeetingMinutesUI({
1982
2017
  } catch (error) {
1983
2018
  if (!isCurrentRequest()) return state.meetings;
1984
2019
  state.listError = loadErrorMessage(error, '会議一覧を読み込めませんでした。');
2020
+ if (append && !isAccessDenied(error)) {
2021
+ state.moreError = loadErrorMessage(error, '続きの会議を読み込めませんでした。');
2022
+ state.listError = null;
2023
+ setStatus(state.moreError, 'error');
2024
+ return state.meetings;
2025
+ }
1985
2026
  const preserve = preserveLoadedStateOnFailure(error);
1986
2027
  const hadDetail = Boolean(state.detail) || state.meetingId !== null;
1987
2028
  if (!preserve) {
1988
2029
  state.meetings = [];
2030
+ state.nextCursor = null;
1989
2031
  if (hadDetail) {
1990
2032
  detailRequestGeneration += 1;
1991
2033
  state.detail = null;
@@ -1999,7 +2041,7 @@ export function createMeetingMinutesUI({
1999
2041
  if (!preserve && hadDetail) renderDetail(null);
2000
2042
  setStatus(state.listError, 'error');
2001
2043
  } finally {
2002
- if (isCurrentRequest()) state.loading = false;
2044
+ if (isCurrentRequest()) { state.loading = false; renderList(); }
2003
2045
  }
2004
2046
  return state.meetings;
2005
2047
  }