@unson/brainbase-mcp 0.35.0 → 0.36.0
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/dist/meeting-minutes.d.ts +15 -1
- package/dist/meeting-minutes.js +67 -5
- package/package.json +2 -2
|
@@ -66,6 +66,12 @@ export interface MinutesDocumentRecord {
|
|
|
66
66
|
readonly created_actor_id: string;
|
|
67
67
|
readonly updated_at: string;
|
|
68
68
|
readonly revision: number;
|
|
69
|
+
/** Set when the document was taken back from its readers. Versions and bodies are kept. */
|
|
70
|
+
readonly withdrawal?: MinutesWithdrawalReceipt;
|
|
71
|
+
}
|
|
72
|
+
export interface MinutesWithdrawalReceipt {
|
|
73
|
+
readonly actor_id: string;
|
|
74
|
+
readonly withdrawn_at: string;
|
|
69
75
|
}
|
|
70
76
|
export interface MeetingMinutesSnapshot {
|
|
71
77
|
readonly schema_version: typeof MEETING_MINUTES_SNAPSHOT_VERSION;
|
|
@@ -76,7 +82,7 @@ export interface MeetingMinutesSnapshot {
|
|
|
76
82
|
readonly versions: readonly MinutesVersionRecord[];
|
|
77
83
|
readonly idempotency: readonly MeetingMinutesIdempotencyRecord[];
|
|
78
84
|
}
|
|
79
|
-
export type MeetingMinutesIdempotencyOperation = 'create_meeting' | 'create_minutes' | 'save_version' | 'confirm_version';
|
|
85
|
+
export type MeetingMinutesIdempotencyOperation = 'create_meeting' | 'create_minutes' | 'save_version' | 'confirm_version' | 'withdraw_minutes';
|
|
80
86
|
/** Durable write receipt. It lets a retried mutation find its exact target after restart. */
|
|
81
87
|
export interface MeetingMinutesIdempotencyRecord {
|
|
82
88
|
readonly key: string;
|
|
@@ -144,6 +150,12 @@ export interface ConfirmMinutesVersionInput {
|
|
|
144
150
|
readonly idempotency_key?: string;
|
|
145
151
|
readonly idempotency_fingerprint?: string;
|
|
146
152
|
}
|
|
153
|
+
export interface WithdrawMinutesInput {
|
|
154
|
+
readonly minutes_id: MinutesId;
|
|
155
|
+
readonly expected_revision: number;
|
|
156
|
+
readonly idempotency_key?: string;
|
|
157
|
+
readonly idempotency_fingerprint?: string;
|
|
158
|
+
}
|
|
147
159
|
export interface MeetingMinutesSummary {
|
|
148
160
|
readonly meeting: MeetingRecord;
|
|
149
161
|
readonly minutes: readonly MinutesDocumentRecord[];
|
|
@@ -186,6 +198,8 @@ export interface MeetingMinutesStore {
|
|
|
186
198
|
get_version(meeting_id: MeetingId, minutes_id: MinutesId, version_id: MinutesVersionId, context: MeetingMinutesRequestContext): Promise<MinutesVersionRecord>;
|
|
187
199
|
save_version(input: SaveMinutesVersionInput, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
|
|
188
200
|
confirm_version(input: ConfirmMinutesVersionInput, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
|
|
201
|
+
/** Takes a document back from its readers (story-meeting-minutes-withdraw-v1). Nothing is deleted. */
|
|
202
|
+
withdraw_minutes(input: WithdrawMinutesInput, context: MeetingMinutesRequestContext): Promise<MeetingMinutesDetail>;
|
|
189
203
|
}
|
|
190
204
|
/**
|
|
191
205
|
* Provider-neutral exact-version seam used by lineage and other read-only
|
package/dist/meeting-minutes.js
CHANGED
|
@@ -289,6 +289,12 @@ function assertSnapshotShape(value) {
|
|
|
289
289
|
checkDate(raw.updated_at, `Minutes document ${minutesId}.updated_at`);
|
|
290
290
|
if (typeof raw.created_actor_id !== 'string' || !raw.created_actor_id.trim())
|
|
291
291
|
throw new MeetingMinutesError('corrupt_record', `Minutes document ${minutesId}.created_actor_id is invalid`);
|
|
292
|
+
if (raw.withdrawal !== undefined) {
|
|
293
|
+
if (!isRecord(raw.withdrawal) || typeof raw.withdrawal.actor_id !== 'string' || !raw.withdrawal.actor_id.trim()) {
|
|
294
|
+
throw new MeetingMinutesError('corrupt_record', `Minutes document ${minutesId}.withdrawal is invalid`);
|
|
295
|
+
}
|
|
296
|
+
checkDate(raw.withdrawal.withdrawn_at, `Minutes document ${minutesId}.withdrawal.withdrawn_at`);
|
|
297
|
+
}
|
|
292
298
|
}
|
|
293
299
|
const versionIds = new Set();
|
|
294
300
|
const versionById = new Map();
|
|
@@ -401,7 +407,8 @@ function assertSnapshotShape(value) {
|
|
|
401
407
|
if (typeof key !== 'string' || key.trim() === '' || key.length > 200
|
|
402
408
|
|| typeof principalId !== 'string' || principalId.trim() === ''
|
|
403
409
|
|| typeof fingerprint !== 'string' || fingerprint.trim() === '' || fingerprint.length > 512
|
|
404
|
-
|| (operation !== 'create_meeting' && operation !== 'create_minutes' && operation !== 'save_version' && operation !== 'confirm_version'
|
|
410
|
+
|| (operation !== 'create_meeting' && operation !== 'create_minutes' && operation !== 'save_version' && operation !== 'confirm_version'
|
|
411
|
+
&& operation !== 'withdraw_minutes')
|
|
405
412
|
|| typeof meetingId !== 'string' || !meetingIds.has(meetingId)) {
|
|
406
413
|
throw new MeetingMinutesError('corrupt_record', 'Idempotency record is invalid');
|
|
407
414
|
}
|
|
@@ -421,9 +428,9 @@ function assertSnapshotShape(value) {
|
|
|
421
428
|
|| documentById.get(minutesId)?.meeting_id !== meetingId) {
|
|
422
429
|
throw new MeetingMinutesError('corrupt_record', 'Idempotency record minutes_id is invalid');
|
|
423
430
|
}
|
|
424
|
-
if (operation === 'create_minutes') {
|
|
431
|
+
if (operation === 'create_minutes' || operation === 'withdraw_minutes') {
|
|
425
432
|
if (versionId !== undefined)
|
|
426
|
-
throw new MeetingMinutesError('corrupt_record',
|
|
433
|
+
throw new MeetingMinutesError('corrupt_record', `${operation} idempotency record has an unexpected version_id`);
|
|
427
434
|
continue;
|
|
428
435
|
}
|
|
429
436
|
if (typeof versionId !== 'string' || !versionIds.has(versionId)
|
|
@@ -601,7 +608,15 @@ function detail(snapshot, meeting) {
|
|
|
601
608
|
return freezeClone({ meeting, minutes, versions, snapshot_revision: snapshot.revision });
|
|
602
609
|
}
|
|
603
610
|
function summary(snapshot, meeting) {
|
|
604
|
-
|
|
611
|
+
// A withdrawn document is taken back from listings; its detail stays readable for history.
|
|
612
|
+
return freezeClone({
|
|
613
|
+
meeting,
|
|
614
|
+
minutes: snapshot.documents.filter((candidate) => candidate.meeting_id === meeting.meeting_id && !candidate.withdrawal)
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
function assertNotWithdrawn(document) {
|
|
618
|
+
if (document.withdrawal)
|
|
619
|
+
throw invalid(`Minutes document ${document.minutes_id} was withdrawn`);
|
|
605
620
|
}
|
|
606
621
|
function ensureRevision(actual, expected) {
|
|
607
622
|
if (!Number.isInteger(expected) || expected < 1)
|
|
@@ -974,6 +989,7 @@ export function createMeetingMinutesStore(options) {
|
|
|
974
989
|
const meeting = findMeeting(snapshot, document.meeting_id);
|
|
975
990
|
await authorized(authorizer, 'write', meeting, context);
|
|
976
991
|
await authorized(authorizer, 'write', document, context);
|
|
992
|
+
assertNotWithdrawn(document);
|
|
977
993
|
ensureRevision(document.revision, input.expected_revision);
|
|
978
994
|
const predecessor = input.predecessor_version_id === undefined ? document.current_version_id : nonEmptyString(input.predecessor_version_id, 'predecessor_version_id');
|
|
979
995
|
if (predecessor !== document.current_version_id)
|
|
@@ -1046,6 +1062,7 @@ export function createMeetingMinutesStore(options) {
|
|
|
1046
1062
|
const version = snapshot.versions.find((candidate) => candidate.version_id === versionId && candidate.minutes_id === minutesId);
|
|
1047
1063
|
if (!version)
|
|
1048
1064
|
throw new MeetingMinutesError('not_found', `Minutes version ${versionId} was not found`);
|
|
1065
|
+
assertNotWithdrawn(document);
|
|
1049
1066
|
ensureRevision(document.revision, input.expected_revision);
|
|
1050
1067
|
if (version.confirmation) {
|
|
1051
1068
|
if (!idempotency.token)
|
|
@@ -1102,7 +1119,52 @@ export function createMeetingMinutesStore(options) {
|
|
|
1102
1119
|
throw new MeetingMinutesError('readback_mismatch', 'Confirmation did not read back');
|
|
1103
1120
|
return detailForCaller(readback, savedMeeting, context);
|
|
1104
1121
|
}
|
|
1105
|
-
|
|
1122
|
+
async function withdraw_minutes(input, context) {
|
|
1123
|
+
const principal = assertPrincipal(context);
|
|
1124
|
+
if (!isRecord(input))
|
|
1125
|
+
throw invalid('withdrawal input must be an object');
|
|
1126
|
+
const minutesId = nonEmptyString(input.minutes_id, 'minutes_id');
|
|
1127
|
+
const snapshot = await readSnapshot();
|
|
1128
|
+
const idempotency = await resolveIdempotency(snapshot, principal, input, 'withdraw_minutes', context, { minutes_id: minutesId });
|
|
1129
|
+
if (idempotency.replay)
|
|
1130
|
+
return idempotency.replay;
|
|
1131
|
+
const document = findDocument(snapshot, minutesId);
|
|
1132
|
+
const meeting = findMeeting(snapshot, document.meeting_id);
|
|
1133
|
+
await authorized(authorizer, 'write', meeting, context);
|
|
1134
|
+
await authorized(authorizer, 'write', document, context);
|
|
1135
|
+
// Withdrawing twice keeps the first record; a retry is not a second withdrawal.
|
|
1136
|
+
if (document.withdrawal && !idempotency.token)
|
|
1137
|
+
return detailForCaller(snapshot, meeting, context);
|
|
1138
|
+
if (!document.withdrawal)
|
|
1139
|
+
ensureRevision(document.revision, input.expected_revision);
|
|
1140
|
+
const timestamp = isoNow(now);
|
|
1141
|
+
const next = snapshotMutable(snapshot);
|
|
1142
|
+
next.revision += 1;
|
|
1143
|
+
if (!document.withdrawal) {
|
|
1144
|
+
next.documents = next.documents.map((candidate) => candidate.minutes_id === minutesId
|
|
1145
|
+
? { ...candidate, withdrawal: { actor_id: principal, withdrawn_at: timestamp }, updated_at: timestamp, revision: candidate.revision + 1 }
|
|
1146
|
+
: candidate);
|
|
1147
|
+
}
|
|
1148
|
+
addIdempotencyRecord(next, idempotency.token, 'withdraw_minutes', {
|
|
1149
|
+
meeting_id: meeting.meeting_id,
|
|
1150
|
+
minutes_id: minutesId
|
|
1151
|
+
}, principal);
|
|
1152
|
+
let readback;
|
|
1153
|
+
try {
|
|
1154
|
+
readback = await writeSnapshot(next, snapshot.revision);
|
|
1155
|
+
}
|
|
1156
|
+
catch (error) {
|
|
1157
|
+
const replay = await replayAfterConflict(error, idempotency.token, principal, 'withdraw_minutes', context, { minutes_id: minutesId });
|
|
1158
|
+
if (replay)
|
|
1159
|
+
return replay;
|
|
1160
|
+
throw error;
|
|
1161
|
+
}
|
|
1162
|
+
const saved = findDocument(readback, minutesId);
|
|
1163
|
+
if (!saved.withdrawal)
|
|
1164
|
+
throw new MeetingMinutesError('readback_mismatch', 'Withdrawal did not read back');
|
|
1165
|
+
return detailForCaller(readback, findMeeting(readback, meeting.meeting_id), context);
|
|
1166
|
+
}
|
|
1167
|
+
return { list_meetings, create_meeting, create_minutes, get_meeting, get_version, save_version, confirm_version, withdraw_minutes };
|
|
1106
1168
|
}
|
|
1107
1169
|
function participantIdsInput(value) {
|
|
1108
1170
|
return participantIds(value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unson/brainbase-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
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",
|
|
@@ -479,5 +479,5 @@
|
|
|
479
479
|
"engines": {
|
|
480
480
|
"node": ">=20"
|
|
481
481
|
},
|
|
482
|
-
"gitHead": "
|
|
482
|
+
"gitHead": "f7389b6d15e12a3fb7312d305be6f6f9660e8c79"
|
|
483
483
|
}
|