@unson/brainbase-mcp 0.49.1 → 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/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/judgment-history.js
CHANGED
|
@@ -1073,10 +1073,6 @@ function appendReferenceList(doc, references) {
|
|
|
1073
1073
|
if (list.children?.length) wrap.append(list);
|
|
1074
1074
|
if (bare.length) {
|
|
1075
1075
|
wrap.append(makeWorkspaceElement(doc, 'p', { className: 'bb-jh-reference-kinds', text: referenceKindCounts(bare) }));
|
|
1076
|
-
wrap.append(makeWorkspaceElement(doc, 'p', {
|
|
1077
|
-
className: 'bb-jh-reference-note',
|
|
1078
|
-
text: 'この記録には参照の名前が残っていません。どの記録かは「記録の詳細」のIDで確かめられます。',
|
|
1079
|
-
}));
|
|
1080
1076
|
}
|
|
1081
1077
|
return wrap;
|
|
1082
1078
|
}
|
|
@@ -1466,10 +1462,6 @@ function appendNormalRecordDetails(doc, record, { onCopyReference, open = false,
|
|
|
1466
1462
|
]));
|
|
1467
1463
|
const handoff = makeWorkspaceElement(doc, 'div', { className: 'bb-jh-handoff' });
|
|
1468
1464
|
handoff.append(makeWorkspaceElement(doc, 'h4', { text: '次の判断に引き継ぐ' }));
|
|
1469
|
-
handoff.append(makeWorkspaceElement(doc, 'p', {
|
|
1470
|
-
className: 'bb-jh-reference-note',
|
|
1471
|
-
text: 'この判断を別の判断の根拠として使うときに、AIへ渡す参照です。コピーしてAIとの会話に貼ります。',
|
|
1472
|
-
}));
|
|
1473
1465
|
handoff.append(appendNormalReferenceExport(doc, record, null, { onCopyReference }));
|
|
1474
1466
|
for (const event of events) handoff.append(appendNormalReferenceExport(doc, record, event, { onCopyReference }));
|
|
1475
1467
|
details.append(handoff);
|
|
@@ -1896,13 +1888,6 @@ function summaryLine(doc, aggregate, { loading = false } = {}) {
|
|
|
1896
1888
|
if (aggregate?.mode !== 'normal') return line;
|
|
1897
1889
|
line.append(makeWorkspaceElement(doc, 'span', { text: ' ・ 結果を確かめた判断 ' }));
|
|
1898
1890
|
line.append(makeWorkspaceElement(doc, Number.isInteger(confirmed) ? 'strong' : 'span', { text: Number.isInteger(confirmed) ? `${confirmed}件` : '数えられません' }));
|
|
1899
|
-
// Results are never recorded automatically; say how a person adds one.
|
|
1900
|
-
if (Number.isInteger(confirmed) && confirmed < retrieved) {
|
|
1901
|
-
line.append(makeWorkspaceElement(doc, 'span', {
|
|
1902
|
-
className: 'bb-jh-summary-note',
|
|
1903
|
-
text: ' 結果は自動では記録されません。判断を開いて「良かったか」を記録すると数えられます。',
|
|
1904
|
-
}));
|
|
1905
|
-
}
|
|
1906
1891
|
return line;
|
|
1907
1892
|
}
|
|
1908
1893
|
|
package/ui/meeting-minutes.js
CHANGED
|
@@ -1931,7 +1931,7 @@ export function createMeetingMinutesUI({
|
|
|
1931
1931
|
title: title.input.value,
|
|
1932
1932
|
...(scheduledAt ? { scheduled_at: scheduledAt } : {}),
|
|
1933
1933
|
participant_ids: participants.input.value.split(',').map((value) => value.trim()).filter(Boolean),
|
|
1934
|
-
minutes_title: minutesTitle.input.value,
|
|
1934
|
+
...(minutesTitle.input.value.trim() ? { minutes_title: minutesTitle.input.value } : {}),
|
|
1935
1935
|
initial_body: body.input.value,
|
|
1936
1936
|
};
|
|
1937
1937
|
const created = typeof createMeeting === 'function' && Array.isArray(projectOptions) ? await createMeeting(payload, projectCode) : await mutate('', payload);
|
|
@@ -7,12 +7,33 @@
|
|
|
7
7
|
|
|
8
8
|
import { workspaceNotificationCard } from '../../workspace-kit.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// Shared so the standard presentation can reuse the same sky artwork and labels
|
|
11
|
+
// (RQ-152). The icons are fixed code, never host data.
|
|
12
|
+
export const SKY_MODES = Object.freeze([
|
|
11
13
|
{ value: 'auto', label: '自動(現在時刻)', icon: '<circle cx="12" cy="12" r="8.5"/><path d="M12 7.5v5l3 1.8"/>' },
|
|
12
14
|
{ value: 'day', label: '昼', icon: '<circle cx="12" cy="12" r="5" fill="currentColor" fill-opacity=".12"/><path d="M12 2v2m0 16v2M2 12h2m16 0h2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/><path d="M10 12h.01M14 12h.01m-4 2.5q2 1.6 4 0"/>' },
|
|
13
15
|
{ value: 'dusk', label: '夕方', icon: '<path d="M5.5 13a6.5 6.5 0 0 1 13 0" fill="currentColor" fill-opacity=".12"/><path d="M12 2v2M3.5 5.5 5 7m15.5-1.5L19 7M2 13h20M3 17q3-2 6 0t6 0 6 0M6 21q3-2 6 0t6 0"/>' },
|
|
14
16
|
{ value: 'night', label: '夜', icon: '<path d="M19.5 15.5A8.5 8.5 0 0 1 8.5 4.5a8.5 8.5 0 1 0 11 11Z" fill="currentColor" fill-opacity=".12"/><path d="m18 3 .7 2.3L21 6l-2.3.7L18 9l-.7-2.3L15 6l2.3-.7ZM22 11h.01"/>' },
|
|
15
17
|
]);
|
|
18
|
+
|
|
19
|
+
/** The sky mode after `mode`, cycling in the listed order. */
|
|
20
|
+
export function nextSkyMode(mode) {
|
|
21
|
+
const index = SKY_MODES.findIndex((entry) => entry.value === mode);
|
|
22
|
+
return SKY_MODES[(Math.max(0, index) + 1) % SKY_MODES.length];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** "空:{現在}。次は{次}" — the single sky-control label, used in both presentations. */
|
|
26
|
+
export function skyModeLabel(mode) {
|
|
27
|
+
const match = SKY_MODES.find((entry) => entry.value === mode) ?? SKY_MODES[0];
|
|
28
|
+
return `空:${match.label}。次は${nextSkyMode(match.value).label}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The fixed-artwork SVG for a sky mode, as inner HTML for an aria-hidden icon span. */
|
|
32
|
+
export function skyModeIconSvg(mode) {
|
|
33
|
+
const match = SKY_MODES.find((entry) => entry.value === mode) ?? SKY_MODES[0];
|
|
34
|
+
return `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${match.icon}</svg>`;
|
|
35
|
+
}
|
|
36
|
+
|
|
16
37
|
const CLOSE_DELAY = 220;
|
|
17
38
|
let instanceId = 0;
|
|
18
39
|
|
|
@@ -221,9 +242,8 @@ export function createWorldCanvasUI({
|
|
|
221
242
|
if (!match) return;
|
|
222
243
|
skyMode = mode;
|
|
223
244
|
// Artwork is fixed code, never host data. Native button activation covers Enter/Space.
|
|
224
|
-
skyIcon.innerHTML =
|
|
225
|
-
const
|
|
226
|
-
const label = `空:${match.label}。次は${next.label}`;
|
|
245
|
+
skyIcon.innerHTML = skyModeIconSvg(mode);
|
|
246
|
+
const label = skyModeLabel(mode);
|
|
227
247
|
sky.setAttribute('aria-label', label);
|
|
228
248
|
sky.setAttribute('title', label);
|
|
229
249
|
}
|
|
@@ -411,7 +431,7 @@ export function createWorldCanvasUI({
|
|
|
411
431
|
});
|
|
412
432
|
listen(city, 'change', () => { if (businesses.has(city.value)) onCity?.(city.value); });
|
|
413
433
|
listen(sky, 'click', () => {
|
|
414
|
-
const next =
|
|
434
|
+
const next = nextSkyMode(skyMode);
|
|
415
435
|
setSky(next.value);
|
|
416
436
|
onSky?.(next.value);
|
|
417
437
|
});
|