@unson/brainbase-mcp 0.49.0 → 0.50.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/contracts/brainbase-public-contract.v1.json +288 -0
- package/dist/meeting-source-connection.d.ts +33 -1
- package/dist/meeting-source-connection.js +124 -1
- package/dist/meeting-source-reader.d.ts +9 -0
- package/dist/meeting-source-reader.js +10 -3
- package/dist/ownership-survey.d.ts +28 -0
- package/dist/ownership-survey.js +60 -0
- package/dist/queue-task-tools.d.ts +114 -0
- package/dist/queue-task-tools.js +263 -0
- package/dist/testing/queue-task-reference-backend.d.ts +43 -0
- package/dist/testing/queue-task-reference-backend.js +157 -0
- package/dist/testing/queue-task-tools-contract.d.ts +33 -0
- package/dist/testing/queue-task-tools-contract.js +487 -0
- package/package.json +21 -5
- package/ui/area-nav.css +23 -13
- package/ui/area-nav.js +15 -1
- package/ui/judgment-history.js +0 -15
- package/ui/meeting-minutes.js +1 -1
- package/ui/world/world-canvas-ui.js +25 -5
- package/ui/world/world-view.css +58 -0
- package/ui/world/world-view.js +43 -14
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { queueTaskToolDefinitions, QUEUE_TASK_TOOL_NAMES } from '../queue-task-tools.js';
|
|
2
|
+
import { createQueueReferenceSeed, QUEUE_REFERENCE_CODES as C, } from './queue-task-reference-backend.js';
|
|
3
|
+
export const QUEUE_TASK_CONTRACT_SCENARIO_NAMES = [
|
|
4
|
+
'AC-2 reads only visible tasks and forwards opaque cursors one page per call',
|
|
5
|
+
'AC-2 reads an approved task by id',
|
|
6
|
+
'AC-3 binds every call and replay to the authenticated agent',
|
|
7
|
+
'AC-4 claims next and renews without duplicate claims',
|
|
8
|
+
'AC-4 claims an approved task by id without duplicates',
|
|
9
|
+
'AC-5 attaches evidence once for the same operation',
|
|
10
|
+
'AC-6 completes through queue status without bypassing gates',
|
|
11
|
+
'AC-7 validates inputs before calling the queue backend',
|
|
12
|
+
'AC-8 preserves structured failures without leaking credentials',
|
|
13
|
+
'AC-9 advertises conservative queue tool annotations',
|
|
14
|
+
];
|
|
15
|
+
export { createQueueReferenceBackend, createQueueReferenceSeed, QUEUE_REFERENCE_CODES, } from './queue-task-reference-backend.js';
|
|
16
|
+
export async function runQueueTaskContractScenario(name, adapter, assert) {
|
|
17
|
+
const steps = [];
|
|
18
|
+
const connections = [];
|
|
19
|
+
async function connect(state = createQueueReferenceSeed(), agent = { agentId: 'A', credential: 'credential-sentinel' }, generatedKeys = ['generated-1', 'generated-2', 'generated-3', 'generated-4']) {
|
|
20
|
+
const c = await adapter.connect({
|
|
21
|
+
state,
|
|
22
|
+
agent,
|
|
23
|
+
sharedServiceToken: 'shared-sentinel',
|
|
24
|
+
generatedKeys,
|
|
25
|
+
});
|
|
26
|
+
connections.push(c);
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
async function call(c, n, args, code) {
|
|
30
|
+
const r = await c.callTool(n, args);
|
|
31
|
+
assert.equal(r.content[0].type, 'text');
|
|
32
|
+
assert.equal(r.structuredContent, undefined);
|
|
33
|
+
const text = r.content[0].text;
|
|
34
|
+
assert.ok(!text.includes('credential-sentinel'));
|
|
35
|
+
assert.ok(!text.includes('exception-sentinel'));
|
|
36
|
+
assert.ok(!text.includes('shared-sentinel'));
|
|
37
|
+
const v = JSON.parse(text);
|
|
38
|
+
assert.equal(!!r.isError, v.status !== 'ok');
|
|
39
|
+
if (code)
|
|
40
|
+
assert.equal(v.error?.code, code);
|
|
41
|
+
else
|
|
42
|
+
assert.equal(v.status, 'ok');
|
|
43
|
+
steps.push(v);
|
|
44
|
+
return v.queue;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const c = await connect();
|
|
48
|
+
const index = QUEUE_TASK_CONTRACT_SCENARIO_NAMES.indexOf(name);
|
|
49
|
+
if (index === 0) {
|
|
50
|
+
const p = await call(c, 'list_my_tasks', { limit: 2 });
|
|
51
|
+
assert.equal(p.items.length, 2);
|
|
52
|
+
assert.ok(p.next_cursor);
|
|
53
|
+
const q = await call(c, 'list_my_tasks', { cursor: p.next_cursor, limit: 2 });
|
|
54
|
+
assert.equal(q.items.length, 1);
|
|
55
|
+
assert.equal(q.next_cursor, null);
|
|
56
|
+
await call(c, 'list_my_tasks', { statuses: ['pending'] });
|
|
57
|
+
const s = await c.snapshot();
|
|
58
|
+
assert.equal(s.calls.length, 3);
|
|
59
|
+
assert.equal(s.calls[1].input.cursor, p.next_cursor);
|
|
60
|
+
assert.ok(!JSON.stringify(steps).includes('synthetic-task-4'));
|
|
61
|
+
const empty = await connect(s, { agentId: 'Z', credential: 'agent-credential-sentinel' });
|
|
62
|
+
assert.deepEqual(await call(empty, 'list_my_tasks', {}), { items: [], next_cursor: null });
|
|
63
|
+
}
|
|
64
|
+
else if (index === 1) {
|
|
65
|
+
const q = await call(c, 'get_task', { task_id: 't1' });
|
|
66
|
+
assert.equal(q.task.title, 'synthetic-task-1');
|
|
67
|
+
assert.equal(q.task.version, 1);
|
|
68
|
+
await call(c, 'get_task', { task_id: 't4' }, C.agent_scope_denied);
|
|
69
|
+
await call(c, 'get_task', { task_id: 'missing' }, C.task_not_found);
|
|
70
|
+
for (const x of (await c.snapshot()).calls) {
|
|
71
|
+
assert.equal(x.operation, 'get');
|
|
72
|
+
assert.equal(x.agentId, 'A');
|
|
73
|
+
assert.deepEqual(Object.keys(x.input), ['task_id']);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (index === 2) {
|
|
77
|
+
const args = [
|
|
78
|
+
{},
|
|
79
|
+
{ task_id: 't1' },
|
|
80
|
+
{ task_id: 't1' },
|
|
81
|
+
{},
|
|
82
|
+
{ task_id: 't1' },
|
|
83
|
+
{ task_id: 't1', expected_version: 1, kind: 'ci', ref: {} },
|
|
84
|
+
{ task_id: 't1', expected_version: 1, to_status: 'done' },
|
|
85
|
+
];
|
|
86
|
+
for (const agent of [
|
|
87
|
+
null,
|
|
88
|
+
{ agentId: 'A', credential: '' },
|
|
89
|
+
{ agentId: 'A', credential: ' ' },
|
|
90
|
+
]) {
|
|
91
|
+
const x = await connect(createQueueReferenceSeed(), agent);
|
|
92
|
+
for (let i = 0; i < 7; i++) {
|
|
93
|
+
await call(x, QUEUE_TASK_TOOL_NAMES[i], args[i], 'task_auth_unavailable');
|
|
94
|
+
if (i >= 2)
|
|
95
|
+
assert.deepEqual(steps.at(-1).error.details, { outcome: 'not_sent' });
|
|
96
|
+
}
|
|
97
|
+
assert.equal((await x.snapshot()).calls.length, 0);
|
|
98
|
+
}
|
|
99
|
+
for (const field of ['agent_id', 'assignee', 'scope'])
|
|
100
|
+
await call(c, 'claim_next', { [field]: '*' }, 'task_input_invalid');
|
|
101
|
+
assert.equal((await c.snapshot()).calls.length, 0);
|
|
102
|
+
await call(c, 'claim_next', { idempotency_key: 'k' });
|
|
103
|
+
const s = await c.snapshot();
|
|
104
|
+
assert.ok(s.calls.every((x) => x.agentId === 'A' && x.credentialMatchesAgent));
|
|
105
|
+
const b = await connect(s, { agentId: 'B', credential: 'agent-credential-sentinel' });
|
|
106
|
+
const q = await call(b, 'claim_next', { idempotency_key: 'k' });
|
|
107
|
+
assert.equal(q.task.id, 't4');
|
|
108
|
+
assert.ok((await b.snapshot()).calls.every((x) => x.credentialMatchesAgent));
|
|
109
|
+
s.tasks.forEach((t) => {
|
|
110
|
+
t.assignee = 'B';
|
|
111
|
+
});
|
|
112
|
+
const revoked = await connect(s);
|
|
113
|
+
await call(revoked, 'claim_next', { idempotency_key: 'k' }, C.agent_scope_denied);
|
|
114
|
+
}
|
|
115
|
+
else if (index === 3 || index === 4) {
|
|
116
|
+
const tool = index === 3 ? 'claim_next' : 'claim_task';
|
|
117
|
+
const args = index === 3 ? { idempotency_key: 'k' } : { task_id: 't1', idempotency_key: 'k' };
|
|
118
|
+
const q = await call(c, tool, args);
|
|
119
|
+
assert.equal(q.replayed, false);
|
|
120
|
+
assert.ok(q.claimed_until);
|
|
121
|
+
assert.equal(q.renew_interval_minutes, 10);
|
|
122
|
+
const replay = await call(c, tool, args);
|
|
123
|
+
assert.equal(replay.task.id, q.task.id);
|
|
124
|
+
assert.equal(replay.replayed, true);
|
|
125
|
+
assert.equal(Object.keys((await c.snapshot()).claims).length, 1);
|
|
126
|
+
if (index === 4) {
|
|
127
|
+
assert.deepEqual((await c.snapshot()).calls[0].input, {
|
|
128
|
+
mode: 'by_id',
|
|
129
|
+
task_id: 't1',
|
|
130
|
+
idempotency_key: 'k',
|
|
131
|
+
});
|
|
132
|
+
await call(c, tool, { task_id: 't2', idempotency_key: 'k' }, C.idempotency_conflict);
|
|
133
|
+
await call(c, tool, { task_id: 't4' }, C.agent_scope_denied);
|
|
134
|
+
const s = await c.snapshot();
|
|
135
|
+
s.claims.t2 = { agent: 'B', claimed_until: q.claimed_until };
|
|
136
|
+
const x = await connect(s);
|
|
137
|
+
await call(x, tool, { task_id: 't2' }, C.claim_not_held);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
await call(c, tool, {});
|
|
141
|
+
await call(c, tool, {});
|
|
142
|
+
const s = await c.snapshot();
|
|
143
|
+
assert.equal(s.calls[2].input.idempotency_key, 'mcp:generated-1');
|
|
144
|
+
assert.equal(s.calls[3].input.idempotency_key, 'mcp:generated-2');
|
|
145
|
+
assert.equal((await call(c, tool, {})).status, 'no_claimable_task');
|
|
146
|
+
const renewed = await call(c, 'renew_claim', { task_id: 't1', idempotency_key: 'renew' });
|
|
147
|
+
assert.ok(renewed.claimed_until > q.claimed_until);
|
|
148
|
+
assert.equal((await c.snapshot()).claims.t1.claimed_until, renewed.claimed_until);
|
|
149
|
+
await call(c, 'renew_claim', { task_id: 't4' }, C.agent_scope_denied);
|
|
150
|
+
await call(c, 'renew_claim', { task_id: 't2', idempotency_key: 'renew' }, C.idempotency_conflict);
|
|
151
|
+
const competing = createQueueReferenceSeed();
|
|
152
|
+
competing.claims.t1 = { agent: 'B', claimed_until: q.claimed_until };
|
|
153
|
+
const competitor = await connect(competing);
|
|
154
|
+
const next = await call(competitor, 'claim_next', {});
|
|
155
|
+
assert.equal(next.task.id, 't2');
|
|
156
|
+
assert.equal((await competitor.snapshot()).claims.t1.agent, 'B');
|
|
157
|
+
const unclaimed = await connect();
|
|
158
|
+
await call(unclaimed, 'renew_claim', { task_id: 't1' }, C.claim_not_held);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (index === 5 || index === 6) {
|
|
162
|
+
await call(c, 'claim_task', { task_id: 't1' });
|
|
163
|
+
let version = 1;
|
|
164
|
+
if (index === 6) {
|
|
165
|
+
await call(c, 'update_status', {
|
|
166
|
+
task_id: 't1',
|
|
167
|
+
expected_version: version++,
|
|
168
|
+
to_status: 'started',
|
|
169
|
+
idempotency_key: 'start',
|
|
170
|
+
});
|
|
171
|
+
const before = (await c.snapshot()).calls.length;
|
|
172
|
+
await call(c, 'update_status', { task_id: 't1', expected_version: version, to_status: 'blocked' }, 'task_input_invalid');
|
|
173
|
+
assert.equal((await c.snapshot()).calls.length, before);
|
|
174
|
+
await call(c, 'update_status', {
|
|
175
|
+
task_id: 't1',
|
|
176
|
+
expected_version: version++,
|
|
177
|
+
to_status: 'blocked',
|
|
178
|
+
waiting_on: 'synthetic dependency',
|
|
179
|
+
});
|
|
180
|
+
await call(c, 'update_status', { task_id: 't1', expected_version: version, to_status: 'done', waiting_on: 'x' }, 'task_input_invalid');
|
|
181
|
+
await call(c, 'update_status', { task_id: 't1', expected_version: version, to_status: 'done' }, C.completion_gate_unmet);
|
|
182
|
+
await call(c, 'update_status', { task_id: 't1', expected_version: 1, to_status: 'started' }, C.version_conflict);
|
|
183
|
+
}
|
|
184
|
+
for (const kind of ['pull_request', 'ci', 'production_readback']) {
|
|
185
|
+
const args = {
|
|
186
|
+
task_id: 't1',
|
|
187
|
+
expected_version: version,
|
|
188
|
+
kind,
|
|
189
|
+
ref: { a: 1, b: 2 },
|
|
190
|
+
idempotency_key: `e-${kind}`,
|
|
191
|
+
};
|
|
192
|
+
const q = await call(c, 'attach_evidence', args);
|
|
193
|
+
assert.equal(q.task.version, ++version);
|
|
194
|
+
assert.deepEqual(await call(c, 'attach_evidence', { ...args, ref: { b: 2, a: 1 } }), q);
|
|
195
|
+
await call(c, 'attach_evidence', { ...args, ref: { a: 2 } }, C.idempotency_conflict);
|
|
196
|
+
}
|
|
197
|
+
assert.equal((await c.snapshot()).evidence.length, 3);
|
|
198
|
+
await call(c, 'attach_evidence', { task_id: 't1', expected_version: 1, kind: 'ci', ref: {} }, C.version_conflict);
|
|
199
|
+
await call(c, 'attach_evidence', { task_id: 't2', expected_version: 1, kind: 'ci', ref: {} }, C.claim_not_held);
|
|
200
|
+
if (index === 6) {
|
|
201
|
+
const args = {
|
|
202
|
+
task_id: 't1',
|
|
203
|
+
expected_version: version,
|
|
204
|
+
to_status: 'done',
|
|
205
|
+
idempotency_key: 'done',
|
|
206
|
+
};
|
|
207
|
+
const q = await call(c, 'update_status', args);
|
|
208
|
+
assert.equal(q.task.status, 'completed');
|
|
209
|
+
assert.deepEqual(await call(c, 'update_status', args), q);
|
|
210
|
+
await call(c, 'update_status', { ...args, idempotency_key: 'done-again' }, C.task_already_completed);
|
|
211
|
+
const s = await c.snapshot();
|
|
212
|
+
assert.equal(s.completions.length, 1);
|
|
213
|
+
assert.equal(s.audit.length, 1);
|
|
214
|
+
assert.equal(s.tasks[0].version, version + 1);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (index === 7) {
|
|
218
|
+
const valid = [
|
|
219
|
+
{},
|
|
220
|
+
{ task_id: 't1' },
|
|
221
|
+
{ task_id: 't1' },
|
|
222
|
+
{},
|
|
223
|
+
{ task_id: 't1' },
|
|
224
|
+
{ task_id: 't1', expected_version: 1, kind: 'ci', ref: {} },
|
|
225
|
+
{ task_id: 't1', expected_version: 1, to_status: 'started' },
|
|
226
|
+
];
|
|
227
|
+
for (let i = 0; i < 7; i++) {
|
|
228
|
+
await call(c, QUEUE_TASK_TOOL_NAMES[i], { ...valid[i], unknown: true }, 'task_input_invalid');
|
|
229
|
+
await call(c, QUEUE_TASK_TOOL_NAMES[i], { task_id: 7 }, 'task_input_invalid');
|
|
230
|
+
if (i !== 0 && i !== 3)
|
|
231
|
+
await call(c, QUEUE_TASK_TOOL_NAMES[i], {}, 'task_input_invalid');
|
|
232
|
+
}
|
|
233
|
+
for (let i = 0; i < 7; i++) {
|
|
234
|
+
const required = queueTaskToolDefinitions[i].inputSchema.required ?? [];
|
|
235
|
+
for (const field of required) {
|
|
236
|
+
const missing = { ...valid[i] };
|
|
237
|
+
delete missing[field];
|
|
238
|
+
await call(c, QUEUE_TASK_TOOL_NAMES[i], missing, 'task_input_invalid');
|
|
239
|
+
await call(c, QUEUE_TASK_TOOL_NAMES[i], { ...valid[i], [field]: false }, 'task_input_invalid');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
for (const task_id of ['', ' ', '😀'.repeat(257)])
|
|
243
|
+
await call(c, 'get_task', { task_id }, 'task_input_invalid');
|
|
244
|
+
for (const limit of [0, 51, 1.5])
|
|
245
|
+
await call(c, 'list_my_tasks', { limit }, 'task_input_invalid');
|
|
246
|
+
await call(c, 'list_my_tasks', { statuses: ['unknown'] }, 'task_input_invalid');
|
|
247
|
+
for (const expected_version of [0, -1, 1.2])
|
|
248
|
+
await call(c, 'attach_evidence', { ...valid[5], expected_version }, 'task_input_invalid');
|
|
249
|
+
for (const ref of [[], null, 'text'])
|
|
250
|
+
await call(c, 'attach_evidence', { ...valid[5], ref }, 'task_input_invalid');
|
|
251
|
+
await call(c, 'attach_evidence', { ...valid[5], kind: 'unknown' }, 'task_input_invalid');
|
|
252
|
+
for (const waiting_on of [' ', 'x'.repeat(2001)])
|
|
253
|
+
await call(c, 'update_status', { ...valid[6], to_status: 'blocked', waiting_on }, 'task_input_invalid');
|
|
254
|
+
for (const idempotency_key of [' ', 'api:x', 'workflow:x'])
|
|
255
|
+
await call(c, 'claim_next', { idempotency_key }, 'task_input_invalid');
|
|
256
|
+
assert.equal((await c.snapshot()).calls.length, 0);
|
|
257
|
+
for (const task_id of ['😀'.repeat(256), 'a/b'])
|
|
258
|
+
await call(c, 'get_task', { task_id }, C.task_not_found);
|
|
259
|
+
for (const limit of [1, 50])
|
|
260
|
+
await call(c, 'list_my_tasks', { limit });
|
|
261
|
+
await call(c, 'claim_task', { task_id: 't1' });
|
|
262
|
+
await call(c, 'update_status', {
|
|
263
|
+
...valid[6],
|
|
264
|
+
to_status: 'blocked',
|
|
265
|
+
waiting_on: 'x'.repeat(2000),
|
|
266
|
+
});
|
|
267
|
+
const s = await c.snapshot();
|
|
268
|
+
assert.equal(s.calls[0].input.task_id, '😀'.repeat(256));
|
|
269
|
+
assert.equal(s.calls[1].input.task_id, 'a/b');
|
|
270
|
+
assert.equal(s.calls[4].input.mode, 'by_id');
|
|
271
|
+
}
|
|
272
|
+
else if (index === 8) {
|
|
273
|
+
const keyFailure = await connect(createQueueReferenceSeed(), undefined, ['invalid/key']);
|
|
274
|
+
await call(keyFailure, 'claim_next', {}, 'task_contract_error');
|
|
275
|
+
assert.deepEqual(steps.at(-1).error.details, { outcome: 'not_sent' });
|
|
276
|
+
assert.equal((await keyFailure.snapshot()).calls.length, 0);
|
|
277
|
+
const cases = [
|
|
278
|
+
...['get_task', 'claim_next'].flatMap((tool) => [
|
|
279
|
+
{
|
|
280
|
+
tool,
|
|
281
|
+
result: {
|
|
282
|
+
status: 'error',
|
|
283
|
+
error: {
|
|
284
|
+
code: 'synthetic_denied',
|
|
285
|
+
message: 'denied',
|
|
286
|
+
details: { body: { auth: 'credential-sentinel' } },
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
code: 'task_contract_error',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
tool,
|
|
293
|
+
result: {
|
|
294
|
+
status: 'error',
|
|
295
|
+
error: { code: 'synthetic_denied', message: 'credential-sentinel' },
|
|
296
|
+
},
|
|
297
|
+
code: 'task_contract_error',
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
tool,
|
|
301
|
+
result: {
|
|
302
|
+
status: 'unavailable',
|
|
303
|
+
error: {
|
|
304
|
+
code: 'unexpected',
|
|
305
|
+
message: 'unavailable',
|
|
306
|
+
details: { outcome: 'unknown' },
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
code: 'task_contract_error',
|
|
310
|
+
},
|
|
311
|
+
]),
|
|
312
|
+
{ tool: 'claim_next', result: null, code: 'task_contract_error' },
|
|
313
|
+
{
|
|
314
|
+
tool: 'get_task',
|
|
315
|
+
result: {
|
|
316
|
+
status: 'error',
|
|
317
|
+
error: {
|
|
318
|
+
code: 'synthetic_denied',
|
|
319
|
+
message: 'denied',
|
|
320
|
+
http_status: 409,
|
|
321
|
+
details: { reason: 'synthetic' },
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
code: 'synthetic_denied',
|
|
325
|
+
},
|
|
326
|
+
...['not_sent', 'unknown'].map((outcome) => ({
|
|
327
|
+
tool: 'claim_next',
|
|
328
|
+
result: {
|
|
329
|
+
status: 'unavailable',
|
|
330
|
+
error: { code: 'task_api_unavailable', message: 'unavailable', details: { outcome } },
|
|
331
|
+
},
|
|
332
|
+
code: 'task_api_unavailable',
|
|
333
|
+
})),
|
|
334
|
+
{
|
|
335
|
+
tool: 'claim_next',
|
|
336
|
+
result: {
|
|
337
|
+
status: 'unavailable',
|
|
338
|
+
error: { code: 'task_api_unavailable', message: 'unavailable' },
|
|
339
|
+
},
|
|
340
|
+
code: 'task_contract_error',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
tool: 'claim_next',
|
|
344
|
+
result: {
|
|
345
|
+
status: 'unavailable',
|
|
346
|
+
error: {
|
|
347
|
+
code: 'task_auth_unavailable',
|
|
348
|
+
message: 'unavailable',
|
|
349
|
+
details: { outcome: 'unknown' },
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
code: 'task_auth_unavailable',
|
|
353
|
+
},
|
|
354
|
+
...['throw', 'reject'].map((type) => ({
|
|
355
|
+
tool: 'claim_next',
|
|
356
|
+
type,
|
|
357
|
+
code: 'task_api_unavailable',
|
|
358
|
+
})),
|
|
359
|
+
...[
|
|
360
|
+
{ items: [] },
|
|
361
|
+
{ items: [{ id: 't1', version: 0, status: 'pending' }], next_cursor: null },
|
|
362
|
+
null,
|
|
363
|
+
].map((queue) => ({
|
|
364
|
+
tool: 'list_my_tasks',
|
|
365
|
+
result: { status: 'ok', queue },
|
|
366
|
+
code: 'task_contract_error',
|
|
367
|
+
})),
|
|
368
|
+
{
|
|
369
|
+
tool: 'claim_next',
|
|
370
|
+
result: { status: 'ok', queue: { status: 'unknown' } },
|
|
371
|
+
code: 'task_contract_error',
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
tool: 'renew_claim',
|
|
375
|
+
result: { status: 'ok', queue: { task: { id: 't1', version: 1, status: 'pending' } } },
|
|
376
|
+
code: 'task_contract_error',
|
|
377
|
+
},
|
|
378
|
+
...[{ code: 'x' }, { code: 1, message: 'x' }].map((error) => ({
|
|
379
|
+
tool: 'claim_next',
|
|
380
|
+
result: { status: 'error', error },
|
|
381
|
+
code: 'task_contract_error',
|
|
382
|
+
})),
|
|
383
|
+
];
|
|
384
|
+
for (const test of cases) {
|
|
385
|
+
const state = createQueueReferenceSeed();
|
|
386
|
+
state.scripted = [{ at: 1, type: test.type ?? 'result', result: test.result }];
|
|
387
|
+
const x = await connect(state);
|
|
388
|
+
await call(x, test.tool, test.tool === 'get_task' || test.tool === 'renew_claim' ? { task_id: 't1' } : {}, test.code);
|
|
389
|
+
const last = steps.at(-1);
|
|
390
|
+
if (test.result &&
|
|
391
|
+
test.result.status !== 'ok' &&
|
|
392
|
+
test.code !== 'task_contract_error')
|
|
393
|
+
assert.deepEqual(last, test.result);
|
|
394
|
+
if ((test.type || test.code === 'task_contract_error') &&
|
|
395
|
+
test.tool !== 'list_my_tasks' &&
|
|
396
|
+
test.tool !== 'get_task')
|
|
397
|
+
assert.deepEqual(last.error.details, { outcome: 'unknown' });
|
|
398
|
+
assert.equal((await x.snapshot()).calls.length, 1);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
const tools = await c.listTools();
|
|
403
|
+
assert.deepEqual(tools, queueTaskToolDefinitions);
|
|
404
|
+
assert.deepEqual(tools.map((t) => t.name), QUEUE_TASK_TOOL_NAMES);
|
|
405
|
+
const expectedAnnotations = {
|
|
406
|
+
list_my_tasks: {
|
|
407
|
+
readOnlyHint: true,
|
|
408
|
+
destructiveHint: false,
|
|
409
|
+
idempotentHint: true,
|
|
410
|
+
openWorldHint: true,
|
|
411
|
+
},
|
|
412
|
+
get_task: {
|
|
413
|
+
readOnlyHint: true,
|
|
414
|
+
destructiveHint: false,
|
|
415
|
+
idempotentHint: true,
|
|
416
|
+
openWorldHint: true,
|
|
417
|
+
},
|
|
418
|
+
claim_task: {
|
|
419
|
+
readOnlyHint: false,
|
|
420
|
+
destructiveHint: true,
|
|
421
|
+
idempotentHint: false,
|
|
422
|
+
openWorldHint: true,
|
|
423
|
+
},
|
|
424
|
+
claim_next: {
|
|
425
|
+
readOnlyHint: false,
|
|
426
|
+
destructiveHint: true,
|
|
427
|
+
idempotentHint: false,
|
|
428
|
+
openWorldHint: true,
|
|
429
|
+
},
|
|
430
|
+
renew_claim: {
|
|
431
|
+
readOnlyHint: false,
|
|
432
|
+
destructiveHint: true,
|
|
433
|
+
idempotentHint: false,
|
|
434
|
+
openWorldHint: true,
|
|
435
|
+
},
|
|
436
|
+
attach_evidence: {
|
|
437
|
+
readOnlyHint: false,
|
|
438
|
+
destructiveHint: true,
|
|
439
|
+
idempotentHint: false,
|
|
440
|
+
openWorldHint: true,
|
|
441
|
+
},
|
|
442
|
+
update_status: {
|
|
443
|
+
readOnlyHint: false,
|
|
444
|
+
destructiveHint: true,
|
|
445
|
+
idempotentHint: false,
|
|
446
|
+
openWorldHint: true,
|
|
447
|
+
},
|
|
448
|
+
};
|
|
449
|
+
for (let i = 0; i < tools.length; i++) {
|
|
450
|
+
assert.deepEqual(tools[i].annotations, expectedAnnotations[tools[i].name]);
|
|
451
|
+
assert.equal(tools[i].inputSchema.additionalProperties, false);
|
|
452
|
+
for (const key of ['agent_id', 'assignee', 'principal', 'scope', 'token', 'api_url'])
|
|
453
|
+
assert.ok(!(key in (tools[i].inputSchema.properties ?? {})));
|
|
454
|
+
}
|
|
455
|
+
assert.deepEqual(tools.map((t) => t.inputSchema.required), [
|
|
456
|
+
[],
|
|
457
|
+
['task_id'],
|
|
458
|
+
['task_id'],
|
|
459
|
+
[],
|
|
460
|
+
['task_id'],
|
|
461
|
+
['task_id', 'expected_version', 'kind', 'ref'],
|
|
462
|
+
['task_id', 'expected_version', 'to_status'],
|
|
463
|
+
]);
|
|
464
|
+
const properties = tools.map((t) => t.inputSchema.properties);
|
|
465
|
+
assert.deepEqual(properties[0].statuses.items.enum, [
|
|
466
|
+
'pending',
|
|
467
|
+
'in_progress',
|
|
468
|
+
'waiting',
|
|
469
|
+
'completed',
|
|
470
|
+
'cancelled',
|
|
471
|
+
]);
|
|
472
|
+
assert.deepEqual(properties[5].kind.enum, ['pull_request', 'ci', 'production_readback']);
|
|
473
|
+
assert.deepEqual(properties[6].to_status.enum, [
|
|
474
|
+
'started',
|
|
475
|
+
'waiting_for_review',
|
|
476
|
+
'blocked',
|
|
477
|
+
'done',
|
|
478
|
+
]);
|
|
479
|
+
steps.push(tools);
|
|
480
|
+
}
|
|
481
|
+
steps.push(await c.snapshot());
|
|
482
|
+
return { scenario: name, steps };
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
await Promise.all(connections.map((c) => c.close()));
|
|
486
|
+
}
|
|
487
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unson/brainbase-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.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",
|
|
@@ -540,7 +540,20 @@
|
|
|
540
540
|
"import": "./dist/private-philosophy-graph.js"
|
|
541
541
|
},
|
|
542
542
|
"./ui/native-scrollbars": "./ui/native-scrollbars.js",
|
|
543
|
-
"./ui/native-scrollbars.css": "./ui/native-scrollbars.css"
|
|
543
|
+
"./ui/native-scrollbars.css": "./ui/native-scrollbars.css",
|
|
544
|
+
"./queue-task-tools": {
|
|
545
|
+
"types": "./dist/queue-task-tools.d.ts",
|
|
546
|
+
"import": "./dist/queue-task-tools.js"
|
|
547
|
+
},
|
|
548
|
+
"./testing/queue-task-tools-contract": {
|
|
549
|
+
"types": "./dist/testing/queue-task-tools-contract.d.ts",
|
|
550
|
+
"import": "./dist/testing/queue-task-tools-contract.js"
|
|
551
|
+
},
|
|
552
|
+
"./contracts/brainbase-public-contract.v1.json": "./contracts/brainbase-public-contract.v1.json",
|
|
553
|
+
"./ownership-survey": {
|
|
554
|
+
"types": "./dist/ownership-survey.d.ts",
|
|
555
|
+
"import": "./dist/ownership-survey.js"
|
|
556
|
+
}
|
|
544
557
|
},
|
|
545
558
|
"bin": {
|
|
546
559
|
"brainbase-mcp": "dist/index.js",
|
|
@@ -601,7 +614,10 @@
|
|
|
601
614
|
"zod": "^4.6.7"
|
|
602
615
|
},
|
|
603
616
|
"overrides": {
|
|
604
|
-
"ip-address": "^10.4.0"
|
|
617
|
+
"ip-address": "^10.4.0",
|
|
618
|
+
"vitepress": {
|
|
619
|
+
"vite": "^6.4.5"
|
|
620
|
+
}
|
|
605
621
|
},
|
|
606
622
|
"devDependencies": {
|
|
607
623
|
"@electric-sql/pglite": "^0.5.8",
|
|
@@ -613,7 +629,7 @@
|
|
|
613
629
|
"tsx": "^4.19.4",
|
|
614
630
|
"typescript": "^5.8.3",
|
|
615
631
|
"vitepress": "^1.6.4",
|
|
616
|
-
"vitest": "^4.1.
|
|
632
|
+
"vitest": "^4.1.12"
|
|
617
633
|
},
|
|
618
634
|
"engines": {
|
|
619
635
|
"node": ">=20"
|
|
@@ -628,5 +644,5 @@
|
|
|
628
644
|
"url": "https://github.com/Unson-LLC/brainbase/issues"
|
|
629
645
|
},
|
|
630
646
|
"homepage": "https://github.com/Unson-LLC/brainbase#readme",
|
|
631
|
-
"gitHead": "
|
|
647
|
+
"gitHead": "4e2b7f753300d797a8b44ef53b8fbb83c09aca3e"
|
|
632
648
|
}
|
package/ui/area-nav.css
CHANGED
|
@@ -9,45 +9,55 @@
|
|
|
9
9
|
flex: 1 1 auto;
|
|
10
10
|
display: flex;
|
|
11
11
|
flex-direction: column;
|
|
12
|
-
gap: 2px;
|
|
12
|
+
gap: var(--bb-area-nav-gap, 2px);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.bb-area-section {
|
|
16
|
+
display: grid;
|
|
17
|
+
gap: var(--bb-area-section-gap, 2px);
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
.bb-area-section,
|
|
16
20
|
.bb-area-section-links {
|
|
17
21
|
display: grid;
|
|
18
|
-
gap: 2px;
|
|
22
|
+
gap: var(--bb-area-section-links-gap, 2px);
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/* Space between the groups; the footer group sits at the bottom of the nav. */
|
|
22
26
|
.bb-area-section + .bb-area-section {
|
|
23
|
-
margin-top: var(--bb-space-4);
|
|
27
|
+
margin-top: var(--bb-area-section-margin-top, var(--bb-space-4));
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
.bb-area-section.is-footer {
|
|
27
|
-
margin-top: auto;
|
|
28
|
-
padding-top: var(--bb-space-4);
|
|
31
|
+
margin-top: var(--bb-area-footer-margin-top, auto);
|
|
32
|
+
padding-top: var(--bb-area-footer-padding-top, var(--bb-space-4));
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
.bb-area-section-label {
|
|
32
|
-
padding: 0 10px 4px;
|
|
33
|
-
color: var(--bb-color-rail-muted, var(--bb-color-muted));
|
|
34
|
-
font-size: 11px;
|
|
35
|
-
font-weight: var(--bb-font-weight-medium);
|
|
36
|
-
letter-spacing: .04em;
|
|
36
|
+
padding: var(--bb-area-section-label-padding, 0 10px 4px);
|
|
37
|
+
color: var(--bb-area-section-label-color, var(--bb-color-rail-muted, var(--bb-color-muted)));
|
|
38
|
+
font-size: var(--bb-area-section-label-font-size, 11px);
|
|
39
|
+
font-weight: var(--bb-area-section-label-font-weight, var(--bb-font-weight-medium));
|
|
40
|
+
letter-spacing: var(--bb-area-section-label-letter-spacing, .04em);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
.bb-area-section-link {
|
|
40
44
|
display: flex;
|
|
41
45
|
align-items: center;
|
|
42
|
-
gap: 4px;
|
|
46
|
+
gap: var(--bb-area-section-link-gap, 4px);
|
|
43
47
|
border-radius: 6px;
|
|
44
|
-
padding-top: 4px;
|
|
48
|
+
padding-top: var(--bb-area-section-link-padding-top, 4px);
|
|
45
49
|
text-decoration: none;
|
|
46
50
|
}
|
|
47
51
|
|
|
52
|
+
.bb-area-section-icon {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
flex: 0 0 auto;
|
|
55
|
+
}
|
|
56
|
+
|
|
48
57
|
/* A heading that opens a screen says so with a chevron (not part of its name). */
|
|
49
58
|
.bb-area-section-link::after {
|
|
50
59
|
content: "›";
|
|
60
|
+
display: var(--bb-area-section-link-indicator-display, inline);
|
|
51
61
|
font-size: 13px;
|
|
52
62
|
line-height: 1;
|
|
53
63
|
}
|
package/ui/area-nav.js
CHANGED
|
@@ -97,6 +97,8 @@ export function resolveAreaTarget(area, { remembered = null, isShown = () => tru
|
|
|
97
97
|
* @param {(screenId: string, event: Event) => void} [options.onSelect]
|
|
98
98
|
* @param {(linkId: string, event: Event) => void} [options.onSelectLink] A link given by `setLinks`.
|
|
99
99
|
* @param {(area: object) => Node|null} [options.iconFor] Icon in front of an area link.
|
|
100
|
+
* @param {(section: object) => Node|null} [options.sectionIconFor] Decorative icon in front of a section heading link.
|
|
101
|
+
* @param {string} [options.sectionLinkClassName] Extra class for section heading links.
|
|
100
102
|
* @param {string} [options.linkClassName] Extra class for the area links (the host's look).
|
|
101
103
|
*/
|
|
102
104
|
export function createAreaNav({
|
|
@@ -109,6 +111,8 @@ export function createAreaNav({
|
|
|
109
111
|
onSelect,
|
|
110
112
|
onSelectLink,
|
|
111
113
|
iconFor,
|
|
114
|
+
sectionIconFor,
|
|
115
|
+
sectionLinkClassName = '',
|
|
112
116
|
linkClassName = '',
|
|
113
117
|
label = '画面',
|
|
114
118
|
} = {}) {
|
|
@@ -194,7 +198,17 @@ export function createAreaNav({
|
|
|
194
198
|
if (section) {
|
|
195
199
|
// Both forms of the heading are made once; render shows one of them.
|
|
196
200
|
group.headingText = makeElement(doc, 'div', { className: 'bb-area-section-label', text: section.label ?? '' });
|
|
197
|
-
group.headingLink = makeElement(doc, 'a', {
|
|
201
|
+
group.headingLink = makeElement(doc, 'a', {
|
|
202
|
+
className: ['bb-area-section-label bb-area-section-link', sectionLinkClassName].filter(Boolean).join(' '),
|
|
203
|
+
text: section.label ?? '',
|
|
204
|
+
});
|
|
205
|
+
const sectionIcon = sectionIconFor?.(section) ?? null;
|
|
206
|
+
if (sectionIcon) {
|
|
207
|
+
const decoration = makeElement(doc, 'span', { className: 'bb-area-section-icon', attrs: { 'aria-hidden': 'true' } });
|
|
208
|
+
decoration.append(sectionIcon);
|
|
209
|
+
group.headingLink.textContent = '';
|
|
210
|
+
group.headingLink.append(decoration, makeElement(doc, 'span', { className: 'bb-area-link-label', text: section.label ?? '' }));
|
|
211
|
+
}
|
|
198
212
|
group.headingLink.addEventListener('click', (event) => {
|
|
199
213
|
if (section.screenId) onSelect?.(section.screenId, event);
|
|
200
214
|
});
|